From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: cj.winklhofer@gmail.com, Rob Herring <robh+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Rob Herring <robh@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Jonathan Corbet <corbet@lwn.net>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v6 3/3] w1: add UART w1 bus driver
Date: Mon, 12 Feb 2024 16:30:00 +0100 [thread overview]
Message-ID: <466d7be4-6ca1-4eb2-a59b-a3f0a846a2df@linaro.org> (raw)
In-Reply-To: <20240209-w1-uart-v6-3-3e753c149196@gmail.com>
On 09/02/2024 07:22, Christoph Winklhofer via B4 Relay wrote:
> From: Christoph Winklhofer <cj.winklhofer@gmail.com>
>
> Add a UART 1-Wire bus driver. The driver utilizes the UART interface via
> the Serial Device Bus to create the 1-Wire timing patterns. The driver
> was tested on a "Raspberry Pi 3B" with a DS18B20 and on a "Variscite
> DART-6UL" with a DS18S20 temperature sensor.
>
> The 1-Wire timing pattern and the corresponding UART baud-rate with the
> interpretation of the transferred bytes are described in the document:
> +/*
> + * struct w1_uart_config - configuration for 1-Wire operation
> + *
> + * @baudrate: baud-rate returned from serdev
> + * @delay_us: delay to complete a 1-Wire cycle (in us)
> + * @tx_byte: byte to generate 1-Wire timing pattern
> + */
> +struct w1_uart_config {
> + unsigned int baudrate;
> + unsigned int delay_us;
> + u8 tx_byte;
> +};
> +
> +/*
> + * struct w1_uart_config - w1-uart device data
That's neither correct (device, not config) nor proper kerneldoc nor
useful. Your comment repeats struct name. If you want to make it
kerneldoc, go ahead, but then make it a full kerneldoc.
And obviously compile with W=1.
> + *
> + * @serdev: serial device
> + * @bus: w1-bus master
> + * @cfg_reset: config for 1-Wire reset
> + * @cfg_touch_0: config for 1-Wire write-0 cycle
> + * @cfg_touch_1: config for 1-Wire write-1 and read cycle
> + * @rx_byte_received: completion for serdev receive
> + * @rx_err: indicates an error in serdev-receive
> + * @rx_byte: result byte from serdev-receive
> + * @mutex: mutex to protected rx_err and rx_byte from concurrent access
> + * in w1-callbacks and serdev-receive.
> + */
> +struct w1_uart_device {
> + struct serdev_device *serdev;
> + struct w1_bus_master bus;
> +
> + struct w1_uart_config cfg_reset;
> + struct w1_uart_config cfg_touch_0;
> + struct w1_uart_config cfg_touch_1;
> +
> + struct completion rx_byte_received;
> + int rx_err;
> + u8 rx_byte;
> +
How did you solve my comment and checkpatch warning from previous version:
CHECK: struct mutex definition without comment
> + struct mutex mutex;
> +};
> +
> +/*
> + * struct w1_uart_limits - limits for 1-Wire operations
> + *
> + * @baudrate: Requested baud-rate to create 1-Wire timing pattern
> + * @bit_min_us: minimum time for a bit (in us)
> + * @bit_max_us: maximum time for a bit (in us)
> + * @sample_us: timespan to sample 1-Wire response
> + * @cycle_us: duration of the 1-Wire cycle
> + */
> +struct w1_uart_limits {
> + unsigned int baudrate;
> + unsigned int bit_min_us;
> + unsigned int bit_max_us;
> + unsigned int sample_us;
> + unsigned int cycle_us;
...
> +/*
> + * Configuration for write-1 and read cycle (touch bit 1)
> + * - bit_min_us is 5us, add margin and use 6us
> + * - limits for sample time 5us-15us, use 15us
> + */
> +static int w1_uart_set_config_touch_1(struct w1_uart_device *w1dev)
> +{
> + struct serdev_device *serdev = w1dev->serdev;
> + struct device_node *np = serdev->dev.of_node;
> +
> + struct w1_uart_limits limits = { .baudrate = 115200,
> + .bit_min_us = 6,
> + .bit_max_us = 15,
> + .sample_us = 15,
> + .cycle_us = 70 };
> +
> + of_property_read_u32(np, "write-1-bps", &limits.baudrate);
> +
> + return w1_uart_set_config(serdev, &limits, &w1dev->cfg_touch_1);
> +}
> +
> +/*
> + * Configure and open the serial device
> + */
> +static int w1_uart_serdev_open(struct w1_uart_device *w1dev)
> +{
> + struct serdev_device *serdev = w1dev->serdev;
> + struct device *dev = &serdev->dev;
> + int ret;
> +
> + /* serdev is automatically closed on unbind or driver remove */
Drop comment, that's obvious. That's what devm* functions are for.
> + ret = devm_serdev_device_open(dev, serdev);
> + if (ret < 0)
> + return ret;
> +
> + ret = serdev_device_set_parity(serdev, SERDEV_PARITY_NONE);
> + if (ret < 0) {
> + dev_err(dev, "set parity failed\n");
> + return ret;
> + }
Best regards,
Krzysztof
next prev parent reply other threads:[~2024-02-12 15:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-09 6:22 [PATCH v6 0/3] " Christoph Winklhofer via B4 Relay
2024-02-09 6:22 ` [PATCH v6 1/3] dt-bindings: serial: allow onewire as child node Christoph Winklhofer via B4 Relay
2024-02-12 15:32 ` (subset) " Krzysztof Kozlowski
2024-02-09 6:22 ` [PATCH v6 2/3] dt-bindings: w1: UART 1-Wire bus Christoph Winklhofer via B4 Relay
2024-02-12 15:32 ` (subset) " Krzysztof Kozlowski
2024-02-09 6:22 ` [PATCH v6 3/3] w1: add UART w1 bus driver Christoph Winklhofer via B4 Relay
2024-02-12 15:30 ` Krzysztof Kozlowski [this message]
2024-02-13 7:02 ` Christoph Winklhofer
2024-02-13 8:27 ` Krzysztof Kozlowski
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=466d7be4-6ca1-4eb2-a59b-a3f0a846a2df@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=cj.winklhofer@gmail.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=robh@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®