Re: [PATCH] iio: cros_ec: use sysfs_emit() in show callbacks

From: David Laight

Date: Thu Nov 12 2026 - 18:43:41 EST


On Thu, 12 Nov 2026 02:04:39 +0000
Jonathan Cameron <jic23@xxxxxxxxxx> wrote:

> On Wed, 11 Nov 2026 16:39:37 +0200
> Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
>
> > On Wed, Nov 11, 2026 at 07:26:08AM +0000, Di Wu wrote:
> > > Replace sprintf() and snprintf() with sysfs_emit() in the sysfs show
> > > and ext_info read callbacks. sysfs_emit() is aware of the sysfs buffer
> > > PAGE_SIZE limit and is the preferred helper for show callbacks.
> >
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
> >
> > ...
> >
> > > - return sprintf(buf, "%d.%06u\n",
> > > - latency / 1000,
> > > - (latency % 1000) * 1000);
> > > + return sysfs_emit(buf, "%d.%06u\n",
> > > + latency / 1000,
> > > + (latency % 1000) * 1000);
> >
> > As David said, since you touched these lines, make the less amount of them
> > while at it.
> >
> > (But no need to resend, usually Jonathan is kind to tweak this small thing.)
> >
> Done and applied.
>
>

I just looked at that line again.
Why is it multiplying the remainder by 1000?
It could be:
return sysfs_emit(buf, "%d.%03u000\n", latency / 1000, latency % 1000);
if the 6 digits after the decimal point are required.

David