[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aGaIMjkYBmfMmCBn@smile.fi.intel.com>
Date: Thu, 3 Jul 2025 16:40:02 +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,
skhan@...uxfoundation.org, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] iio: st_lsm6dsx: Replace scnprintf with sysfs_emit
On Thu, Jul 03, 2025 at 11:08:59AM +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.
'must' is stronger than 'recommendation'.
Of has the documentation been changed lately?
...
> st_lsm6dsx_sysfs_sampling_frequency_avail(struct device *dev,
> odr_table = &sensor->hw->settings->odr_table[sensor->id];
> for (i = 0; i < odr_table->odr_len; i++)
> - len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%03d ",
> - odr_table->odr_avl[i].milli_hz / 1000,
> - odr_table->odr_avl[i].milli_hz % 1000);
> + len += sysfs_emit_at(buf, len, "%d.%03d ",
> + odr_table->odr_avl[i].milli_hz / 1000,
> + odr_table->odr_avl[i].milli_hz % 1000);
> buf[len - 1] = '\n';
My gosh, this is error prone. I'm wondering when some CIs will start to
complain on this line. But this was already before your change...
> return len;
...
> 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);
> + len += sysfs_emit_at(buf, len, "0.%09u ",
> + fs_table->fs_avl[i].gain);
> buf[len - 1] = '\n';
Ditto.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists