Re: [PATCH v2 04/11] iio: adc: ad_sigma_delta: use BITS_TO_BYTES() macro

From: Jonathan Cameron
Date: Sat Jun 28 2025 - 10:57:01 EST


On Fri, 27 Jun 2025 18:40:00 -0500
David Lechner <dlechner@xxxxxxxxxxxx> 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 one 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).
>
> scan_type is factored out to reduce line wrapping.
>
> Signed-off-by: David Lechner <dlechner@xxxxxxxxxxxx>

>
> - samples_buf_size = ALIGN(slot * indio_dev->channels[0].scan_type.storagebits / 8, 8);
> + samples_buf_size = ALIGN(slot * BITS_TO_BYTES(scan_type->storagebits), 8);

Ah. You do it here. Fair enough and no problem wrt to patch 1 then.

> samples_buf_size += sizeof(s64);
> samples_buf = devm_krealloc(&sigma_delta->spi->dev, sigma_delta->samples_buf,
> samples_buf_size, GFP_KERNEL);