lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 18 Nov 2022 13:43:47 +0800
From:   Tzung-Bi Shih <tzungbi@...nel.org>
To:     Mark Hasemeyer <markhas@...omium.org>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Raul Rangel <rrangel@...omium.org>,
        Bhanu Prakash Maiya <bhanumaiya@...omium.org>,
        Benson Leung <bleung@...omium.org>,
        Enric Balletbo i Serra <enric.balletbo@...labora.com>,
        Guenter Roeck <groeck@...omium.org>,
        chrome-platform@...ts.linux.dev
Subject: Re: [PATCH v7 1/3] platform/chrome: cros_ec_uart: Add cros-ec-uart
 transport layer

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@...omium.org>
> +R:	Enric Balletbo i Serra <enric.balletbo@...labora.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`.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ