[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aID01DxC1Hf2PK0i@smile.fi.intel.com>
Date: Wed, 23 Jul 2025 17:42:28 +0300
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Akshay Bansod <akbansd@...il.com>
Cc: Lorenzo Bianconi <lorenzo@...nel.org>,
Jonathan Cameron <jic23@...nel.org>,
David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>,
linux-kernel-mentees@...ts.linuxfoundation.org,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] iio: st_lsm6dsx: Replace scnprintf with sysfs_emit
On Wed, Jul 23, 2025 at 07:43:59PM +0530, Akshay Bansod wrote:
> Update the sysfs interface for sampling frequency and scale attributes.
> Replace `scnprintf()` with `sysfs_emit_at()` which is PAGE_SIZE-aware
> and recommended for use in sysfs.
...
> fs_table = &hw->settings->fs_table[sensor->id];
> for (i = 0; i < fs_table->fs_len; i++)
> - len += scnprintf(buf + len, PAGE_SIZE - len, "0.%09u ",
> - fs_table->fs_avl[i].gain);
> - buf[len - 1] = '\n';
> + len += sysfs_emit_at(buf, len, "0.%09u ",
> + fs_table->fs_avl[i].gain);
> +
> + sysfs_emit_at(buf, len - 1, "\n");
Still looks a bit weird (while working).
> return len;
I deally we should have a helper doing all this under the hood for plenty of
the (existing) users in the kernel.
In any case, I leave this change to others to comment, I don't object pushing
it in this form, either way len - 1 is simply weird.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists