From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Akshay Bansod <akbansd@gmail.com>
Cc: "Lorenzo Bianconi" <lorenzo@kernel.org>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-kernel-mentees@lists.linuxfoundation.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] iio: st_lsm6dsx: Replace scnprintf with sysfs_emit
Date: Wed, 23 Jul 2025 17:42:28 +0300 [thread overview]
Message-ID: <aID01DxC1Hf2PK0i@smile.fi.intel.com> (raw)
In-Reply-To: <20250723141359.11723-1-akbansd@gmail.com>
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
next prev parent reply other threads:[~2025-07-23 14:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 14:13 [PATCH v3] iio: st_lsm6dsx: Replace scnprintf with sysfs_emit Akshay Bansod
2025-07-23 14:42 ` Andy Shevchenko [this message]
2025-07-23 15:41 ` Jonathan Cameron
2025-07-24 11:47 ` Andy Shevchenko
2025-08-02 11:50 ` Jonathan Cameron
2025-08-11 16:59 ` akshay bansod
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=aID01DxC1Hf2PK0i@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.