[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZksbzQeR6cDsQz0B@google.com>
Date: Mon, 20 May 2024 17:45:49 +0800
From: Tzung-Bi Shih <tzungbi@...nel.org>
To: Ben Walsh <ben@...nut.com>
Cc: Benson Leung <bleung@...omium.org>, Guenter Roeck <groeck@...omium.org>,
"Dustin L. Howett" <dustin@...ett.net>,
Kieran Levin <ktl@...me.work>,
Thomas Weißschuh <linux@...ssschuh.net>,
Mario Limonciello <mario.limonciello@....com>,
chrome-platform@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/6] platform/chrome: cros_ec_lpc: MEC access can return
error code
On Wed, May 15, 2024 at 06:56:26AM +0100, Ben Walsh wrote:
> diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
[...]
> @@ -116,14 +118,19 @@ static u8 cros_ec_lpc_write_bytes(unsigned int offset, unsigned int length,
> * An instance of the read function of struct lpc_driver_ops, used for the
> * MEC variant of LPC EC.
> */
> -static u8 cros_ec_lpc_mec_read_bytes(unsigned int offset, unsigned int length,
> - u8 *dest)
> +static int cros_ec_lpc_mec_read_bytes(unsigned int offset, unsigned int length,
> + u8 *dest)
> {
> - int in_range = cros_ec_lpc_mec_in_range(offset, length);
> + int in_range;
>
> - if (in_range < 0)
> + if (length == 0)
> return 0;
>
> + in_range = cros_ec_lpc_mec_in_range(offset, length);
> +
> + if (in_range < 0)
> + return in_range;
> +
> return in_range ?
> cros_ec_lpc_io_bytes_mec(MEC_IO_READ,
> offset - EC_HOST_CMD_REGION0,
The `in_range` change looks irrelevant to the patch. Or it should rather be
an independent patch if it fixes something.
> @@ -135,14 +142,19 @@ static u8 cros_ec_lpc_mec_read_bytes(unsigned int offset, unsigned int length,
> * An instance of the write function of struct lpc_driver_ops, used for the
> * MEC variant of LPC EC.
> */
> -static u8 cros_ec_lpc_mec_write_bytes(unsigned int offset, unsigned int length,
> - const u8 *msg)
> +static int cros_ec_lpc_mec_write_bytes(unsigned int offset, unsigned int length,
> + const u8 *msg)
> {
> - int in_range = cros_ec_lpc_mec_in_range(offset, length);
> + int in_range;
>
> - if (in_range < 0)
> + if (length == 0)
> return 0;
>
> + in_range = cros_ec_lpc_mec_in_range(offset, length);
> +
> + if (in_range < 0)
> + return in_range;
> +
> return in_range ?
> cros_ec_lpc_io_bytes_mec(MEC_IO_WRITE,
> offset - EC_HOST_CMD_REGION0,
Same as above.
> @@ -179,28 +194,41 @@ static int cros_ec_pkt_xfer_lpc(struct cros_ec_device *ec,
[...]
> /* Check result */
> - msg->result = cros_ec_lpc_ops.read(EC_LPC_ADDR_HOST_DATA, 1, &sum);
> + ret = cros_ec_lpc_ops.read(EC_LPC_ADDR_HOST_DATA, 1, &sum);
> + if (ret < 0)
> + goto done;
> + msg->result = sum;
Even though they are equivalent, `msg->result = ret` looks more intuitive.
> @@ -255,32 +286,47 @@ static int cros_ec_cmd_xfer_lpc(struct cros_ec_device *ec,
[...]
> /* Check result */
> - msg->result = cros_ec_lpc_ops.read(EC_LPC_ADDR_HOST_DATA, 1, &sum);
> + ret = cros_ec_lpc_ops.read(EC_LPC_ADDR_HOST_DATA, 1, &sum);
> + if (ret < 0)
> + goto done;
> + msg->result = sum;
Same as above.
Powered by blists - more mailing lists