diff mbox series

[2/4] iio: iio_enum_available_read(): Convert to sysfs_emit_at()

Message ID 20210320071405.9347-3-lars@metafoo.de (mailing list archive)
State New, archived
Headers show
Series iio: Start conversion to sysfs_emit() | expand

Commit Message

Lars-Peter Clausen March 20, 2021, 7:14 a.m. UTC
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 mbox series

Patch

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 */