* [RFC PATCH 0/2] i2c: check correct size of maximum RECV_LEN packet
@ 2020-06-28 11:52 Wolfram Sang
2020-06-28 11:52 ` [RFC PATCH 1/2] i2c: mlxcpld: " Wolfram Sang
2020-06-28 11:52 ` [RFC PATCH 2/2] i2c: octeon: " Wolfram Sang
0 siblings, 2 replies; 5+ messages in thread
From: Wolfram Sang @ 2020-06-28 11:52 UTC (permalink / raw)
To: linux-i2c
Cc: linux-renesas-soc, Wolfram Sang, David Daney, Jan Glauber,
linux-kernel, Michael Shych, Wolfram Sang
I am preparing to add RECV_LEN support to Renesas I2C drivers. On my
way, I found these two peculiarities. Let's discuss them.
Wolfram Sang (2):
i2c: mlxcpld: check correct size of maximum RECV_LEN packet
i2c: octeon: check correct size of maximum RECV_LEN packet
drivers/i2c/busses/i2c-mlxcpld.c | 4 ++--
drivers/i2c/busses/i2c-octeon-core.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH 1/2] i2c: mlxcpld: check correct size of maximum RECV_LEN packet
2020-06-28 11:52 [RFC PATCH 0/2] i2c: check correct size of maximum RECV_LEN packet Wolfram Sang
@ 2020-06-28 11:52 ` Wolfram Sang
2020-06-28 13:50 ` Michael Shych
2020-06-28 11:52 ` [RFC PATCH 2/2] i2c: octeon: " Wolfram Sang
1 sibling, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2020-06-28 11:52 UTC (permalink / raw)
To: linux-i2c
Cc: linux-renesas-soc, Wolfram Sang, Vadim Pasternak, Michael Shych,
Wolfram Sang, linux-kernel
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@sang-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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [RFC PATCH 1/2] i2c: mlxcpld: check correct size of maximum RECV_LEN packet
2020-06-28 11:52 ` [RFC PATCH 1/2] i2c: mlxcpld: " Wolfram Sang
@ 2020-06-28 13:50 ` Michael Shych
0 siblings, 0 replies; 5+ messages in thread
From: Michael Shych @ 2020-06-28 13:50 UTC (permalink / raw)
To: Wolfram Sang, linux-i2c
Cc: linux-renesas-soc, Vadim Pasternak, Wolfram Sang, linux-kernel
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@sang-engineering.com>
> Sent: Sunday, June 28, 2020 2:53 PM
> To: linux-i2c@vger.kernel.org
> Cc: linux-renesas-soc@vger.kernel.org; Wolfram Sang <wsa+renesas@sang-
> engineering.com>; Vadim Pasternak <vadimp@mellanox.com>; Michael Shych
> <michaelsh@mellanox.com>; Wolfram Sang <wsa@kernel.org>; linux-
> kernel@vger.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@sang-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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH 2/2] i2c: octeon: check correct size of maximum RECV_LEN packet
2020-06-28 11:52 [RFC PATCH 0/2] i2c: check correct size of maximum RECV_LEN packet Wolfram Sang
2020-06-28 11:52 ` [RFC PATCH 1/2] i2c: mlxcpld: " Wolfram Sang
@ 2020-06-28 11:52 ` Wolfram Sang
2020-07-24 19:45 ` Wolfram Sang
1 sibling, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2020-06-28 11:52 UTC (permalink / raw)
To: linux-i2c
Cc: linux-renesas-soc, Wolfram Sang, Robert Richter, Wolfram Sang,
David Daney, Jan Glauber, linux-kernel
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.
Fixes: 886f6f8337dd ("i2c: octeon: Support I2C_M_RECV_LEN")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-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-octeon-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-octeon-core.c b/drivers/i2c/busses/i2c-octeon-core.c
index d9607905dc2f..845eda70b8ca 100644
--- a/drivers/i2c/busses/i2c-octeon-core.c
+++ b/drivers/i2c/busses/i2c-octeon-core.c
@@ -347,7 +347,7 @@ static int octeon_i2c_read(struct octeon_i2c *i2c, int target,
if (result)
return result;
if (recv_len && i == 0) {
- if (data[i] > I2C_SMBUS_BLOCK_MAX + 1)
+ if (data[i] > I2C_SMBUS_BLOCK_MAX)
return -EPROTO;
length += data[i];
}
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 2/2] i2c: octeon: check correct size of maximum RECV_LEN packet
2020-06-28 11:52 ` [RFC PATCH 2/2] i2c: octeon: " Wolfram Sang
@ 2020-07-24 19:45 ` Wolfram Sang
0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2020-07-24 19:45 UTC (permalink / raw)
To: linux-i2c, Robert Richter
Cc: linux-renesas-soc, David Daney, Jan Glauber, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1170 bytes --]
On Sun, Jun 28, 2020 at 01:52:45PM +0200, Wolfram Sang wrote:
> 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.
>
> Fixes: 886f6f8337dd ("i2c: octeon: Support I2C_M_RECV_LEN")
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
Robert, is this correct?
>
> 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-octeon-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-octeon-core.c b/drivers/i2c/busses/i2c-octeon-core.c
> index d9607905dc2f..845eda70b8ca 100644
> --- a/drivers/i2c/busses/i2c-octeon-core.c
> +++ b/drivers/i2c/busses/i2c-octeon-core.c
> @@ -347,7 +347,7 @@ static int octeon_i2c_read(struct octeon_i2c *i2c, int target,
> if (result)
> return result;
> if (recv_len && i == 0) {
> - if (data[i] > I2C_SMBUS_BLOCK_MAX + 1)
> + if (data[i] > I2C_SMBUS_BLOCK_MAX)
> return -EPROTO;
> length += data[i];
> }
> --
> 2.20.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-24 19:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-28 11:52 [RFC PATCH 0/2] i2c: check correct size of maximum RECV_LEN packet Wolfram Sang
2020-06-28 11:52 ` [RFC PATCH 1/2] i2c: mlxcpld: " Wolfram Sang
2020-06-28 13:50 ` Michael Shych
2020-06-28 11:52 ` [RFC PATCH 2/2] i2c: octeon: " Wolfram Sang
2020-07-24 19:45 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).