Skip to contentSkip to conversation

iio: light: vcnl4000: use sysfs_emit() for near_level

PATCH Applied Donggeun Yoo 3 participants 3 messages Aug 30 – Sep 1 IIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iio: light: vcnl4000: use sysfs_emit() for near_level

Use sysfs_emit() instead of sprintf() for writing to the sysfs output buffer. sysfs_emit() is aware of the buffer's PAGE_SIZE limit and is the preferred helper for sysfs callbacks.

---
v1 -> v2: Add #include <linux/sysfs.h> for sysfs_emit() instead of relying on transitive includes. (Suggested by Joshua Crofts)

v1: https://lore.kernel.org/linux-iio/[email protected]/

 drivers/iio/light/vcnl4000.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/light/vcnl4000.c +2 -1
index 336468d59ea7..911f8d1c74d4 100644
@@ -26,6 +26,7 @@
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
+#include <linux/sysfs.h>
 #include <linux/units.h>
 
 #include <linux/iio/buffer.h>
@@ -1504,7 +1505,7 @@ static ssize_t vcnl4000_read_near_level(struct iio_dev *indio_dev,
 {
 	struct vcnl4000_data *data = iio_priv(indio_dev);
 
-	return sprintf(buf, "%u\n", data->near_level);
+	return sysfs_emit(buf, "%u\n", data->near_level);
 }
 
 static irqreturn_t vcnl4010_irq_thread(int irq, void *p)

base-commit: 350d1fb9204b13c5f95e511e98b8bcb47574d425

Signature · 1 line
2.53.0
maintainer Applied
#2 lore raw
Quoted 7 lines · On Mon, 31 Aug 2026 11:12:43 +0200 Joshua Crofts <[email protected]>…
Quoted 4 lines · On Mon, 31 Aug 2026 03:53:45 +0900 Donggeun Yoo <[email protected]>…

Use sysfs_emit() instead of sprintf() for writing to the sysfs output buffer. sysfs_emit() is aware of the buffer's PAGE_SIZE limit and is the preferred helper for sysfs callbacks.

Quoted 7 lines
Quoted 2 lines

---

Seems fine.

Applied. Forgot to say the other day (or update patchwork).

J