From: Johan Hovold <johan@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@kernel.org>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Alexandru Tachici <alexandru.tachici@analog.com>,
Roan van Dijk <roan@protonic.nl>,
Tomasz Duszynski <tduszyns@gmail.com>,
Marc Titinger <mtitinger@baylibre.com>,
Matt Ranostay <mranostay@gmail.com>,
Paresh Chaudhary <paresh.chaudhary@rockwellcollins.com>,
Navin Sankar Velliangiri <navin@linumiz.com>,
Jacopo Mondi <jacopo+renesas@jmondi.org>,
Ludovic Tancerel <ludovic.tancerel@maplehightech.com>,
linux-iio@vger.kernel.org
Subject: Re: [PATCH 07/13] iio: lm3533: Use sysfs_emit()
Date: Fri, 17 Dec 2021 10:14:49 +0100 [thread overview]
Message-ID: <YbxVCcJgE55hOqPY@hovoldconsulting.com> (raw)
In-Reply-To: <20211216185217.1054495-8-lars@metafoo.de>
On Thu, Dec 16, 2021 at 07:52:11PM +0100, Lars-Peter Clausen wrote:
> sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
> knows about the sysfs buffer specifics and has some built-in checks for
> size and alignment.
I realise that the above is some copy-paste boiler plate, but none of it
is really relevant here when the driver uses the attribute buffer
directly with scnprintf() and a PAGE_SIZE argument.
This should probably be rephrased in terms of consistency and the
documentation now claiming that only sysfs_emit() should be used in
show() functions (e.g. to avoid problems in drivers that would have
failed to follow the previous instructions).
> Use sysfs_emit() to format the custom device attributes of the lm3533
> driver.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
That said, the change itself is otherwise fine even I'm not sure it's
generally worth the churn to convert all existing show() functions:
Reviewed-by: Johan Hovold <johan@kernel.org>
> ---
> drivers/iio/light/lm3533-als.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/light/lm3533-als.c b/drivers/iio/light/lm3533-als.c
> index 8a621244dd01..827bc25269e9 100644
> --- a/drivers/iio/light/lm3533-als.c
> +++ b/drivers/iio/light/lm3533-als.c
> @@ -417,7 +417,7 @@ static ssize_t show_thresh_either_en(struct device *dev,
> enable = 0;
> }
>
> - return scnprintf(buf, PAGE_SIZE, "%u\n", enable);
> + return sysfs_emit(buf, "%u\n", enable);
> }
>
> static ssize_t store_thresh_either_en(struct device *dev,
> @@ -474,7 +474,7 @@ static ssize_t show_zone(struct device *dev,
> if (ret)
> return ret;
>
> - return scnprintf(buf, PAGE_SIZE, "%u\n", zone);
> + return sysfs_emit(buf, "%u\n", zone);
> }
>
> enum lm3533_als_attribute_type {
> @@ -530,7 +530,7 @@ static ssize_t show_als_attr(struct device *dev,
> if (ret)
> return ret;
>
> - return scnprintf(buf, PAGE_SIZE, "%u\n", val);
> + return sysfs_emit(buf, "%u\n", val);
> }
>
> static ssize_t store_als_attr(struct device *dev,
Johan
next prev parent reply other threads:[~2021-12-17 9:15 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-16 18:52 [PATCH 00/13] iio: Use sysfs_emit() Lars-Peter Clausen
2021-12-16 18:52 ` [PATCH 01/13] iio: core: " Lars-Peter Clausen
2021-12-16 18:52 ` [PATCH 02/13] iio: dmaengine-buffer: " Lars-Peter Clausen
2021-12-16 18:52 ` [PATCH 03/13] iio: ad7192: " Lars-Peter Clausen
2021-12-23 13:30 ` Jonathan Cameron
2021-12-16 18:52 ` [PATCH 04/13] iio: ad9523: " Lars-Peter Clausen
2021-12-23 13:32 ` Jonathan Cameron
2021-12-16 18:52 ` [PATCH 05/13] iio: as3935: " Lars-Peter Clausen
2021-12-16 18:52 ` [PATCH 06/13] iio: ina2xx-adc: sysfs_emit() Lars-Peter Clausen
2021-12-16 18:52 ` [PATCH 07/13] iio: lm3533: Use sysfs_emit() Lars-Peter Clausen
2021-12-17 9:14 ` Johan Hovold [this message]
2022-01-16 16:50 ` Jonathan Cameron
2021-12-16 18:52 ` [PATCH 08/13] iio: max31856: " Lars-Peter Clausen
2021-12-16 18:52 ` [PATCH 09/13] iio: max31865: " Lars-Peter Clausen
2021-12-16 18:52 ` [PATCH 10/13] iio: max9611: " Lars-Peter Clausen
2021-12-17 9:05 ` Jacopo Mondi
2021-12-17 9:17 ` Lars-Peter Clausen
2021-12-17 10:09 ` Jacopo Mondi
2021-12-16 18:52 ` [PATCH 11/13] iio: ms_sensors: " Lars-Peter Clausen
2021-12-16 18:52 ` [PATCH 12/13] iio: scd4x: " Lars-Peter Clausen
2021-12-16 18:52 ` [PATCH 13/13] iio: sps30: " Lars-Peter Clausen
2022-01-16 16:54 ` [PATCH 00/13] iio: " 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=YbxVCcJgE55hOqPY@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.tachici@analog.com \
--cc=jacopo+renesas@jmondi.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=ludovic.tancerel@maplehightech.com \
--cc=mranostay@gmail.com \
--cc=mtitinger@baylibre.com \
--cc=navin@linumiz.com \
--cc=paresh.chaudhary@rockwellcollins.com \
--cc=roan@protonic.nl \
--cc=tduszyns@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