[PATCH v2 4/5] hwmon: (max6650) Replace sprintf() with sysfs_emit()

Amay Agarwal posted 5 patches 1 month ago
[PATCH v2 4/5] hwmon: (max6650) Replace sprintf() with sysfs_emit()
Posted by Amay Agarwal 1 month ago
Replace sprintf() with sysfs_emit() when writing to sysfs buffers.

sysfs_emit() performs proper bounds checking and is the preferred
helper for sysfs output.

No functional change intended.

Signed-off-by: Amay Agarwal <tt@turingtested.xyz>
---
 drivers/hwmon/max6650.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
index 9649c6611d5f..56b8157885bb 100644
--- a/drivers/hwmon/max6650.c
+++ b/drivers/hwmon/max6650.c
@@ -27,6 +27,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/err.h>
 #include <linux/of.h>
+#include <linux/sysfs.h>
 #include <linux/thermal.h>
 
 /*
@@ -312,7 +313,7 @@ static ssize_t alarm_show(struct device *dev,
 		mutex_unlock(&data->update_lock);
 	}
 
-	return sprintf(buf, "%d\n", alarm);
+	return sysfs_emit(buf, "%d\n", alarm);
 }
 
 static SENSOR_DEVICE_ATTR_RO(gpio1_alarm, alarm, MAX6650_ALRM_GPIO1);
-- 
2.53.0
Re: [PATCH v2 4/5] hwmon: (max6650) Replace sprintf() with sysfs_emit()
Posted by Guenter Roeck 1 month ago
On Tue, Mar 03, 2026 at 08:54:55PM +0530, Amay Agarwal wrote:
> Replace sprintf() with sysfs_emit() when writing to sysfs buffers.
> 
> sysfs_emit() performs proper bounds checking and is the preferred
> helper for sysfs output.
> 
> No functional change intended.
> 
> Signed-off-by: Amay Agarwal <tt@turingtested.xyz>

Applied.

Thanks,
Guenter