[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250628155521.056b3394@jic23-huawei>
Date: Sat, 28 Jun 2025 15:55:21 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: David Lechner <dlechner@...libre.com>
Cc: Michael Hennerich <Michael.Hennerich@...log.com>, Nuno Sá
<nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>, Rob Herring
<robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, Mark Brown <broonie@...nel.org>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, linux-spi@...r.kernel.org
Subject: Re: [PATCH v2 01/11] iio: adc: ad_sigma_delta: don't overallocate
scan buffer
On Fri, 27 Jun 2025 18:39:57 -0500
David Lechner <dlechner@...libre.com> wrote:
> Fix overallocating the size of the scan buffer by converting bits to
> bytes. The size is meant to be in bytes, so scanbits needs to be
> divided by 8.
>
> Signed-off-by: David Lechner <dlechner@...libre.com>
> ---
> drivers/iio/adc/ad_sigma_delta.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
> index 4c5f8d29a559fea7226b84141bcb148fb801f62c..6b3ef7ef403e00804abeb81025ed293b188e492b 100644
> --- a/drivers/iio/adc/ad_sigma_delta.c
> +++ b/drivers/iio/adc/ad_sigma_delta.c
> @@ -489,7 +489,7 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev)
> return ret;
> }
>
> - samples_buf_size = ALIGN(slot * indio_dev->channels[0].scan_type.storagebits, 8);
> + samples_buf_size = ALIGN(slot * indio_dev->channels[0].scan_type.storagebits / 8, 8);
Seems like a good place for BITS_TO_BYTES() from bitops.h. Given we have another 8
kicking around in the same code line it might be a tiny bit confusing as / 8
If everything else is good I'll tweak this whilst applying (and add the include if needed).
> samples_buf_size += sizeof(int64_t);
> samples_buf = devm_krealloc(&sigma_delta->spi->dev, sigma_delta->samples_buf,
> samples_buf_size, GFP_KERNEL);
>
Powered by blists - more mailing lists