On Thu, Apr 14, 2022 at 03:57:36PM +0200, Geert Uytterhoeven wrote: > The checker code to iterate over all drive strength and bias register > description items is cumbersome, due to the repeated calculation of > indices, and the use of hardcoded array sizes. The latter was done > under the assumption they would never need to be changed, which turned > out to be false. > > Increase readability by introducing helper macros to access drive > strength and bias register description items. > Increase maintainability by replacing hardcoded numbers by array sizes > calculated at compile-time. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> Cool, this makes the code much more readable! In general, I am fine with it, maybe one tiny addition to make it even more readable? > +#define drive_nfields ARRAY_SIZE(drive_regs->fields) Let's have here: #define drive_ofs(i) drive_regs[(i) / drive_nfields] > +#define drive_reg(i) drive_regs[(i) / drive_nfields].reg and here #define drive_reg(i) drive_ofs(i).reg > +#define drive_bit(i) ((i) % drive_nfields) > +#define drive_field(i) drive_regs[(i) / drive_nfields].fields[drive_bit(i)] and here drive_field(i) drv_ofs(i).fields[drive_bit(i)] ?
Attachment:
signature.asc
Description: PGP signature