public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ti-ads7950: normalize return value of gpio_get
@ 2026-02-18 20:52 Dmitry Torokhov
  2026-02-18 23:40 ` David Lechner
  2026-02-19 10:48 ` Bartosz Golaszewski
  0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2026-02-18 20:52 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: David Lechner, Nuno Sá, Andy Shevchenko, Linus Walleij,
	Bartosz Golaszewski, linux-iio, linux-kernel, linux-gpio

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..0c4db18ec4d7 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));
 		goto out;
 	}
 
-- 
2.53.0.335.g19a08e0c02-goog


-- 
Dmitry

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-19 10:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-18 20:52 [PATCH] iio: adc: ti-ads7950: normalize return value of gpio_get Dmitry Torokhov
2026-02-18 23:40 ` David Lechner
2026-02-19 10:48 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox