From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: alison@she-devel.com, johan@kernel.org
Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
achaiken@aurora.tech
Subject: Re: [PATCH 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud
Date: Mon, 1 May 2023 19:40:35 +0200 [thread overview]
Message-ID: <da606e4b-9fe9-ca47-2c9b-1b32ae2ce498@linaro.org> (raw)
In-Reply-To: <20230501170124.1218603-2-alison@she-devel.com>
On 01/05/2023 19:01, alison@she-devel.com wrote:
> From: Alison Chaiken <achaiken@aurora.tech>
>
> Add support for setting the baud rate of U-Blox Zed-F9P GNSS devices.
> Provide functions that support writing of arbitrary configuration
> messages to the device plus one that specifically configures the baud
> rate. Override the default gnss_serial_open() with a new method that
> writes the configuration message to the GNSS if the devicetree declares
> it to be a Zed F9P and requests a non-default baud. Add a boolean flag
> to the ubx_data private data of the GNSS driver in order to track
> whether the configuration message has already been written. Set the Zed
> F9P to its default port speed if the devicetree does not specify a
> value.
>
> Signed-off-by: Alison Chaiken <achaiken@aurora.tech>
> ---
> drivers/gnss/ubx.c | 195 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 195 insertions(+)
>
Thank you for your patch. There is something to discuss/improve.
> +/* Configure the Zed F9P baud rate via the UBX-CFG-VALSET message. */
> +static int set_zedf9p_baud(struct gnss_device *gdev,
> + struct serdev_device *serdev, const speed_t speed)
> +{
> + size_t count = 0U;
> + int ret;
> +
> + if (speed == ZED_F9P_DEFAULT_BAUD)
> + return 0;
> +
> + ret = prepare_zedf9p_config_msg(speed, &gdev->dev, ZED_F9P_BAUD_CONFIG_REGISTER);
> + if (ret)
> + return ret;
> + /* Initially set the UART to the default speed to match the GNSS' power-on value. */
> + serdev_device_set_baudrate(serdev, ZED_F9P_DEFAULT_BAUD);
> + /* Now set the new baud rate. */
> + count = gdev->ops->write_raw(gdev, ZED_F9P_CFG_VALSET_MSG, CFG_MSG_TOTAL_LEN);
> + if (count != CFG_MSG_TOTAL_LEN)
> + return count;
> +
> + return 0;
> +}
> +
> +static int ubx_serial_open(struct gnss_device *gdev)
> +{
> + struct gnss_serial *gserial = gnss_get_drvdata(gdev);
> + struct serdev_device *serdev = gserial->serdev;
> + struct ubx_data *data = gnss_serial_get_drvdata(gserial);
> + struct device_node *np;
> + int ret;
> +
> + ret = serdev_device_open(serdev);
> + if (ret)
> + return ret;
> +
> + serdev_device_set_flow_control(serdev, false);
> +
> + np = serdev->dev.of_node;
> + if ((of_device_is_compatible(np, "u-blox,zed-f9p")) && (!data->is_configured)) {
Use driver data/match data for such customizations. compatibles
sprinkled over the driver code do not scale, make code unreadable. They
also obfuscate a but compatibility - based on your of_device_id I would
claim devices are compatible and you can remove all the entries except one.
...
> @@ -133,6 +327,7 @@ static const struct of_device_id ubx_of_match[] = {
> { .compatible = "u-blox,neo-6m" },
> { .compatible = "u-blox,neo-8" },
> { .compatible = "u-blox,neo-m8" },
> + { .compatible = "u-blox,zed-f9p" },
Looks compatible with previous, right?
> {},
> };
> MODULE_DEVICE_TABLE(of, ubx_of_match);
Best regards,
Krzysztof
next prev parent reply other threads:[~2023-05-01 17:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-01 17:01 [PATCH v3 0/2] support config of U-Blox Zed-F9P GNSS alison
2023-05-01 17:01 ` [PATCH 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud alison
2023-05-01 17:40 ` Krzysztof Kozlowski [this message]
2023-05-01 17:01 ` [PATCH 2/2] dt-bindings: gnss: Add U-Blox Zed-F9 alison
2023-05-01 17:42 ` Krzysztof Kozlowski
2023-05-05 21:21 ` Rob Herring
2023-05-05 21:22 ` Rob Herring
-- strict thread matches above, loose matches on Subject: below --
2023-04-29 22:43 [PATCH 0/2] support config of U-Blox Zed-F9P GNSS alison
2023-04-29 22:43 ` [PATCH 1/2] gnss: ubx: customize serial device open to set U-Blox Zed-F9P baud alison
2023-04-30 0:20 ` kernel test robot
2023-05-09 3:09 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da606e4b-9fe9-ca47-2c9b-1b32ae2ce498@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=achaiken@aurora.tech \
--cc=alison@she-devel.com \
--cc=devicetree@vger.kernel.org \
--cc=johan@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®