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>] [day] [month] [year] [list]
Message-ID: <202212071540249842544@zte.com.cn>
Date:   Wed, 7 Dec 2022 15:40:24 +0800 (CST)
From:   <ye.xingchen@....com.cn>
To:     <jic23@...nel.org>
Cc:     <lorenzo@...nel.org>, <andriy.shevchenko@...ux.intel.com>,
        <lars@...afoo.de>, <linux-iio@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
Subject: [PATCH] iio: imu: st_lsm6dsx: Convert to use sysfs_emit_at() API

From: ye xingchen <ye.xingchen@....com.cn>

Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@....com.cn>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 9 ++++-----
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 6 ++----
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 3f6060c64f32..ac89978a6da1 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -1993,9 +1993,9 @@ 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 ",
-				 odr_table->odr_avl[i].milli_hz / 1000,
-				 odr_table->odr_avl[i].milli_hz % 1000);
+		len += sysfs_emit_at(buf, len, "%d.%03d ",
+				     odr_table->odr_avl[i].milli_hz / 1000,
+				     odr_table->odr_avl[i].milli_hz % 1000);
 	buf[len - 1] = '\n';

 	return len;
@@ -2012,8 +2012,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 ",
-				 fs_table->fs_avl[i].gain);
+		len += sysfs_emit_at(buf, len, "0.%09u ", fs_table->fs_avl[i].gain);
 	buf[len - 1] = '\n';

 	return len;
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
index f2b64b4956a3..554b235f75a0 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
@@ -676,8 +676,7 @@ st_lsm6dsx_shub_sampling_freq_avail(struct device *dev,
 	for (i = 0; i < settings->odr_table.odr_len; i++) {
 		u32 val = settings->odr_table.odr_avl[i].milli_hz;

-		len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%03d ",
-				 val / 1000, val % 1000);
+		len += sysfs_emit_at(buf, len, "%d.%03d ", val / 1000, val % 1000);
 	}
 	buf[len - 1] = '\n';

@@ -694,8 +693,7 @@ static ssize_t st_lsm6dsx_shub_scale_avail(struct device *dev,

 	settings = sensor->ext_info.settings;
 	for (i = 0; i < settings->fs_table.fs_len; i++)
-		len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ",
-				 settings->fs_table.fs_avl[i].gain);
+		len += sysfs_emit_at(buf, len, "0.%06u ", settings->fs_table.fs_avl[i].gain);
 	buf[len - 1] = '\n';

 	return len;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ