From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Mark Hasemeyer <markhas@chromium.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Raul Rangel <rrangel@chromium.org>,
Bhanu Prakash Maiya <bhanumaiya@chromium.org>,
Benson Leung <bleung@chromium.org>,
Enric Balletbo i Serra <enric.balletbo@collabora.com>,
Guenter Roeck <groeck@chromium.org>,
chrome-platform@lists.linux.dev
Subject: Re: [PATCH v7 1/3] platform/chrome: cros_ec_uart: Add cros-ec-uart transport layer
Date: Fri, 18 Nov 2022 13:43:47 +0800 [thread overview]
Message-ID: <Y3cbk3dEuRWyJh40@google.com> (raw)
In-Reply-To: <20221117114818.v7.1.If7926fcbad397bc6990dd725690229bed403948c@changeid>
On Thu, Nov 17, 2022 at 11:48:46AM -0700, Mark Hasemeyer wrote:
> diff --git a/MAINTAINERS b/MAINTAINERS
[...]
> +CHROMEOS EC UART DRIVER
> +M: Bhanu Prakash Maiya <bhanumaiya@chromium.org>
> +R: Enric Balletbo i Serra <enric.balletbo@collabora.com>
I think the address is no longer reachable.
> diff --git a/drivers/platform/chrome/cros_ec_uart.c b/drivers/platform/chrome/cros_ec_uart.c
[...]
> + * Copyright 2020 Google LLC.
Any concerns if it uses 2022?
> +#include <linux/delay.h>
> +#include <linux/errno.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/acpi.h>
> +#include <linux/platform_data/cros_ec_commands.h>
> +#include <linux/platform_data/cros_ec_proto.h>
> +#include <linux/serdev.h>
> +#include <linux/slab.h>
> +#include <uapi/linux/sched/types.h>
To be neat, please sort them.
> +/**
> + * struct response_info - Encapsulate EC response related
> + * information for passing between function
> + * cros_ec_uart_pkt_xfer() and cros_ec_uart_rx_bytes()
> + * callback.
> + * @data: Copy the data received from EC here.
> + * @max_size: Max size allocated for the @data buffer. If the
> + * received data exceeds this value, we log an error.
> + * @size: Actual size of data received from EC. This is also
> + * used to accumulate byte count with response is received
> + * in dma chunks.
> + * @exp_len: Expected bytes of response from EC including header.
> + * @error: 0 for success, negative error code for a failure.
> + * @received: Set to true on receiving a valid EC response.
> + * @wait_queue: Wait queue EC response where the cros_ec sends request
> + * to EC and waits
> + */
> +struct response_info {
> + void *data;
> + size_t max_size;
> + size_t size;
> + int error;
> + size_t exp_len;
> + bool received;
> + wait_queue_head_t wait_queue;
> +};
To be neat, please swap `error` and `exp_len` to maintain the order with
the kernel-doc.
> +struct cros_ec_uart {
> + struct serdev_device *serdev;
> + u32 baudrate;
> + u8 flowcontrol;
To be neat, please remove the extra space.
> +static int cros_ec_uart_pkt_xfer(struct cros_ec_device *ec_dev,
> + struct cros_ec_command *ec_msg)
> +{
[...]
> + /* Prepare an outgoing message in the output buffer */
> + len = cros_ec_prepare_tx(ec_dev, ec_msg);
> + dev_dbg(ec_dev->dev, "Prepared len=%d\n", len);
> +
[...]
> + /* Write serial device buffer */
> + ret = serdev_device_write_buf(serdev, ec_dev->dout, len);
> + if (ret < len) {
> + dev_err(&serdev->dev,
To be neat, please use `ec_dev->dev`.
> + "Unable to write data to serial device %s",
> + dev_name(&serdev->dev));
To be neat, please use `ec_dev->dev`. Also, I guess the info can be
dropped as it is already an dev_err().
> + /* Check if wait_queue was interrupted due to an error */
> + if (ec_uart->response.error < 0) {
> + dev_warn(&serdev->dev, "Response error detected.\n");
To be neat, please use `ec_dev->dev`.
> + /* Check if valid response was received or there was a timeout */
> + if (!ec_uart->response.received) {
> + dev_warn(&serdev->dev, "EC failed to respond in time.\n");
To be neat, please use `ec_dev->dev`.
> + /* Copy response packet to ec_msg data buffer */
> + memcpy(ec_msg->data,
> + ec_dev->din + sizeof(*response),
> + response->data_len);
> +
> + /* Add all response header bytes for checksum calculation */
> + for (i = 0; i < sizeof(*response); i++)
> + sum += ec_dev->din[i];
> +
> + /* Copy response packet payload and compute checksum */
> + for (i = 0; i < response->data_len; i++)
> + sum += ec_msg->data[i];
The 2 loops can be combined, e.g.:
for (i = 0; i < sizeof(*response) + response->data_len; i++)
> +static int cros_ec_uart_probe(struct serdev_device *serdev)
> +{
> + struct device *dev = &serdev->dev;
[...]
> + /* Open the serial device */
> + ret = devm_serdev_device_open(dev, ec_uart->serdev);
> + if (ret) {
> + dev_err(dev, "Unable to open UART device %s",
> + dev_name(&serdev->dev));
To be concise, please use `dev`. Also I think the info can be
dropped as it is already an dev_err().
> + /* Initialize ec_dev for cros_ec */
> + ec_dev->phys_name = dev_name(&ec_uart->serdev->dev);
To be concise, please use `dev`.
prev parent reply other threads:[~2022-11-18 5:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 18:48 [PATCH v7 1/3] platform/chrome: cros_ec_uart: Add cros-ec-uart transport layer Mark Hasemeyer
2022-11-17 18:48 ` [PATCH v7 2/3] dt-bindings: mfd: Add DT compatible string "google,cros_ec_uart" Mark Hasemeyer
2022-11-18 5:44 ` Tzung-Bi Shih
2022-11-18 8:59 ` Lee Jones
2022-11-18 9:19 ` Tzung-Bi Shih
2022-11-18 12:47 ` Krzysztof Kozlowski
2022-11-18 12:42 ` Guenter Roeck
2022-11-18 14:28 ` Lee Jones
2022-11-18 12:49 ` Krzysztof Kozlowski
2022-11-17 18:48 ` [PATCH v7 3/3] platform/chrome: cros_ec_uart: Add DT enumeration support Mark Hasemeyer
2022-11-18 5:44 ` Tzung-Bi Shih
2022-11-29 18:13 ` Mark Hasemeyer
2022-11-30 7:09 ` Tzung-Bi Shih
2022-11-30 16:52 ` Raul Rangel
2022-12-01 3:07 ` Tzung-Bi Shih
2022-11-18 5:43 ` Tzung-Bi Shih [this message]
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=Y3cbk3dEuRWyJh40@google.com \
--to=tzungbi@kernel.org \
--cc=bhanumaiya@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=enric.balletbo@collabora.com \
--cc=groeck@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markhas@chromium.org \
--cc=rrangel@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.