Skip to contentSkip to conversation

power: supply: sbs-manager: normalize return value of gpio_get

PATCH Applied Dmitry Torokhov 4 participants 4 messages Feb 18 – Mar 2

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

PATCH 1/1 power: supply: sbs-manager: 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 sbsm_gpio_get_value() is normalized to the [0, 1] range.

---
 drivers/power/supply/sbs-manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/sbs-manager.c +1 -1
index 6fe526222f7f..343ad4ab4082 100644
@@ -199,7 +199,7 @@ static int sbsm_gpio_get_value(struct gpio_chip *gc, unsigned int off)
 	if (ret < 0)
 		return ret;
 
-	return ret & BIT(off);
+	return !!(ret & BIT(off));
 }
 
 /*
Signature · 5 lines
2.53.0.335.g19a08e0c02-goog


-- 
Dmitry
maintainer Reviewed-by on v1 1/1
#1 lore raw
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 sbsm_gpio_get_value() is normalized to the [0, 1] range.

---
 drivers/power/supply/sbs-manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/sbs-manager.c +1 -2
index 6fe526222f7f..343ad4ab4082 100644
@@ -199,7 +199,7 @@ static int sbsm_gpio_get_value(struct gpio_chip *gc, unsigned int off)
 	if (ret < 0)
 		return ret;
 
-	return ret & BIT(off);
+	return !!(ret & BIT(off));
 }
 
 /*
--

2.53.0.335.g19a08e0c02-goog

Quoted 3 lines

--
Dmitry

#3 lore raw
In reply to Dmitry Torokhov
Quoted 5 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 sbsm_gpio_get_value() is normalized to the [0, 1] range.

Applied, thanks!

[1/1] power: supply: sbs-manager: normalize return value of gpio_get

      commit: b4512ae0d55a5632294a16eae765e8b4c41b8856

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>