Skip to contentSkip to conversation

hwmon: (ads7871) Replace sprintf() with sysfs_emit()

PATCH Applied Tabrez Ahmed 2 participants 2 messages Mar 7 – Mar 8 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (ads7871) Replace sprintf() with sysfs_emit()

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.

---
 drivers/hwmon/ads7871.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/ads7871.c +1 -1
index 5434c37969d75..b84426c940c5e 100644
@@ -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;
 	}
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 10 lines · Tabrez Ahmed

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.

Applied.

Thanks,
Guenter