All of lore.kernel.org
 help / color / mirror / Atom feed
From: akshay bansod <akbansd@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@intel.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,
	skhan@linuxfoundation.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: st_lsm6dsx: Replace scnprintf with sysfs_emit
Date: Thu, 03 Jul 2025 22:28:13 +0530	[thread overview]
Message-ID: <2413481.ElGaqSPkdT@mbox> (raw)
In-Reply-To: <aGaIMjkYBmfMmCBn@smile.fi.intel.com>

On Thursday, 3 July 2025 10:12 pm +0530 Andy Shevchenko wrote:
> 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...
> 
I'm planning to drop It entirely or should I replace it with another `sysfs_emit_at()` ?
I've seen other device driver returning space terminated buffers. Maybe I'm overlooking
something.

> >  	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.
> 
> 

regards,
Akshay Bansod




  reply	other threads:[~2025-07-03 16:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03  5:38 [PATCH v2] iio: st_lsm6dsx: Replace scnprintf with sysfs_emit Akshay Bansod
2025-07-03 13:40 ` Andy Shevchenko
2025-07-03 16:58   ` akshay bansod [this message]
2025-07-06 10:50     ` Jonathan Cameron
2025-07-08  6:50       ` akshay bansod
2025-07-09 14:15         ` Jonathan Cameron

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=2413481.ElGaqSPkdT@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 \
    --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 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.