[PATCH v2 1/4] iio: adc: ti-ads7950: normalize return value of gpio_get

Dmitry Torokhov posted 4 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH v2 1/4] iio: adc: ti-ads7950: normalize return value of gpio_get
Posted by Dmitry Torokhov 1 month, 2 weeks ago
The GPIO get callback is expected to return 0 or 1 (or a negative error
code). Ensure that the value returned by ti_ads7950_get() for output
pins is normalized to the [0, 1] range.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/iio/adc/ti-ads7950.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
index bbe1ce577789..b8cc39fc39fb 100644
--- a/drivers/iio/adc/ti-ads7950.c
+++ b/drivers/iio/adc/ti-ads7950.c
@@ -433,7 +433,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
 
 	/* If set as output, return the output */
 	if (st->gpio_cmd_settings_bitmask & BIT(offset)) {
-		ret = st->cmd_settings_bitmask & BIT(offset);
+		ret = (st->cmd_settings_bitmask & BIT(offset)) ? 1 : 0;
 		goto out;
 	}
 
-- 
2.53.0.335.g19a08e0c02-goog
Re: [PATCH v2 1/4] iio: adc: ti-ads7950: normalize return value of gpio_get
Posted by Jonathan Cameron 1 month, 1 week ago
On Wed, 18 Feb 2026 18:29:25 -0800
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:

> The GPIO get callback is expected to return 0 or 1 (or a negative error
> code). Ensure that the value returned by ti_ads7950_get() for output
> pins is normalized to the [0, 1] range.
Fixes?  I'm not quite sure with something that says 'expected'

Jonathan

> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/iio/adc/ti-ads7950.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
> index bbe1ce577789..b8cc39fc39fb 100644
> --- a/drivers/iio/adc/ti-ads7950.c
> +++ b/drivers/iio/adc/ti-ads7950.c
> @@ -433,7 +433,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
>  
>  	/* If set as output, return the output */
>  	if (st->gpio_cmd_settings_bitmask & BIT(offset)) {
> -		ret = st->cmd_settings_bitmask & BIT(offset);
> +		ret = (st->cmd_settings_bitmask & BIT(offset)) ? 1 : 0;
>  		goto out;
>  	}
>
Re: [PATCH v2 1/4] iio: adc: ti-ads7950: normalize return value of gpio_get
Posted by Dmitry Torokhov 1 month, 1 week ago
On Sun, Feb 22, 2026 at 02:03:15PM +0000, Jonathan Cameron wrote:
> On Wed, 18 Feb 2026 18:29:25 -0800
> Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> 
> > The GPIO get callback is expected to return 0 or 1 (or a negative error
> > code). Ensure that the value returned by ti_ads7950_get() for output
> > pins is normalized to the [0, 1] range.
> Fixes?  I'm not quite sure with something that says 'expected'

Will add a tag.

Thanks.

-- 
Dmitry
Re: [PATCH v2 1/4] iio: adc: ti-ads7950: normalize return value of gpio_get
Posted by Linus Walleij 1 month, 2 weeks ago
On Thu, Feb 19, 2026 at 3:29 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> The GPIO get callback is expected to return 0 or 1 (or a negative error
> code). Ensure that the value returned by ti_ads7950_get() for output
> pins is normalized to the [0, 1] range.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij
Re: [PATCH v2 1/4] iio: adc: ti-ads7950: normalize return value of gpio_get
Posted by Bartosz Golaszewski 1 month, 2 weeks ago
On Thu, 19 Feb 2026 03:29:25 +0100, Dmitry Torokhov
<dmitry.torokhov@gmail.com> said:
> The GPIO get callback is expected to return 0 or 1 (or a negative error
> code). Ensure that the value returned by ti_ads7950_get() for output
> pins is normalized to the [0, 1] range.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/iio/adc/ti-ads7950.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
> index bbe1ce577789..b8cc39fc39fb 100644
> --- a/drivers/iio/adc/ti-ads7950.c
> +++ b/drivers/iio/adc/ti-ads7950.c
> @@ -433,7 +433,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset)
>
>  	/* If set as output, return the output */
>  	if (st->gpio_cmd_settings_bitmask & BIT(offset)) {
> -		ret = st->cmd_settings_bitmask & BIT(offset);
> +		ret = (st->cmd_settings_bitmask & BIT(offset)) ? 1 : 0;
>  		goto out;
>  	}
>
> --
> 2.53.0.335.g19a08e0c02-goog
>
>

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Re: [PATCH v2 1/4] iio: adc: ti-ads7950: normalize return value of gpio_get
Posted by Andy Shevchenko 1 month, 2 weeks ago
On Wed, Feb 18, 2026 at 06:29:25PM -0800, Dmitry Torokhov wrote:
> The GPIO get callback is expected to return 0 or 1 (or a negative error
> code). Ensure that the value returned by ti_ads7950_get() for output
> pins is normalized to the [0, 1] range.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko