Re: [PATCH 3/9] iio: adc: ad_sigma_delta: use BITS_TO_BYTES() macro

From: Andy Shevchenko
Date: Mon Jun 23 2025 - 02:54:41 EST


On Fri, Jun 20, 2025 at 05:20:09PM -0500, David Lechner wrote:
> Use the BITS_TO_BYTES() macro instead of dividing by 8 to convert bits
> to bytes.
>
> This makes it more obvious what unit conversion is taking place.
>
> In once instance, we also avoid the temporary assignment to a variable
> as it was confusing that reg_size was being used with two different
> units (bits and bytes).

...

> - size = DIV_ROUND_UP(reset_length, 8);
> + size = BITS_TO_BYTES(reset_length);
> buf = kcalloc(size, sizeof(*buf), GFP_KERNEL);
> if (!buf)
> return -ENOMEM;

Hmm... On the rough glance this sounds like some kind of bitmap
and hence bitmap_zalloc() (and other bitmap APIs), but I am not
sure.

--
With Best Regards,
Andy Shevchenko