From: Jonathan Cameron <jic23@kernel.org>
To: Angel2Eyes <thefireking@gmail.com>
Cc: linux-iio@vger.kernel.org, dlechner@baylibre.com,
nuno.sa@analog.com, andy@kernel.org
Subject: Re: [PATCH] iio: adc: mcp3422: use sysfs_emit() in show functions
Date: Sun, 20 Sep 2026 01:30:00 +0100 [thread overview]
Message-ID: <20260920013000.7ed606c5@jic23-hlaptop> (raw)
In-Reply-To: <20260919195507.94130-1-thefireking@gmail.com>
On Sat, 19 Sep 2026 22:55:07 +0300
Angel2Eyes <thefireking@gmail.com> wrote:
> sysfs_emit() is preferred over sprintf() for sysfs show() callbacks
> since it is aware of the PAGE_SIZE buffer and has built-in size and
> alignment checks.
>
> Convert the remaining sprintf() calls in mcp3422_show_samp_freqs() and
> mcp3422_show_scales(). The formatted output is unchanged.
>
> Assisted-by: LLM
> Signed-off-by: Angel2Eyes <thefireking@gmail.com>
Hi.
In the ideal case you would go further here and make us of the
read_avail() callback and appropriate _avail bitmap elements
for the channels. Given simple nature of these two functions that
should be easy to convert. The reason to do this is to make the
ranges etc available to in kernel users.
If you want to just make this simpler change I don't mind, but
we do need that 'well known identity' for the Sign off that
Maxwell has raised.
Jonathan
> ---
> drivers/iio/adc/mcp3422.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c
> index 36ba00edf..fd9e72265 100644
> --- a/drivers/iio/adc/mcp3422.c
> +++ b/drivers/iio/adc/mcp3422.c
> @@ -262,9 +262,9 @@ static ssize_t mcp3422_show_samp_freqs(struct device *dev,
> struct mcp3422 *adc = iio_priv(dev_to_iio_dev(dev));
>
> if (adc->id > 4)
> - return sprintf(buf, "240 60 15\n");
> + return sysfs_emit(buf, "240 60 15\n");
>
> - return sprintf(buf, "240 60 15 3\n");
> + return sysfs_emit(buf, "240 60 15 3\n");
> }
>
> static ssize_t mcp3422_show_scales(struct device *dev,
> @@ -273,7 +273,7 @@ static ssize_t mcp3422_show_scales(struct device *dev,
> struct mcp3422 *adc = iio_priv(dev_to_iio_dev(dev));
> u8 sample_rate = FIELD_GET(MCP3422_SRATE_MASK, adc->config);
>
> - return sprintf(buf, "0.%09u 0.%09u 0.%09u 0.%09u\n",
> + return sysfs_emit(buf, "0.%09u 0.%09u 0.%09u 0.%09u\n",
> mcp3422_scales[sample_rate][0],
> mcp3422_scales[sample_rate][1],
> mcp3422_scales[sample_rate][2],
>
> base-commit: 69fa76f0af3414cc189c3b0b807cb59e327ecc00
next prev parent reply other threads:[~2026-09-20 0:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 19:55 [PATCH] iio: adc: mcp3422: use sysfs_emit() in show functions Angel2Eyes
2026-09-19 22:33 ` Maxwell Doose
2026-09-19 22:45 ` Joshua Crofts
2026-09-20 0:30 ` Jonathan Cameron [this message]
2026-09-20 16:00 ` [PATCH v2] iio: adc: mcp3422: use read_avail() for available attributes Yuval Saar
2026-09-21 3:47 ` Jonathan Cameron
2026-09-25 16:50 ` Andy Shevchenko
2026-10-03 0:16 ` [PATCH v3 0/2] iio: adc: mcp3422: chip info and read_avail() Yuval Saar
2026-10-03 0:16 ` [PATCH v3 1/2] iio: adc: mcp3422: describe parts with chip_info Yuval Saar
2026-10-03 20:37 ` Andy Shevchenko
2026-10-04 16:38 ` Jonathan Cameron
2026-10-03 0:16 ` [PATCH v3 2/2] iio: adc: mcp3422: use read_avail() for available attributes Yuval Saar
2026-10-03 13:40 ` [PATCH v3 0/2] iio: adc: mcp3422: chip info and read_avail() Joshua Crofts
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=20260920013000.7ed606c5@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=thefireking@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox