public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: i2c: max9286: normalize return value of gpio_get
@ 2026-02-18 20:53 Dmitry Torokhov
  2026-02-19 10:42 ` Ricardo Ribalda
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2026-02-18 20:53 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: Jacopo Mondi, Kieran Bingham, Laurent Pinchart,
	Niklas Söderlund, Mauro Carvalho Chehab, Linus Walleij,
	Bartosz Golaszewski, Hans Verkuil, Sakari Ailus, Ricardo Ribalda,
	linux-media, 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 max9286_gpiochip_get() is
normalized to the [0, 1] range.

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

diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index e6e214f8294b..ac0712ce1e65 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -1205,7 +1205,7 @@ static int max9286_gpiochip_get(struct gpio_chip *chip, unsigned int offset)
 {
 	struct max9286_priv *priv = gpiochip_get_data(chip);
 
-	return priv->gpio_state & BIT(offset);
+	return !!(priv->gpio_state & BIT(offset));
 }
 
 static int max9286_register_gpio(struct max9286_priv *priv)
-- 
2.53.0.335.g19a08e0c02-goog


-- 
Dmitry

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-18 20:53 [PATCH] media: i2c: max9286: normalize return value of gpio_get Dmitry Torokhov
2026-02-19 10:42 ` Ricardo Ribalda
2026-02-19 10:48 ` Bartosz Golaszewski
2026-02-19 11:58 ` Kieran Bingham
2026-02-19 17:32 ` Linus Walleij

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