From: Phil Sutter Date: Tue, 11 Nov 2008 23:09:30 +0000 (+0100) Subject: MIPS: RB532: Fix bit swapping in rb532_set_bit() X-Git-Tag: firefly_0821_release~15689^2~14 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5379a5fdf3cb2b23d00da2a1298167f9a1fb002a;p=firefly-linux-kernel-4.4.55.git MIPS: RB532: Fix bit swapping in rb532_set_bit() The algorithm works unconditionally. If bitval is one, the first line is a no op and the second line sets the bit at offset position. Vice versa, if bitval is zero, the first line clears the bit at offset position and the second line is a no op. Signed-off-by: Phil Sutter Signed-off-by: Ralf Baechle --- diff --git a/arch/mips/rb532/gpio.c b/arch/mips/rb532/gpio.c index 0e84c8ab6a39..e35cb75a3ae7 100644 --- a/arch/mips/rb532/gpio.c +++ b/arch/mips/rb532/gpio.c @@ -119,13 +119,11 @@ static inline void rb532_set_bit(unsigned bitval, unsigned long flags; u32 val; - bitval = !!bitval; /* map parameter to {0,1} */ - local_irq_save(flags); val = readl(ioaddr); - val &= ~( ~bitval << offset ); /* unset bit if bitval == 0 */ - val |= ( bitval << offset ); /* set bit if bitval == 1 */ + val &= ~(!bitval << offset); /* unset bit if bitval == 0 */ + val |= (!!bitval << offset); /* set bit if bitval == 1 */ writel(val, ioaddr); local_irq_restore(flags);