Re: [PATCH 3/9] iio: adc: ad_sigma_delta: use BITS_TO_BYTES() macro
From: David Lechner
Date: Fri Jun 27 2025 - 19:36:36 EST
On 6/23/25 1:54 AM, Andy Shevchenko wrote:
> 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.
>
I looked at it, but I don't think it is worth changing. It is
really counting clock cycles, not bits.