]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (ads7871) Replace sprintf() with sysfs_emit()
authorTabrez Ahmed <tabreztalks@gmail.com>
Sat, 7 Mar 2026 08:38:15 +0000 (14:08 +0530)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 31 Mar 2026 02:45:06 +0000 (19:45 -0700)
Use sysfs_emit() instead of sprintf() in the sysfs show function
voltage_show() to comply with the preferred kernel interface for
writing to sysfs buffers, which ensures PAGE_SIZE buffer limits
are respected.

No functional change intended.

Note: Not runtime tested due to lack of hardware.

Signed-off-by: Tabrez Ahmed <tabreztalks@gmail.com>
Link: https://lore.kernel.org/r/20260307083815.12095-1-tabreztalks@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ads7871.c

index 5434c37969d755f5f59e31e3cc2c815dd84e34ef..b84426c940c5e53b625c8cdb0626d8ede8656ae7 100644 (file)
@@ -124,7 +124,7 @@ static ssize_t voltage_show(struct device *dev, struct device_attribute *da,
                val = ads7871_read_reg16(spi, REG_LS_BYTE);
                /*result in volts*10000 = (val/8192)*2.5*10000*/
                val = ((val >> 2) * 25000) / 8192;
-               return sprintf(buf, "%d\n", val);
+               return sysfs_emit(buf, "%d\n", val);
        } else {
                return -1;
        }