public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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>,
	kernel test robot <lkp@intel.com>,
	Prashant Malani <pmalani@chromium.org>,
	Benson Leung <bleung@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	chrome-platform@lists.linux.dev
Subject: Re: [PATCH v12 1/3] platform/chrome: cros_ec_uart: Add cros-ec-uart transport layer
Date: Mon, 26 Dec 2022 16:12:07 +0800	[thread overview]
Message-ID: <Y6lXV8Rhh1Da572l@google.com> (raw)
In-Reply-To: <20221209092619.v12.1.If7926fcbad397bc6990dd725690229bed403948c@changeid>

On Fri, Dec 09, 2022 at 09:26:22AM -0700, Mark Hasemeyer wrote:
> diff --git a/drivers/platform/chrome/cros_ec_uart.c b/drivers/platform/chrome/cros_ec_uart.c
[...]
> +static int cros_ec_uart_rx_bytes(struct serdev_device *serdev,
> +				 const u8 *data,
> +				 size_t count)
> +{
> +	struct ec_host_response *response;

There are 2 "response" in the context: struct response_info vs.
struct ec_host_response.  The pointer `response` here is only used for
setting `exp_len`.

I would suggest to introduce another pointer:
    struct response_info *resp = &ec_uart->response;
So that most of the following "ec_uart->response." could simplify to
"resp->".

[...]
> +	/* Read data_len if we received response header and if exp_len was not read before. */
> +	if (ec_uart->response.size >= sizeof(*response) &&
> +	    ec_uart->response.exp_len == 0) {
> +		response = (struct ec_host_response *) ec_uart->response.data;

Please drop the extra space.

> +static int cros_ec_uart_pkt_xfer(struct cros_ec_device *ec_dev,
> +				 struct cros_ec_command *ec_msg)
> +{
> +	struct cros_ec_uart *ec_uart = ec_dev->priv;
> +	struct serdev_device *serdev = ec_uart->serdev;
> +	struct ec_host_response *response;

Ditto, if using another pointer to struct response_info could simplify the
function a bit.

> +	unsigned int len;
> +	int ret, i;
> +	u8 sum = 0;

To make it clear, please drop the initialization and set it to 0 just right
before it is used.

[...]
> +	/* Validate checksum */
> +	for (i = 0; i < sizeof(*response) + response->data_len; i++)
> +		sum += ec_dev->din[i];

The function is long.  Setting sum to 0 before the loop improves the
readability.

> +static int cros_ec_uart_probe(struct serdev_device *serdev)
> +{
> +	struct device *dev = &serdev->dev;
> +	struct cros_ec_device *ec_dev;
> +	struct cros_ec_uart *ec_uart;
> +	int ret;
> +
> +	ec_uart = devm_kzalloc(dev, sizeof(*ec_uart), GFP_KERNEL);
> +	if (!ec_uart)
> +		return -ENOMEM;
> +
> +	ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL);
> +	if (!ec_dev)
> +		return -ENOMEM;
> +
> +	ec_uart->serdev = serdev;

The assignment can move somewhere before calling cros_ec_uart_acpi_probe().

> +
> +	ret = devm_serdev_device_open(dev, ec_uart->serdev);

Using `ec_uart->serdev` here makes less sense.  Please use `serdev` directly.

  parent reply	other threads:[~2022-12-26  8:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-09 16:26 [PATCH v12 1/3] platform/chrome: cros_ec_uart: Add cros-ec-uart transport layer Mark Hasemeyer
2022-12-09 16:26 ` [PATCH v12 2/3] dt-bindings: mfd: cros-ec: Add UART compatible string Mark Hasemeyer
2022-12-09 16:26 ` [PATCH v12 3/3] platform/chrome: cros_ec_uart: Add DT enumeration support Mark Hasemeyer
2022-12-26  8:12 ` Tzung-Bi Shih [this message]
2022-12-27 10:16 ` [PATCH v12 1/3] platform/chrome: cros_ec_uart: Add cros-ec-uart transport layer Tzung-Bi Shih
2022-12-28  3:50 ` patchwork-bot+chrome-platform
2022-12-28  5:40 ` patchwork-bot+chrome-platform

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=Y6lXV8Rhh1Da572l@google.com \
    --to=tzungbi@kernel.org \
    --cc=bhanumaiya@chromium.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=groeck@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=markhas@chromium.org \
    --cc=pmalani@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox