From: akshay bansod <akbansd@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>,
Jonathan Cameron <jic23@kernel.org>
Cc: "Lorenzo Bianconi" <lorenzo@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: Mon, 11 Aug 2025 22:29:21 +0530 [thread overview]
Message-ID: <13797318.O9o76ZdvQC@mbox> (raw)
In-Reply-To: <20250802125038.7a02cbce@jic23-huawei>
On Saturday, 2 August 2025 10:26 pm +0530 Jonathan Cameron wrote:
> On Thu, 24 Jul 2025 14:47:31 +0300
> Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
>
> > On Wed, Jul 23, 2025 at 04:41:00PM +0100, Jonathan Cameron wrote:
> > > On Wed, 23 Jul 2025 17:42:28 +0300
> > > Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > > > On Wed, Jul 23, 2025 at 07:43:59PM +0530, Akshay Bansod wrote:
> >
> > ...
> >
> > > > > 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.
> > >
> > > hmm I'm not sure generic is terribly easy
> >
> > I agree, I have some plans for %p specifier extension, but I was stuck with it
> > and it in half-basked state in some of my local Git branches.
> >
> > > and I'd prefer this using the
> > > read_avail callbacks that require the data in an array where ever possible.
> > > Mind you that does the same print at len - 1 as this. Let's play.
> > > Completely untested.
> > >
> > > for (i = 0; i < fs_table->fs_len; i++)
> > > len += sysfs_emit_at(buf, len, "0x%09u%c",
> > > fs_table->fs_avl[i].gain,
> > > ((i == fs_table->fs_len - 1) ? '\n', ' '));
> > >
> > > better?
> >
> > Without extra parentheses this makes the job.
> >
> Akshay, can you spin a new version along those lines?
Apologies for the delay. Here's the revision
https://lore.kernel.org/linux-iio/20250811165641.1214347-1-akbansd@gmail.com/
> >
> > > It's definitely not more readable than the above, but it does avoid the write
> > > to len - 1.
> > >
> > > > 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.
> >
>
>
prev parent reply other threads:[~2025-08-11 17:00 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
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 [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=13797318.O9o76ZdvQC@mbox \
--to=akbansd@gmail.com \
--cc=andriy.shevchenko@intel.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.