Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19506fc5 authored by Bruno Randolf's avatar Bruno Randolf Committed by Ralf Baechle
Browse files

[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: default avatarBruno Randolf <br1@einfach.org>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 6ef190cc
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -48,7 +48,7 @@ static void au1xxx_gpio2_write(unsigned gpio, int value)
{
{
	gpio -= AU1XXX_GPIO_BASE;
	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)
static int au1xxx_gpio2_direction_input(unsigned gpio)
@@ -62,7 +62,7 @@ static int au1xxx_gpio2_direction_output(unsigned gpio, int value)
{
{
	gpio -= AU1XXX_GPIO_BASE;
	gpio -= AU1XXX_GPIO_BASE;
	gpio2->dir |= 0x01 << gpio;
	gpio2->dir |= 0x01 << gpio;
	gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | (value << gpio);
	gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | ((!!value) << gpio);
	return 0;
	return 0;
}
}