Skip to contentSkip to conversation

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

PATCH Superseded Donggeun Yoo 2 participants 3 messages Aug 30 IIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 drivers/iio/light/vcnl4000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/vcnl4000.c +1 -1
index 336468d59ea7..dac235dd6220 100644
@@ -1504,7 +1504,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
#1 lore raw
Quoted 14 lines · On Sun, 30 Aug 2026 14:42:36 +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.

---
 drivers/iio/light/vcnl4000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/vcnl4000.c +0 -0
index 336468d59ea7..dac235dd6220 100644

drivers/iio/light/vcnl4000.c static ssize_t vcnl4000_read_near_level(struct iio_dev *indio_dev, · line 1507

Quoted 5 lines
drivers/iio/light/vcnl4000.c +1 -1
@@ -1504,7 +1504,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);

You should also include <linux/sysfs.h>.

Signature · 2 lines
Kind regards,
Joshua Crofts
#2 lore raw
Quoted 1 line

You should also include <linux/sysfs.h>.

Thanks, added in v2.

Quoted 29 lines · Joshua Crofts
Quoted 14 lines · On Sun, 30 Aug 2026 14:42:36 +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.

---
 drivers/iio/light/vcnl4000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/vcnl4000.c +0 -0
index 336468d59ea7..dac235dd6220 100644

drivers/iio/light/vcnl4000.c static ssize_t vcnl4000_read_near_level(struct iio_dev *indio_dev, · line 1507

Quoted 5 lines
drivers/iio/light/vcnl4000.c +1 -1
@@ -1504,7 +1504,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);

You should also include <linux/sysfs.h>.

--
Kind regards,
Joshua Crofts