[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20211022090248.1065217-1-ye.guojin@zte.com.cn>
Date: Fri, 22 Oct 2021 09:02:48 +0000
From: cgel.zte@...il.com
To: joe@...ches.com
Cc: alistair@...ple.id.au, cgel.zte@...il.com, eajames@...ux.ibm.com,
jk@...abs.org, joel@....id.au, linux-fsi@...ts.ozlabs.org,
linux-kernel@...r.kernel.org, ye.guojin@....com.cn,
zealci@....com.cn
Subject: [PATCH v2] fsi: master: replace snprintf in show functions with sysfs_emit
From: Ye Guojin <ye.guojin@....com.cn>
coccicheck complains about the use of snprintf() in sysfs show
functions:
WARNING use scnprintf or sprintf
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
Reported-by: Zeal Robot <zealci@....com.cn>
Signed-off-by: Ye Guojin <ye.guojin@....com.cn>
---
Changes since v1:
- remove unnecessary ?: since external_mode is already bool.
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 24292acdbaf8..7f3303854e23 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);
}
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 7d5f29b4b595..b8538a851675 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);
}
static ssize_t external_mode_store(struct device *dev,
--
2.25.1
Powered by blists - more mailing lists