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

Amay Agarwal posted 5 patches 1 month ago
[PATCH v2 5/5] hwmon: (emc1403) 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/emc1403.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
index ccce948a4306..964a8cb278f1 100644
--- a/drivers/hwmon/emc1403.c
+++ b/drivers/hwmon/emc1403.c
@@ -40,7 +40,7 @@ static ssize_t power_state_show(struct device *dev, struct device_attribute *att
 	retval = regmap_read(data->regmap, 0x03, &val);
 	if (retval < 0)
 		return retval;
-	return sprintf(buf, "%d\n", !!(val & BIT(6)));
+	return sysfs_emit(buf, "%d\n", !!(val & BIT(6)));
 }
 
 static ssize_t power_state_store(struct device *dev, struct device_attribute *attr,
-- 
2.53.0
Re: [PATCH v2 5/5] hwmon: (emc1403) Replace sprintf() with sysfs_emit()
Posted by Guenter Roeck 1 month ago
On Tue, Mar 03, 2026 at 08:54:56PM +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