Re: [PATCH v5] iio: proximity: srf08: Replace sprintf() with sysfs_emit()

From: Jonathan Cameron

Date: Fri Apr 24 2026 - 13:53:50 EST


On Wed, 22 Apr 2026 15:53:55 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:

> On Wed, Apr 22, 2026 at 07:45:05AM -0500, Maxwell Doose wrote:
> > Replace sprintf() function calls with sysfs_emit() and
> > sysfs_emit_at(). While the current code is fine, sysfs_emit() is
> > preferred over sprintf(), and will help modernize the driver.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
>
> ...
>
> > v5:
> > - Reversed decision to put sysfs_emit() call on one line per Jonathan
> > Cameron's request.
>
> Oh, I missed that. In any case I consider my suggestion is still better,
> it keeps driver in limits and makes the wrap on logical boundary.
I'm a bit lost on which of us is asking for what and can't figure it out
from the patch history. Anyhow, I did make one tweak whilst applying -
I think some confusion occurred as I don't think we'd disagree on this one
and you called it out in an earlier review.

diff --git a/drivers/iio/proximity/srf08.c b/drivers/iio/proximity/srf08.c
index 2ec8d0732763..92a37ba331f6 100644
--- a/drivers/iio/proximity/srf08.c
+++ b/drivers/iio/proximity/srf08.c
@@ -317,7 +317,7 @@ static ssize_t srf08_show_sensitivity_available(struct device *dev,
for (i = 0; i < data->chip_info->num_sensitivity_avail; i++)
if (data->chip_info->sensitivity_avail[i])
len += sysfs_emit_at(buf, len, "%d ",
- data->chip_info->sensitivity_avail[i]);
+ data->chip_info->sensitivity_avail[i]);

len += sysfs_emit_at(buf, len, "\n");

It's only just over 80 chars and flipping to
if (!data->chip_info->sensitivity_avail[i])
continue;
len += sysfs_emit_at(..

doesn't seem worth the effort.

With that applied to the testing branch of iio.git.

Thanks,

Jonathan

>
> > - Fixed some of my editor's tab-spacing issues
>