From: akshay bansod <akbansd@gmail.com>
To: "Lorenzo Bianconi" <lorenzo@kernel.org>,
"Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"David Lechner" <dlechner@baylibre.com>
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
skhan@linuxfoundation.org
Subject: Re: [PATCH] iio: st_lsm6dsx: Replace scnprintf with sysfs_emit
Date: Wed, 02 Jul 2025 20:27:53 +0530 [thread overview]
Message-ID: <3363941.44csPzL39Z@mbox> (raw)
In-Reply-To: <f96b68a5-d750-45f0-8cdd-9761b5daca1d@baylibre.com>
On Wednesday, 2 July 2025 8:25 pm +0530 David Lechner wrote:
> On 7/2/25 8:58 AM, 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.
> >
> > Signed-off-by: Akshay Bansod <akbansd@gmail.com>
> > ---
> >
> > Testing:
> > - Built the driver (`st_lsm6dsx_i2c`) as a module.
> > - Tested using `i2c-stub` to mock the device.
> > - Verified that reading sysfs attributes like `sampling_frequency_available`
> > works correctly and shows no change in functionality.
>
> Nice to see it was actually tested. :-)
>
:-)
> >
> > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > index c65ad4982..1cef10919 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > @@ -2035,7 +2035,7 @@ 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 ",
> > + len += sysfs_emit_at(buf, len, "%d.%03d ",
> > odr_table->odr_avl[i].milli_hz / 1000,
> > odr_table->odr_avl[i].milli_hz % 1000);
>
> Let's keep checkpatch happy and change the indent of the wrapped lines to
> line up with ( since the ( moved.
>
noted. I wasn't aware of that.
> > buf[len - 1] = '\n';
> > @@ -2054,7 +2054,7 @@ static ssize_t st_lsm6dsx_sysfs_scale_avail(struct device *dev,
> >
> > 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 ",
> > + len += sysfs_emit_at(buf, len, "0.%09u ",
> > fs_table->fs_avl[i].gain);
>
> ditto
>
noted.
> > buf[len - 1] = '\n';
> >
>
>
Thanks for the review. I'll revise the patch.
Regards,
Akshay
prev parent reply other threads:[~2025-07-02 14:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 13:58 [PATCH] iio: st_lsm6dsx: Replace scnprintf with sysfs_emit Akshay Bansod
2025-07-02 14:16 ` David Lechner
2025-07-02 14:55 ` Andy Shevchenko
2025-07-02 15:04 ` David Lechner
2025-07-02 15:22 ` Andy Shevchenko
2025-07-02 15:33 ` Jonathan Cameron
2025-07-02 15:53 ` David Lechner
2025-07-03 9:05 ` Andy Shevchenko
2025-07-03 12:31 ` David Lechner
2025-07-02 14:57 ` akshay bansod [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3363941.44csPzL39Z@mbox \
--to=akbansd@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=nuno.sa@analog.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).