[PATCH 1/2] sh: push-switch: use sysfs_emit() in switch_show

From: Thorsten Blum

Date: Fri Apr 24 2026 - 08:11:10 EST


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@xxxxxxxxx>
---
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);