linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Joe Perches <joe@perches.com>,
	linux-iio@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 2/4] iio: iio_enum_available_read(): Convert to sysfs_emit_at()
Date: Sat, 20 Mar 2021 08:14:03 +0100	[thread overview]
Message-ID: <20210320071405.9347-3-lars@metafoo.de> (raw)
In-Reply-To: <20210320071405.9347-1-lars@metafoo.de>

sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in sanity checks.

Convert the iio_enum_available_read() function to use sysfs_emit_at()
instead of scnprintf().

The conversion is straight forward, the only difference is that
sysfs_emit_at() takes the buffers start address and an offset as parameters
and already knows about the buffer's size limit.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/industrialio-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 058874af1242..e0fdf9141e09 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -504,7 +504,7 @@ ssize_t iio_enum_available_read(struct iio_dev *indio_dev,
 	for (i = 0; i < e->num_items; ++i) {
 		if (!e->items[i])
 			continue;
-		len += scnprintf(buf + len, PAGE_SIZE - len, "%s ", e->items[i]);
+		len += sysfs_emit_at(buf, len, "%s ", e->items[i]);
 	}
 
 	/* replace last space with a newline */
-- 
2.20.1


  parent reply	other threads:[~2021-03-20 11:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-20  7:14 [PATCH 0/4] iio: Start conversion to sysfs_emit() Lars-Peter Clausen
2021-03-20  7:14 ` [PATCH 1/4] iio: core: Use sysfs_emit() (trivial bits) Lars-Peter Clausen
2021-03-20  7:14 ` Lars-Peter Clausen [this message]
2021-03-20  7:14 ` [PATCH 3/4] iio: __iio_format_value(): Convert to sysfs_emit_at() Lars-Peter Clausen
2021-03-20  7:14 ` [PATCH 4/4] iio: dac: Convert powerdown read callbacks to sysfs_emit() Lars-Peter Clausen
2021-03-20 11:01   ` Joe Perches
2021-03-20 12:52     ` Lars-Peter Clausen
2021-03-20 15:13       ` Joe Perches
2021-03-29 10:13         ` Jonathan Cameron
2021-03-29 11:21       ` Andy Shevchenko
2021-03-29 11:22         ` Andy Shevchenko
2021-03-29 11:27   ` Andy Shevchenko
2021-03-20 18:34 ` [PATCH 0/4] iio: Start conversion " Jonathan Cameron

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=20210320071405.9347-3-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=jic23@kernel.org \
    --cc=joe@perches.com \
    --cc=linux-iio@vger.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;
as well as URLs for NNTP newsgroup(s).