Re: [PATCH 2/2] i2c: designware: abort the transfer if receiving byte count of 0

From: Andy Shevchenko
Date: Thu Aug 17 2023 - 11:52:23 EST


On Thu, Aug 17, 2023 at 04:42:05PM +0200, Yann Sionneau wrote:
> Le 11/08/2023 à 16:01, Andy Shevchenko a écrit :
> > On Fri, Aug 11, 2023 at 02:46:24PM +0200, Yann Sionneau wrote:

...

> > > + if ((tmp <= I2C_SMBUS_BLOCK_MAX) && (tmp != 0))
> > if (tmp && tmp <= I2C_SMBUS_BLOCK_MAX)
>
> I find the tmp != 0 "more obvious", I am more used to "just tmp" when it's a
> pointer or a boolean, but maybe it's just me!
>
> I'll fix that in the V2 :)

IIRC it's unsigned, so you may use

if (tmp > 0 && tmp <= I2C_SMBUS_BLOCK_MAX)

which will be more explicit.

> > > + len = i2c_dw_recv_len(dev, tmp);
> > > + else
> > > + i2c_dw_abort(dev);

--
With Best Regards,
Andy Shevchenko