* [PATCH] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at()
@ 2026-07-13 17:08 OrangeBlack0765
2026-07-14 6:52 ` Joshua Crofts
2026-07-14 8:53 ` Andy Shevchenko
0 siblings, 2 replies; 7+ messages in thread
From: OrangeBlack0765 @ 2026-07-13 17:08 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel, Chengrui Liu
From: Chengrui Liu <OrangeBlack0765@outlook.com>
Replace sprintf() with sysfs_emit() for single-value sysfs show
functions, and use sysfs_emit_at() for lux_table_show() which
concatenates multiple values. This ensures buffer safety and
follows the modern kernel sysfs API.
Signed-off-by: Chengrui Liu <OrangeBlack0765@outlook.com>
---
drivers/iio/light/tsl2583.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/light/tsl2583.c b/drivers/iio/light/tsl2583.c
index a0dd122af..9ec2747e5 100644
--- a/drivers/iio/light/tsl2583.c
+++ b/drivers/iio/light/tsl2583.c
@@ -475,7 +475,7 @@ static ssize_t in_illuminance_input_target_show(struct device *dev,
int ret;
mutex_lock(&chip->als_mutex);
- ret = sprintf(buf, "%d\n", chip->als_settings.als_cal_target);
+ ret = sysfs_emit(buf, "%d\n", chip->als_settings.als_cal_target);
mutex_unlock(&chip->als_mutex);
return ret;
@@ -533,7 +533,7 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev,
int offset = 0;
for (i = 0; i < ARRAY_SIZE(chip->als_settings.als_device_lux); i++) {
- offset += sprintf(buf + offset, "%u,%u,%u,",
+ offset += sysfs_emit_at(buf, offset, "%u,%u,%u,",
chip->als_settings.als_device_lux[i].ratio,
chip->als_settings.als_device_lux[i].ch0,
chip->als_settings.als_device_lux[i].ch1);
@@ -547,7 +547,7 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev,
}
}
- offset += sprintf(buf + offset, "\n");
+ offset += sysfs_emit_at(buf, offset, "\n");
return offset;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at()
2026-07-13 17:08 [PATCH] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at() OrangeBlack0765
@ 2026-07-14 6:52 ` Joshua Crofts
2026-07-14 8:53 ` Andy Shevchenko
1 sibling, 0 replies; 7+ messages in thread
From: Joshua Crofts @ 2026-07-14 6:52 UTC (permalink / raw)
To: OrangeBlack0765
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux-iio, linux-kernel
On Tue, 14 Jul 2026 01:08:33 +0800
OrangeBlack0765@outlook.com wrote:
> From: Chengrui Liu <OrangeBlack0765@outlook.com>
>
> Replace sprintf() with sysfs_emit() for single-value sysfs show
> functions, and use sysfs_emit_at() for lux_table_show() which
> concatenates multiple values. This ensures buffer safety and
> follows the modern kernel sysfs API.
>
> Signed-off-by: Chengrui Liu <OrangeBlack0765@outlook.com>
> ---
LGTM.
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
--
Kind regards
CJD
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at()
2026-07-13 17:08 [PATCH] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at() OrangeBlack0765
2026-07-14 6:52 ` Joshua Crofts
@ 2026-07-14 8:53 ` Andy Shevchenko
2026-07-14 9:00 ` Joshua Crofts
` (2 more replies)
1 sibling, 3 replies; 7+ messages in thread
From: Andy Shevchenko @ 2026-07-14 8:53 UTC (permalink / raw)
To: OrangeBlack0765
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux-iio, linux-kernel
On Tue, Jul 14, 2026 at 01:08:33AM +0800, OrangeBlack0765@outlook.com wrote:
> Replace sprintf() with sysfs_emit() for single-value sysfs show
> functions, and use sysfs_emit_at() for lux_table_show() which
> concatenates multiple values. This ensures buffer safety and
> follows the modern kernel sysfs API.
...
> for (i = 0; i < ARRAY_SIZE(chip->als_settings.als_device_lux); i++) {
> - offset += sprintf(buf + offset, "%u,%u,%u,",
> + offset += sysfs_emit_at(buf, offset, "%u,%u,%u,",
> chip->als_settings.als_device_lux[i].ratio,
> chip->als_settings.als_device_lux[i].ch0,
> chip->als_settings.als_device_lux[i].ch1);
Now the indentation becomes broken.
> }
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at()
2026-07-14 8:53 ` Andy Shevchenko
@ 2026-07-14 9:00 ` Joshua Crofts
2026-07-14 13:32 ` [PATCH] iio: light: tsl2583: migrate to sysfs_emit() OrangeBlack0765
2026-07-14 13:39 ` [PATCH v2] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at() OrangeBlack0765
2 siblings, 0 replies; 7+ messages in thread
From: Joshua Crofts @ 2026-07-14 9:00 UTC (permalink / raw)
To: Andy Shevchenko
Cc: OrangeBlack0765, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
On Tue, 14 Jul 2026 11:53:42 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > for (i = 0; i < ARRAY_SIZE(chip->als_settings.als_device_lux); i++) {
> > - offset += sprintf(buf + offset, "%u,%u,%u,",
> > + offset += sysfs_emit_at(buf, offset, "%u,%u,%u,",
> > chip->als_settings.als_device_lux[i].ratio,
> > chip->als_settings.als_device_lux[i].ch0,
> > chip->als_settings.als_device_lux[i].ch1);
>
> Now the indentation becomes broken.
I seem to be blind when reviewing.
--
Kind regards
CJD
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] iio: light: tsl2583: migrate to sysfs_emit()
2026-07-14 8:53 ` Andy Shevchenko
2026-07-14 9:00 ` Joshua Crofts
@ 2026-07-14 13:32 ` OrangeBlack0765
2026-07-14 13:39 ` [PATCH v2] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at() OrangeBlack0765
2 siblings, 0 replies; 7+ messages in thread
From: OrangeBlack0765 @ 2026-07-14 13:32 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Andy Shevchenko, linux-iio, linux-kernel, OrangeBlack0765
From: OrangeBlack0765 <OrangeBlack0765@outlook.com>
On Tue, Jul 14, 2026 at 11:53:42AM +0300, Andy Shevchenko wrote:
> > for (i = 0; i < ARRAY_SIZE(chip->als_settings.als_device_lux); i++) {
> > - offset += sprintf(buf + offset, "%u,%u,%u,",
> > + offset += sysfs_emit_at(buf, offset, "%u,%u,%u,",
> > chip->als_settings.als_device_lux[i].ratio,
> > chip->als_settings.als_device_lux[i].ch0,
> > chip->als_settings.als_device_lux[i].ch1);
>
> Now the indentation becomes broken.
Thanks for catching this. I will fix the indentation and send v2 shortly.
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at()
2026-07-14 8:53 ` Andy Shevchenko
2026-07-14 9:00 ` Joshua Crofts
2026-07-14 13:32 ` [PATCH] iio: light: tsl2583: migrate to sysfs_emit() OrangeBlack0765
@ 2026-07-14 13:39 ` OrangeBlack0765
2026-07-14 13:56 ` Andy Shevchenko
2 siblings, 1 reply; 7+ messages in thread
From: OrangeBlack0765 @ 2026-07-14 13:39 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: Andy Shevchenko, linux-iio, linux-kernel, Chengrui Liu
From: Chengrui Liu <OrangeBlack0765@outlook.com>
Replace sprintf() with sysfs_emit() for single-value sysfs show
functions, and use sysfs_emit_at() for lux_table_show() which
concatenates multiple values. This ensures buffer safety and
follows the modern kernel sysfs API.
Changes in v2:
- Fix indentation for multi-line function arguments (align with first param)
Signed-off-by: Chengrui Liu <OrangeBlack0765@outlook.com>
---
drivers/iio/light/tsl2583.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/light/tsl2583.c b/drivers/iio/light/tsl2583.c
index a0dd122af..db0dc2c3e 100644
--- a/drivers/iio/light/tsl2583.c
+++ b/drivers/iio/light/tsl2583.c
@@ -475,7 +475,7 @@ static ssize_t in_illuminance_input_target_show(struct device *dev,
int ret;
mutex_lock(&chip->als_mutex);
- ret = sprintf(buf, "%d\n", chip->als_settings.als_cal_target);
+ ret = sysfs_emit(buf, "%d\n", chip->als_settings.als_cal_target);
mutex_unlock(&chip->als_mutex);
return ret;
@@ -533,10 +533,10 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev,
int offset = 0;
for (i = 0; i < ARRAY_SIZE(chip->als_settings.als_device_lux); i++) {
- offset += sprintf(buf + offset, "%u,%u,%u,",
- chip->als_settings.als_device_lux[i].ratio,
- chip->als_settings.als_device_lux[i].ch0,
- chip->als_settings.als_device_lux[i].ch1);
+ offset += sysfs_emit_at(buf, offset, "%u,%u,%u,",
+ chip->als_settings.als_device_lux[i].ratio,
+ chip->als_settings.als_device_lux[i].ch0,
+ chip->als_settings.als_device_lux[i].ch1);
if (chip->als_settings.als_device_lux[i].ratio == 0) {
/*
* We just printed the first "0" entry.
@@ -547,7 +547,7 @@ static ssize_t in_illuminance_lux_table_show(struct device *dev,
}
}
- offset += sprintf(buf + offset, "\n");
+ offset += sysfs_emit_at(buf, offset, "\n");
return offset;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v2] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at()
2026-07-14 13:39 ` [PATCH v2] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at() OrangeBlack0765
@ 2026-07-14 13:56 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2026-07-14 13:56 UTC (permalink / raw)
To: OrangeBlack0765; +Cc: Jonathan Cameron, linux-iio, linux-kernel
On Tue, Jul 14, 2026 at 09:39:00PM +0800, OrangeBlack0765@outlook.com wrote:
First of all, do not reply with a new version into the thread from
the previous one.
> Replace sprintf() with sysfs_emit() for single-value sysfs show
> functions, and use sysfs_emit_at() for lux_table_show() which
> concatenates multiple values. This ensures buffer safety and
> follows the modern kernel sysfs API.
> Changes in v2:
> - Fix indentation for multi-line function arguments (align with first param)
Next, the changelog should be in the comments block...
> Signed-off-by: Chengrui Liu <OrangeBlack0765@outlook.com>
> ---
...somewhere here (mind the cutter '---' line).
> drivers/iio/light/tsl2583.c | 12 ++++++------
...
> + offset += sysfs_emit_at(buf, offset, "%u,%u,%u,",
> + chip->als_settings.als_device_lux[i].ratio,
> + chip->als_settings.als_device_lux[i].ch0,
> + chip->als_settings.als_device_lux[i].ch1);
And last, but not least. Indentation is still broken. Now it's mix tabs
and spaces (in a wrong order).
...
Do not hurry up with v3, wait at least 24+h.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-07-14 13:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13 17:08 [PATCH] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at() OrangeBlack0765
2026-07-14 6:52 ` Joshua Crofts
2026-07-14 8:53 ` Andy Shevchenko
2026-07-14 9:00 ` Joshua Crofts
2026-07-14 13:32 ` [PATCH] iio: light: tsl2583: migrate to sysfs_emit() OrangeBlack0765
2026-07-14 13:39 ` [PATCH v2] iio: light: tsl2583: migrate to sysfs_emit() and sysfs_emit_at() OrangeBlack0765
2026-07-14 13:56 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.