Skip to contentSkip to conversation

media: i2c: max9286: normalize return value of gpio_get

PATCH In review Dmitry Torokhov 5 participants 5 messages Feb 18 – Feb 19

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: i2c: max9286: normalize return value of gpio_get

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.

---
 drivers/media/i2c/max9286.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/max9286.c +1 -1
index e6e214f8294b..ac0712ce1e65 100644
@@ -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)
Signature · 5 lines
2.53.0.335.g19a08e0c02-goog


-- 
Dmitry
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dmitry Torokhov

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.

Quoted 23 lines
---
 drivers/media/i2c/max9286.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/max9286.c +1 -2
index e6e214f8294b..ac0712ce1e65 100644
@@ -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

Signature · 1 line
Ricardo Ribalda
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Dmitry Torokhov
Quoted 26 lines · Dmitry Torokhov

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.

---
 drivers/media/i2c/max9286.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/max9286.c +1 -2
index e6e214f8294b..ac0712ce1e65 100644
@@ -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

Quoted 3 lines

--
Dmitry

maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Dmitry Torokhov

Quoting Dmitry Torokhov (2026-02-18 20:53:48)

Quoted 14 lines

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.

---
 drivers/media/i2c/max9286.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/max9286.c +0 -0
index e6e214f8294b..ac0712ce1e65 100644

drivers/media/i2c/max9286.c static int max9286_gpiochip_get(struct gpio_chip *chip, unsigned int offset) · line 1208

Quoted 5 lines
drivers/media/i2c/max9286.c +1 -1
@@ -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));
Quoted 9 lines
drivers/media/i2c/max9286.c +0 -0
 }
 
 static int max9286_register_gpio(struct max9286_priv *priv)
Signature · 5 lines
2.53.0.335.g19a08e0c02-goog


-- 
Dmitry