* [PATCH 35/54] m68k: coldfire/gpio: Be sure to clamp return value
@ 2015-12-22 14:39 Linus Walleij
2015-12-23 11:51 ` Greg Ungerer
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2015-12-22 14:39 UTC (permalink / raw)
To: linux-gpio, Geert Uytterhoeven, Greg Ungerer; +Cc: Linus Walleij
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(-)
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,
--
2.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 35/54] m68k: coldfire/gpio: Be sure to clamp return value
2015-12-22 14:39 [PATCH 35/54] m68k: coldfire/gpio: Be sure to clamp return value Linus Walleij
@ 2015-12-23 11:51 ` Greg Ungerer
2015-12-25 12:45 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Greg Ungerer @ 2015-12-23 11:51 UTC (permalink / raw)
To: Linus Walleij, linux-gpio, Geert Uytterhoeven
Hi Linus,
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.
Thanks
Greg
> ---
> arch/m68k/coldfire/gpio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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,
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 35/54] m68k: coldfire/gpio: Be sure to clamp return value
2015-12-23 11:51 ` Greg Ungerer
@ 2015-12-25 12:45 ` Linus Walleij
0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2015-12-25 12:45 UTC (permalink / raw)
To: Greg Ungerer; +Cc: linux-gpio@vger.kernel.org, Geert Uytterhoeven
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-25 12:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-22 14:39 [PATCH 35/54] m68k: coldfire/gpio: Be sure to clamp return value Linus Walleij
2015-12-23 11:51 ` Greg Ungerer
2015-12-25 12:45 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).