]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (max31722) Replace sprintf() with sysfs_emit()
authorAmay Agarwal <tt@turingtested.xyz>
Tue, 3 Mar 2026 15:24:53 +0000 (20:54 +0530)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 31 Mar 2026 02:45:05 +0000 (19:45 -0700)
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>
Link: https://lore.kernel.org/r/20260303152456.35763-3-tt@turingtested.xyz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/max31722.c

index 9a31ef3883969d8bd38b337951ac602181bc80bd..6c5c86c75c36e926607addf741243154d59c16e0 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/spi/spi.h>
+#include <linux/sysfs.h>
 
 #define MAX31722_REG_CFG                               0x00
 #define MAX31722_REG_TEMP_LSB                          0x01
@@ -56,7 +57,7 @@ static ssize_t max31722_temp_show(struct device *dev,
        if (ret < 0)
                return ret;
        /* Keep 12 bits and multiply by the scale of 62.5 millidegrees/bit. */
-       return sprintf(buf, "%d\n", (s16)le16_to_cpu(ret) * 125 / 32);
+       return sysfs_emit(buf, "%d\n", (s16)le16_to_cpu(ret) * 125 / 32);
 }
 
 static SENSOR_DEVICE_ATTR_RO(temp1_input, max31722_temp, 0);