diff mbox series

[RFC,2/2] i2c: octeon: check correct size of maximum RECV_LEN packet

Message ID 20200628115245.9638-3-wsa+renesas@sang-engineering.com
State Superseded
Headers show
Series i2c: check correct size of maximum RECV_LEN packet | expand

Commit Message

Wolfram Sang June 28, 2020, 11:52 a.m. UTC
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(-)

Comments

Wolfram Sang July 24, 2020, 7:45 p.m. UTC | #1
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
>
diff mbox series

Patch

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];
 		}