public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (ads7871) Replace sprintf() with sysfs_emit()
@ 2026-03-07  8:38 Tabrez Ahmed
  2026-03-08  1:23 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Tabrez Ahmed @ 2026-03-07  8:38 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-hwmon, linux-kernel, Shuah Khan, Brigham Campbell,
	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.

Signed-off-by: Tabrez Ahmed <tabreztalks@gmail.com>
---
 drivers/hwmon/ads7871.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c
index 5434c37969d75..b84426c940c5e 100644
--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -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;
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hwmon: (ads7871) Replace sprintf() with sysfs_emit()
  2026-03-07  8:38 [PATCH] hwmon: (ads7871) Replace sprintf() with sysfs_emit() Tabrez Ahmed
@ 2026-03-08  1:23 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2026-03-08  1:23 UTC (permalink / raw)
  To: Tabrez Ahmed; +Cc: linux-hwmon, linux-kernel, Shuah Khan, Brigham Campbell

On Sat, Mar 07, 2026 at 02:08:15PM +0530, Tabrez Ahmed wrote:
> 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>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-08  1:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-07  8:38 [PATCH] hwmon: (ads7871) Replace sprintf() with sysfs_emit() Tabrez Ahmed
2026-03-08  1:23 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox