public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Gabriel Shahrouzi <gshahrouzi@gmail.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	 Jonathan Cameron <jic23@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 linux-iio@vger.kernel.org, linux-staging@lists.linux.dev,
	 linux-kernel@vger.kernel.org
Cc: skhan@linuxfoundation.org,
	kernelmentees@lists.linuxfoundation.org,  stable@vger.kernel.org
Subject: Re: [PATCH v3] iio: adc: Correct conditional logic for store mode
Date: Tue, 15 Apr 2025 10:13:55 +0100	[thread overview]
Message-ID: <1fb5f1c5e61ce386cb431d48296e952bdd560a6c.camel@gmail.com> (raw)
In-Reply-To: <20250414154050.469482-1-gshahrouzi@gmail.com>

On Mon, 2025-04-14 at 11:40 -0400, Gabriel Shahrouzi wrote:
> The mode setting logic in ad7816_store_mode was reversed due to
> incorrect handling of the strcmp return value. strcmp returns 0 on
> match, so the `if (strcmp(buf, "full"))` block executed when the
> input was not "full".
> 
> This resulted in "full" setting the mode to AD7816_PD (power-down) and
> other inputs setting it to AD7816_FULL.
> 
> Fix this by checking it against 0 to correctly check for "full" and
> "power-down", mapping them to AD7816_FULL and AD7816_PD respectively.
> 
> Fixes: 7924425db04a ("staging: iio: adc: new driver for AD7816 devices")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gabriel Shahrouzi <gshahrouzi@gmail.com>
> ---

LGTM, do you happen to have this device? It would more interesting to move this
driver out of staging :)

Acked-by: Nuno Sá <nuno.sa@analog.com>

> Changes since v3:
> 	- Tag stable@vger.kernel.org instead of an email CC
> 	- Use the correct version for patch
> Changes since v2:
> 	- Add fixes tag that references commit that introduced the bug.
>         - Replace sysfs_streq with strcmp.
> ---
>  drivers/staging/iio/adc/ad7816.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7816.c
> b/drivers/staging/iio/adc/ad7816.c
> index 6c14d7bcdd675..081b17f498638 100644
> --- a/drivers/staging/iio/adc/ad7816.c
> +++ b/drivers/staging/iio/adc/ad7816.c
> @@ -136,7 +136,7 @@ static ssize_t ad7816_store_mode(struct device *dev,
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct ad7816_chip_info *chip = iio_priv(indio_dev);
>  
> -	if (strcmp(buf, "full")) {
> +	if (strcmp(buf, "full") == 0) {
>  		gpiod_set_value(chip->rdwr_pin, 1);
>  		chip->mode = AD7816_FULL;
>  	} else {

  reply	other threads:[~2025-04-15  9:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-14 15:40 [PATCH v3] iio: adc: Correct conditional logic for store mode Gabriel Shahrouzi
2025-04-15  9:13 ` Nuno Sá [this message]
2025-04-15 13:54   ` Gabriel Shahrouzi
2025-04-18 15:18     ` Jonathan Cameron
2025-04-18 16:56       ` Gabriel Shahrouzi

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=1fb5f1c5e61ce386cb431d48296e952bdd560a6c.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gshahrouzi@gmail.com \
    --cc=jic23@kernel.org \
    --cc=kernelmentees@lists.linuxfoundation.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=skhan@linuxfoundation.org \
    --cc=stable@vger.kernel.org \
    /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