public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] counter: replace snprintf in show functions with sysfs_emit
@ 2021-10-13  3:26 Qing Wang
  2021-10-14  6:38 ` William Breathitt Gray
  0 siblings, 1 reply; 2+ messages in thread
From: Qing Wang @ 2021-10-13  3:26 UTC (permalink / raw)
  To: Fabrice Gasnier, William Breathitt Gray, Maxime Coquelin,
	Alexandre Torgue, linux-iio, linux-stm32, linux-arm-kernel,
	linux-kernel
  Cc: Qing Wang

coccicheck complains about the use of snprintf() in sysfs show functions.

Fix the following coccicheck warning:
drivers/counter/stm32-lptimer-cnt.c:265:8-16: WARNING: use scnprintf or sprintf.
drivers/counter/stm32-lptimer-cnt.c:176:8-16: WARNING: use scnprintf or sprintf.

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

Signed-off-by: Qing Wang <wangqing@vivo.com>
---
 drivers/counter/stm32-lptimer-cnt.c | 2 +-
 drivers/counter/stm32-timer-cnt.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c
index c19d998..6f1113a 100644
--- a/drivers/counter/stm32-lptimer-cnt.c
+++ b/drivers/counter/stm32-lptimer-cnt.c
@@ -262,7 +262,7 @@ static ssize_t stm32_lptim_cnt_ceiling_read(struct counter_device *counter,
 {
 	struct stm32_lptim_cnt *const priv = counter->priv;
 
-	return snprintf(buf, PAGE_SIZE, "%u\n", priv->ceiling);
+	return sysfs_emit(buf, "%u\n", priv->ceiling);
 }
 
 static ssize_t stm32_lptim_cnt_ceiling_write(struct counter_device *counter,
diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c
index 603b30a..e772586 100644
--- a/drivers/counter/stm32-timer-cnt.c
+++ b/drivers/counter/stm32-timer-cnt.c
@@ -173,7 +173,7 @@ static ssize_t stm32_count_ceiling_read(struct counter_device *counter,
 
 	regmap_read(priv->regmap, TIM_ARR, &arr);
 
-	return snprintf(buf, PAGE_SIZE, "%u\n", arr);
+	return sysfs_emit(buf, "%u\n", arr);
 }
 
 static ssize_t stm32_count_ceiling_write(struct counter_device *counter,
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-14  6:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-13  3:26 [PATCH] counter: replace snprintf in show functions with sysfs_emit Qing Wang
2021-10-14  6:38 ` William Breathitt Gray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox