Re: [PATCH v2 2/2] iio: adc: Add TI ADS131M0x ADC driver

From: Andy Shevchenko

Date: Thu Nov 13 2025 - 15:52:14 EST


On Thu, Nov 13, 2025 at 4:12 PM Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> wrote:
> On Mon, Nov 10, 2025 at 10:46:02PM +0200, Andy Shevchenko wrote:

...

> > > - Handles both input and output CRC; uses a non-reflected CCITT (0x1021)
> > > implementation because the generic crc_ccitt helper is incompatible.
>
> For the crc_ccitt() related part I wrote this comment ^^^ :) in the
> commit message.
>
> Anyways, after some more research, looks like crc_itu_t() should be used. It
> seems to work.

I see, that's good news!

...

> > > +/* 24-bit resolution */
> > > +#define ADS131M_RESOLUTION_BITS 24
> > > +/* Divisor is 2^(Res - 1) for signed 2's complement */
> > > +#define ADS131M_SCALE_DIVISOR (1UL << (ADS131M_RESOLUTION_BITS - 1))
> >
> > Why not BIT() here?
>
> It's meant to signal an arithmetic calculation, BIT() is typically used
> for a hardware bitmask or a flag. Should i still use BIT() here or there
> is other way to describe it?

My understanding that the SCALE_DIVISOR is not a good name and here is
something like maximum resolution factor, and when MAX_ become in the
name, the (BIT($FOO) - 1) notation is a good thing that shows
directly how many bits that MAX is based on the HW bitfield or so. But
also note that $FOO == plain number, i.e. 24 is assumed here.


--
With Best Regards,
Andy Shevchenko