diff mbox series

[v2] fsi: master: replace snprintf in show functions with sysfs_emit

Message ID 20211022090248.1065217-1-ye.guojin@zte.com.cn
State New
Headers show
Series [v2] fsi: master: replace snprintf in show functions with sysfs_emit | expand

Commit Message

CGEL Oct. 22, 2021, 9:02 a.m. UTC
From: Ye Guojin <ye.guojin@zte.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@zte.com.cn>
Signed-off-by: Ye Guojin <ye.guojin@zte.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 mbox series

Patch

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,