From: Di Wu <diwux@google.com>
To: jic23@kernel.org
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
bleung@chromium.org, groeck@chromium.org, tzungbi@kernel.org,
linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev,
linux-kernel@vger.kernel.org, Di Wu <diwux@google.com>
Subject: [PATCH] iio: cros_ec: use sysfs_emit() in show callbacks
Date: Wed, 11 Nov 2026 07:26:08 +0000 [thread overview]
Message-ID: <20261111072608.3490763-1-diwux@google.com> (raw)
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
reply other threads:[~2026-11-11 7:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261111072608.3490763-1-diwux@google.com \
--to=diwux@google.com \
--cc=andy@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dlechner@baylibre.com \
--cc=groeck@chromium.org \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=tzungbi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®