Re: [PATCH] staging: iio: adt7316: use kstrtobool() for sysfs boolean parsing
From: Joshua Crofts
Date: Tue Oct 06 2026 - 11:17:39 EST
On Tue, 6 Oct 2026 13:33:50 +0300
Abdelnasser Hussein <abdelnasserhussein11@xxxxxxxxx> 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@xxxxxxxxx>
> ---
> 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