Re: [PATCH] i2c: designware: Replace magic numbers with named constants

From: Andy Shevchenko

Date: Thu Nov 06 2025 - 05:53:01 EST


On Thu, Nov 06, 2025 at 11:42:28AM +0100, Mika Westerberg wrote:
> On Wed, Nov 05, 2025 at 07:18:44PM +0300, Artem Shimko wrote:

...

> /* Timeouts in us */
> #define DW_IC_BUSY_POLL_TIMEOUT 1100
> #define DW_IC_BUSY_TOTAL_TIMEOUT 20000
> #define DW_IC_FOO_TIMEOUT 1234

It's in-kernel practice to add units to the definitions and avoid unneeded
comments. Also it will be clearer to the reader without looking back for any
comments like above.

...

> All the register offsets, shifts and masks should be in
> drivers/i2c/busses/i2c-designware-core.h and you don't need to "document"
> them because all this is available in the datasheet.

Also the benefit could be switch to use bitfield.h.

--
With Best Regards,
Andy Shevchenko