[PATCH] amba: Replace sprintf with sysfs_emit in driver_override_show

Wang Jiayue posted 1 patch 2 weeks ago
drivers/amba/bus.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] amba: Replace sprintf with sysfs_emit in driver_override_show
Posted by Wang Jiayue 2 weeks ago
Use sysfs_emit() instead of sprintf() when writing to sysfs buffers, as
recommended by the kernel documentation.

Signed-off-by: Wang Jiayue <wangjiayue150@gmail.com>
---
 drivers/amba/bus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 74e34a07ef72..6ae6a41e597b 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -89,7 +89,7 @@ static ssize_t driver_override_show(struct device *_dev,
 	ssize_t len;
 
 	device_lock(_dev);
-	len = sprintf(buf, "%s\n", dev->driver_override);
+	len = sysfs_emit(buf, "%s\n", dev->driver_override);
 	device_unlock(_dev);
 	return len;
 }
@@ -114,7 +114,7 @@ static ssize_t name##_show(struct device *_dev,				\
 			   struct device_attribute *attr, char *buf)	\
 {									\
 	struct amba_device *dev = to_amba_device(_dev);			\
-	return sprintf(buf, fmt, arg);					\
+	return sysfs_emit(buf, fmt, arg);					\
 }									\
 static DEVICE_ATTR_RO(name)
 
-- 
2.43.0
Re: [PATCH] amba: Replace sprintf with sysfs_emit in driver_override_show
Posted by Jiayue Wang 2 weeks ago
Sorry, I noticed there was an issue with the title prefix and content.
I've submitted the v2 version patch, please review it.

Thanks
Wang Jiayue