lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250713151309.30fa9a95@jic23-huawei>
Date: Sun, 13 Jul 2025 15:13:09 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: David Lechner <dlechner@...libre.com>
Cc: Nuno Sá <nuno.sa@...log.com>, Andy Shevchenko
 <andy@...nel.org>, linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: accel: bma180: use stack allocated buffer for scan

On Thu, 10 Jul 2025 18:00:05 -0500
David Lechner <dlechner@...libre.com> wrote:

> Use IIO_DECLARE_BUFFER_WITH_TS() to declare a stack allocated buffer
> in bma180_trigger_handler(). Since the scan buffer isn't used outside
> of this function, it doesn't need to be in struct bma180_data.
> 
> Signed-off-by: David Lechner <dlechner@...libre.com>
As with the other similar cases I'm a fan of structures whenever
we can because the let people see the memory layout in the code.

Jonathan

> ---
>  drivers/iio/accel/bma180.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
> index 4fccbcb76e0423bee37463a72c637af80e356a19..d83d5becca6fc72b855310a31c3de5443e4e2311 100644
> --- a/drivers/iio/accel/bma180.c
> +++ b/drivers/iio/accel/bma180.c
> @@ -139,11 +139,6 @@ struct bma180_data {
>  	int scale;
>  	int bw;
>  	bool pmode;
> -	/* Ensure timestamp is naturally aligned */
> -	struct {
> -		s16 chan[4];
> -		aligned_s64 timestamp;
> -	} scan;
>  };
>  
>  enum bma180_chan {
> @@ -865,6 +860,7 @@ static const struct bma180_part_info bma180_part_info[] = {
>  
>  static irqreturn_t bma180_trigger_handler(int irq, void *p)
>  {
> +	IIO_DECLARE_BUFFER_WITH_TS(s16, scan, 4);
>  	struct iio_poll_func *pf = p;
>  	struct iio_dev *indio_dev = pf->indio_dev;
>  	struct bma180_data *data = iio_priv(indio_dev);
> @@ -879,12 +875,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
>  			mutex_unlock(&data->mutex);
>  			goto err;
>  		}
> -		data->scan.chan[i++] = ret;
> +		scan[i++] = ret;
>  	}
>  
>  	mutex_unlock(&data->mutex);
>  
> -	iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), time_ns);
> +	iio_push_to_buffers_with_ts(indio_dev, scan, sizeof(scan), time_ns);
>  err:
>  	iio_trigger_notify_done(indio_dev->trig);
>  
> 
> ---
> base-commit: f8f559752d573a051a984adda8d2d1464f92f954
> change-id: 20250710-iio-use-more-iio_declare_buffer_with_ts-0924382d38c6
> 
> Best regards,


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ