mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joshua Crofts <joshua.crofts1@gmail.com>
To: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux@analog.com, linux-iio@vger.kernel.org,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: iio: adt7316: use kstrtobool() for sysfs boolean parsing
Date: Tue, 6 Oct 2026 17:10:35 +0200	[thread overview]
Message-ID: <20261006171035.00001ce2@gmail.com> (raw)
In-Reply-To: <20261006103350.32853-1-abdelnasserhussein11@gmail.com>

On Tue,  6 Oct 2026 13:33:50 +0300
Abdelnasser Hussein <abdelnasserhussein11@gmail.com> wrote:

> Replace manual and unsafe character checks (e.g., buf[0] == '1') with the
> standard kstrtobool() API in sysfs store functions. This ensures proper
> handling of standard boolean inputs, fixes potential safety issues, and
> adheres to the Linux kernel coding style.
> 
> Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11@gmail.com>
> ---
>  drivers/staging/iio/addac/adt7316.c | 94 +++++++++++++++++++++++------
>  1 file changed, 77 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
> index 20f6052cc7fb..21a1b811a142 100644
> --- a/drivers/staging/iio/addac/adt7316.c
> +++ b/drivers/staging/iio/addac/adt7316.c
> @@ -246,12 +246,12 @@ static ssize_t adt7316_store_enabled(struct device *dev,
>  {

Please also include linux/kstrtox.h.

>  	struct iio_dev *dev_info = dev_to_iio_dev(dev);
>  	struct adt7316_chip_info *chip = iio_priv(dev_info);
> -	int enable;
> +	bool enable;
> +	int ret;
>  
> -	if (buf[0] == '1')
> -		enable = 1;
> -	else
> -		enable = 0;
> +	ret = kstrtobool(buf, &enable);
> +	if (ret)
> +		return ret;
>  
>  	if (_adt7316_store_enabled(chip, enable) < 0)
>  		return -EIO;
> @@ -285,13 +285,18 @@ static ssize_t adt7316_store_select_ex_temp(struct device *dev,
>  	struct iio_dev *dev_info = dev_to_iio_dev(dev);
>  	struct adt7316_chip_info *chip = iio_priv(dev_info);
>  	u8 config1;
> +	bool req;

Hmmm, req is a pretty vague name in my opinion. Ideally you shouldn't
use super short variable names unless they are self explanatory/common
(like ret or inx). What does req mean? Could be request or required...

(Perhaps I'm just nitpicking).

Otherwise LGTM.

-- 
Kind regards,
Joshua Crofts

      reply	other threads:[~2026-10-06 15:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 10:33 Abdelnasser Hussein
2026-10-06 15:10 ` Joshua Crofts [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=20261006171035.00001ce2@gmail.com \
    --to=joshua.crofts1@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=abdelnasserhussein11@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=linux@analog.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

all inboxes | Powered by JetHome®