public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] sh: push-switch: use sysfs_emit() in switch_show
@ 2026-04-24 12:10 Thorsten Blum
  2026-04-24 12:10 ` [PATCH 2/2] sh: sq: use sysfs_emit_at() in mapping_show Thorsten Blum
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-04-24 12:10 UTC (permalink / raw)
  To: Rich Felker, John Paul Adrian Glaubitz
  Cc: linux-sh, linux-kernel, Thorsten Blum

Replace sprintf() with sysfs_emit() in switch_show(). sysfs_emit() is
preferred for formatting sysfs output because it provides safer bounds
checking.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/sh/drivers/push-switch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/sh/drivers/push-switch.c b/arch/sh/drivers/push-switch.c
index a39e2edd4dcb..9a60e2e088a8 100644
--- a/arch/sh/drivers/push-switch.c
+++ b/arch/sh/drivers/push-switch.c
@@ -9,6 +9,7 @@
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/sysfs.h>
 #include <asm/push-switch.h>
 
 #define DRV_NAME "push-switch"
@@ -19,7 +20,7 @@ static ssize_t switch_show(struct device *dev,
 			   char *buf)
 {
 	struct push_switch_platform_info *psw_info = dev->platform_data;
-	return sprintf(buf, "%s\n", psw_info->name);
+	return sysfs_emit(buf, "%s\n", psw_info->name);
 }
 static DEVICE_ATTR_RO(switch);
 

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

end of thread, other threads:[~2026-04-24 12:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 12:10 [PATCH 1/2] sh: push-switch: use sysfs_emit() in switch_show Thorsten Blum
2026-04-24 12:10 ` [PATCH 2/2] sh: sq: use sysfs_emit_at() in mapping_show Thorsten Blum

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