From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: "Md. Mahmudul Hasan Mabud" <mdmahmudulhasan1511@gmail.com>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org,
gregkh@linuxfoundation.org, dlechner@baylibre.com,
nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: iio: adc: ad7816: use sysfs_streq() instead of strcmp()
Date: Mon, 30 Mar 2026 13:09:20 +0300 [thread overview]
Message-ID: <acpL0OgqPYoVbzb-@ashevche-desk.local> (raw)
In-Reply-To: <20260330074850.12638-1-mdmahmudulhasan1511@gmail.com>
On Mon, Mar 30, 2026 at 01:48:50PM +0600, Md. Mahmudul Hasan Mabud wrote:
> Use sysfs_streq() to compare the input buffer with the mode strings.
> This is more robust as it ignores trailing newlines, making it safer
> for sysfs store functions.
...
> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> struct ad7816_chip_info *chip = iio_priv(indio_dev);
>
> - if (strcmp(buf, "full") == 0) {
> + if (sysfs_streq(buf, "full")) {
> gpiod_set_value(chip->rdwr_pin, 1);
> chip->mode = AD7816_FULL;
I think it might be better to do more work on this.
First of all, convert to use IIO_DEVICE_ATTR_RW().
Second, convert to use sysfs_emit() instead of sprintf().
But with that, switch to use a static array
static const char * const modes[] = {
[_FULL] = "full";
[_PD] = "power-save";
};
This will need redefinition to start from 0 (I don't see why it needs to
start from 1).
#define _FULL 0
#define _PD 1
This allows to switch to sysfs_match_string() and return an error on
unrecognized input (which is absent right now).
So, something like series out of ~3-4 patches is expected.
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-03-30 10:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 7:48 [PATCH] staging: iio: adc: ad7816: use sysfs_streq() instead of strcmp() Md. Mahmudul Hasan Mabud
2026-03-30 10:09 ` Andy Shevchenko [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=acpL0OgqPYoVbzb-@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mdmahmudulhasan1511@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox