diff mbox

[35/54] m68k: coldfire/gpio: Be sure to clamp return value

Message ID 1450795145-27292-1-git-send-email-linus.walleij@linaro.org
State Accepted
Commit 4693c2493a9b2d0c5d407496ea107676a690f1c0
Headers show

Commit Message

Linus Walleij Dec. 22, 2015, 2:39 p.m. UTC
As we want gpio_chip .get() calls to be able to return negative
error codes and propagate to drivers, we need to go over all
drivers and make sure their return values are clamped to [0,1].
We do this by using the ret = !!(val) design pattern.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Ungerer <gerg@uclinux.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
M68K folks: as mentioned in 00/54: either apply this directly
or ACK it and I will take it into the GPIO tree.
---
 arch/m68k/coldfire/gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Linus Walleij Dec. 25, 2015, 12:45 p.m. UTC | #1
On Wed, Dec 23, 2015 at 12:51 PM, Greg Ungerer <gerg@uclinux.org> wrote:
> On 23/12/15 00:39, Linus Walleij wrote:

>>

>> As we want gpio_chip .get() calls to be able to return negative

>> error codes and propagate to drivers, we need to go over all

>> drivers and make sure their return values are clamped to [0,1].

>> We do this by using the ret = !!(val) design pattern.

>>

>> Cc: Geert Uytterhoeven <geert@linux-m68k.org>

>> Cc: Greg Ungerer <gerg@uclinux.org>

>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

>> ---

>> M68K folks: as mentioned in 00/54: either apply this directly

>> or ACK it and I will take it into the GPIO tree.

>

>

> I will take via the m68knommu git tree.

> I am pushing it up to the for-next branch now.


Awesome, thanks Greg.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/m68k/coldfire/gpio.c b/arch/m68k/coldfire/gpio.c
index e7e428681ec5..37a83e27c7a6 100644
--- a/arch/m68k/coldfire/gpio.c
+++ b/arch/m68k/coldfire/gpio.c
@@ -121,7 +121,7 @@  static int mcfgpio_direction_input(struct gpio_chip *chip, unsigned offset)
 
 static int mcfgpio_get_value(struct gpio_chip *chip, unsigned offset)
 {
-	return __mcfgpio_get_value(offset);
+	return !!__mcfgpio_get_value(offset);
 }
 
 static int mcfgpio_direction_output(struct gpio_chip *chip, unsigned offset,