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] [thread-next>] [day] [month] [year] [list]
Message-ID: <f96b68a5-d750-45f0-8cdd-9761b5daca1d@baylibre.com>
Date: Wed, 2 Jul 2025 09:16:51 -0500
From: David Lechner <dlechner@...libre.com>
To: Akshay Bansod <akbansd@...il.com>, Lorenzo Bianconi <lorenzo@...nel.org>,
 Jonathan Cameron <jic23@...nel.org>, Nuno Sá
 <nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>
Cc: linux-kernel-mentees@...ts.linuxfoundation.org,
 linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: st_lsm6dsx: Replace scnprintf with sysfs_emit

On 7/2/25 8:58 AM, Akshay Bansod wrote:
> Update the sysfs interface for sampling frequency and scale attributes.
> Replace `scnprintf()` with `sysfs_emit_at()` which is PAGE_SIZE-aware
> and recommended for use in sysfs.
> 
> Signed-off-by: Akshay Bansod <akbansd@...il.com>
> ---
> 
> Testing:
> - Built the driver (`st_lsm6dsx_i2c`) as a module.
> - Tested using `i2c-stub` to mock the device.
> - Verified that reading sysfs attributes like `sampling_frequency_available`
>   works correctly and shows no change in functionality.

Nice to see it was actually tested. :-)

> 
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index c65ad4982..1cef10919 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2035,7 +2035,7 @@ st_lsm6dsx_sysfs_sampling_frequency_avail(struct device *dev,
>  
>  	odr_table = &sensor->hw->settings->odr_table[sensor->id];
>  	for (i = 0; i < odr_table->odr_len; i++)
> -		len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%03d ",
> +		len += sysfs_emit_at(buf, len, "%d.%03d ",
>  				 odr_table->odr_avl[i].milli_hz / 1000,
>  				 odr_table->odr_avl[i].milli_hz % 1000);

Let's keep checkpatch happy and change the indent of the wrapped lines to
line up with ( since the ( moved.

>  	buf[len - 1] = '\n';
> @@ -2054,7 +2054,7 @@ static ssize_t st_lsm6dsx_sysfs_scale_avail(struct device *dev,
>  
>  	fs_table = &hw->settings->fs_table[sensor->id];
>  	for (i = 0; i < fs_table->fs_len; i++)
> -		len += scnprintf(buf + len, PAGE_SIZE - len, "0.%09u ",
> +		len += sysfs_emit_at(buf, len, "0.%09u ",
>  				 fs_table->fs_avl[i].gain);

ditto

>  	buf[len - 1] = '\n';
>  


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ