Skip to content

Commit

Permalink
[MIPS] au1000: Make sure GPIO value is zero or one
Browse files Browse the repository at this point in the history
David Brownell <david-b@pacbell.net> wrote:
>       The problem is that "value" is zero-or-nonzero.
>       This code wrongly assumes it's zero-or-one.
>       Possible fix:  "((!!value) << gpio)".

Signed-off-by: Bruno Randolf <br1@einfach.org>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Bruno Randolf authored and Ralf Baechle committed Sep 27, 2008
1 parent 6ef190c commit 19506fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/mips/au1000/common/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static void au1xxx_gpio2_write(unsigned gpio, int value)
{
gpio -= AU1XXX_GPIO_BASE;

gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | (value << gpio);
gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | ((!!value) << gpio);
}

static int au1xxx_gpio2_direction_input(unsigned gpio)
Expand All @@ -62,7 +62,7 @@ static int au1xxx_gpio2_direction_output(unsigned gpio, int value)
{
gpio -= AU1XXX_GPIO_BASE;
gpio2->dir |= 0x01 << gpio;
gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | (value << gpio);
gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | ((!!value) << gpio);
return 0;
}

Expand Down

0 comments on commit 19506fc

Please sign in to comment.