Re: [PATCH v3] iio: proximity: srf08: replace sprintf() with sysfs_emit()
From: Andy Shevchenko
Date: Wed Apr 22 2026 - 03:00:49 EST
On Mon, Apr 20, 2026 at 06:08:13PM -0500, Maxwell Doose wrote:
> This patch replaces 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.
...
> static ssize_t srf08_show_range_mm(struct device *dev,
> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> struct srf08_data *data = iio_priv(indio_dev);
>
> - return sprintf(buf, "%d.%03d\n", data->range_mm / 1000,
> - data->range_mm % 1000);
> + return sysfs_emit(buf, "%d.%03d\n",
> + data->range_mm / 1000, data->range_mm % 1000);
Wrong indentation.
> }
...
> for (i = 0; i < data->chip_info->num_sensitivity_avail; i++)
> if (data->chip_info->sensitivity_avail[i])
> - len += sprintf(buf + len, "%d ",
> + len += sysfs_emit_at(buf, len, "%d ",
> data->chip_info->sensitivity_avail[i]);
Ditto.
...
The rest is okay.
--
With Best Regards,
Andy Shevchenko