mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: cros_ec: use sysfs_emit() in show callbacks
@ 2026-11-11  7:26 Di Wu
  2026-11-11  8:36 ` Benson Leung
  2026-11-11 11:17 ` David Laight
  0 siblings, 2 replies; 3+ messages in thread
From: Di Wu @ 2026-11-11  7:26 UTC (permalink / raw)
  To: jic23
  Cc: dlechner, nuno.sa, andy, bleung, groeck, tzungbi, linux-iio,
	chrome-platform, linux-kernel, Di Wu

Replace sprintf() and snprintf() with sysfs_emit() in the sysfs show
and ext_info read callbacks. sysfs_emit() is aware of the sysfs buffer
PAGE_SIZE limit and is the preferred helper for show callbacks.

Signed-off-by: Di Wu <diwux@google.com>
---
 .../iio/common/cros_ec_sensors/cros_ec_sensors_core.c  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
index d03e40c91582..624d4b32b034 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
@@ -149,9 +149,9 @@ static ssize_t cros_ec_sensor_get_report_latency(struct device *dev,
 	if (ret < 0)
 		return ret;
 
-	return sprintf(buf, "%d.%06u\n",
-		       latency / 1000,
-		       (latency % 1000) * 1000);
+	return sysfs_emit(buf, "%d.%06u\n",
+			  latency / 1000,
+			  (latency % 1000) * 1000);
 }
 
 static IIO_DEVICE_ATTR(hwfifo_timeout, 0644,
@@ -165,7 +165,7 @@ static ssize_t hwfifo_watermark_max_show(struct device *dev,
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
 
-	return sprintf(buf, "%d\n", st->fifo_max_event_count);
+	return sysfs_emit(buf, "%d\n", st->fifo_max_event_count);
 }
 
 static IIO_DEVICE_ATTR_RO(hwfifo_watermark_max, 0);
@@ -465,7 +465,7 @@ static ssize_t cros_ec_sensors_id(struct iio_dev *indio_dev,
 {
 	struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", st->param.info.sensor_num);
+	return sysfs_emit(buf, "%d\n", st->param.info.sensor_num);
 }
 
 const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[] = {

base-commit: b70566610b48ba49dec636019da4d696db64b085
-- 
2.56.0.455.g6c5a503b38-goog


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

end of thread, other threads:[~2026-11-11 11:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11  7:26 [PATCH] iio: cros_ec: use sysfs_emit() in show callbacks Di Wu
2026-11-11  8:36 ` Benson Leung
2026-11-11 11:17 ` David Laight

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

all inboxes | Powered by JetHome®