diff options
author | Bruno Randolf <br1@einfach.org> | 2008-09-25 10:45:10 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2008-09-27 10:45:35 -0400 |
commit | 19506fc51852e859bb08ab5abbdb8fd02b7392f2 (patch) | |
tree | 9c6352c3de58feb9651d4488232db81b6ac231c7 /arch/mips/au1000/common/gpio.c | |
parent | 6ef190cc92e33565accff6a320f0e7d90480bfe7 (diff) |
[MIPS] au1000: Make sure GPIO value is zero or one
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>
Diffstat (limited to 'arch/mips/au1000/common/gpio.c')
-rw-r--r-- | arch/mips/au1000/common/gpio.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/mips/au1000/common/gpio.c b/arch/mips/au1000/common/gpio.c index 1f058434b726..e660ddd611c4 100644 --- a/arch/mips/au1000/common/gpio.c +++ b/arch/mips/au1000/common/gpio.c | |||
@@ -48,7 +48,7 @@ static void au1xxx_gpio2_write(unsigned gpio, int value) | |||
48 | { | 48 | { |
49 | gpio -= AU1XXX_GPIO_BASE; | 49 | gpio -= AU1XXX_GPIO_BASE; |
50 | 50 | ||
51 | gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | (value << gpio); | 51 | gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | ((!!value) << gpio); |
52 | } | 52 | } |
53 | 53 | ||
54 | static int au1xxx_gpio2_direction_input(unsigned gpio) | 54 | static int au1xxx_gpio2_direction_input(unsigned gpio) |
@@ -62,7 +62,7 @@ static int au1xxx_gpio2_direction_output(unsigned gpio, int value) | |||
62 | { | 62 | { |
63 | gpio -= AU1XXX_GPIO_BASE; | 63 | gpio -= AU1XXX_GPIO_BASE; |
64 | gpio2->dir |= 0x01 << gpio; | 64 | gpio2->dir |= 0x01 << gpio; |
65 | gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | (value << gpio); | 65 | gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | ((!!value) << gpio); |
66 | return 0; | 66 | return 0; |
67 | } | 67 | } |
68 | 68 | ||