[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AM6PR05MB61688309AFCF832CA4D67696D9910@AM6PR05MB6168.eurprd05.prod.outlook.com>
Date: Sun, 28 Jun 2020 13:50:14 +0000
From: Michael Shych <michaelsh@...lanox.com>
To: Wolfram Sang <wsa+renesas@...g-engineering.com>,
"linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>
CC: "linux-renesas-soc@...r.kernel.org"
<linux-renesas-soc@...r.kernel.org>,
Vadim Pasternak <vadimp@...lanox.com>,
Wolfram Sang <wsa@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [RFC PATCH 1/2] i2c: mlxcpld: check correct size of maximum
RECV_LEN packet
Hi Wolfram,
You are right, +1 isn't required.
Checked your patch also on HW. It works OK.
Thank you,
Michael.
> -----Original Message-----
> From: Wolfram Sang <wsa+renesas@...g-engineering.com>
> Sent: Sunday, June 28, 2020 2:53 PM
> To: linux-i2c@...r.kernel.org
> Cc: linux-renesas-soc@...r.kernel.org; Wolfram Sang <wsa+renesas@...g-
> engineering.com>; Vadim Pasternak <vadimp@...lanox.com>; Michael Shych
> <michaelsh@...lanox.com>; Wolfram Sang <wsa@...nel.org>; linux-
> kernel@...r.kernel.org
> Subject: [RFC PATCH 1/2] i2c: mlxcpld: check correct size of maximum RECV_LEN
> packet
>
> I2C_SMBUS_BLOCK_MAX defines already the maximum number as defined in
> the
> SMBus 2.0 specs. I don't see a reason to add 1 here. Also, fix the errno
> to what is suggested for this error.
>
> Fixes: c9bfdc7c16cb ("i2c: mlxcpld: Add support for smbus block read
> transaction")
> Signed-off-by: Wolfram Sang <wsa+renesas@...g-engineering.com>
> ---
>
> Only build tested, I don't have the HW. Please let me know if I
> overlooked something, but to the best of my knowledge, this +1 is wrong.
>
> drivers/i2c/busses/i2c-mlxcpld.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mlxcpld.c b/drivers/i2c/busses/i2c-mlxcpld.c
> index 2fd717d8dd30..71d7bae2cbca 100644
> --- a/drivers/i2c/busses/i2c-mlxcpld.c
> +++ b/drivers/i2c/busses/i2c-mlxcpld.c
> @@ -337,9 +337,9 @@ static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv
> *priv)
> if (priv->smbus_block && (val &
> MLXCPLD_I2C_SMBUS_BLK_BIT)) {
> mlxcpld_i2c_read_comm(priv,
> MLXCPLD_LPCI2C_NUM_DAT_REG,
> &datalen, 1);
> - if (unlikely(datalen > (I2C_SMBUS_BLOCK_MAX + 1))) {
> + if (unlikely(datalen > I2C_SMBUS_BLOCK_MAX)) {
> dev_err(priv->dev, "Incorrect smbus block read
> message len\n");
> - return -E2BIG;
> + return -EPROTO;
> }
> } else {
> datalen = priv->xfer.data_len;
> --
> 2.20.1
Powered by blists - more mailing lists