[PATCH 08/42] drivers/fsi: Convert snprintf to sysfs_emit
Li Zhijian
lizhijian at fujitsu.com
Tue Jan 16 15:52:42 AEDT 2024
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/fsi/fsi-master-ast-cf.c:1086:8-16: WARNING: please use sysfs_emit
> ./drivers/fsi/fsi-master-gpio.c:721:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Jeremy Kerr <jk at ozlabs.org>
CC: Joel Stanley <joel at jms.id.au>
CC: Alistar Popple <alistair at popple.id.au>
CC: Eddie James <eajames at linux.ibm.com>
CC: linux-fsi at lists.ozlabs.org
Signed-off-by: Li Zhijian <lizhijian at fujitsu.com>
---
drivers/fsi/fsi-master-ast-cf.c | 3 +--
drivers/fsi/fsi-master-gpio.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c
index 812dfa9a9140..5740b2d9dace 100644
--- a/drivers/fsi/fsi-master-ast-cf.c
+++ b/drivers/fsi/fsi-master-ast-cf.c
@@ -1083,8 +1083,7 @@ static ssize_t external_mode_show(struct device *dev,
{
struct fsi_master_acf *master = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE - 1, "%u\n",
- master->external_mode ? 1 : 0);
+ return sysfs_emit(buf, "%u\n", master->external_mode ? 1 : 0);
}
static ssize_t external_mode_store(struct device *dev,
diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index ed03da4f2447..286fe1cddf99 100644
--- a/drivers/fsi/fsi-master-gpio.c
+++ b/drivers/fsi/fsi-master-gpio.c
@@ -718,8 +718,7 @@ static ssize_t external_mode_show(struct device *dev,
{
struct fsi_master_gpio *master = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE - 1, "%u\n",
- master->external_mode ? 1 : 0);
+ return sysfs_emit(buf, "%u\n", master->external_mode ? 1 : 0);
}
static ssize_t external_mode_store(struct device *dev,
--
2.29.2
More information about the linux-fsi
mailing list