]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
MIPS: RB532: Fix bit swapping in rb532_set_bit()
authorPhil Sutter <n0-1@freewrt.org>
Tue, 11 Nov 2008 23:09:30 +0000 (00:09 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Fri, 30 Jan 2009 21:32:59 +0000 (21:32 +0000)
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 <n0-1@freewrt.org>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/rb532/gpio.c

index 0e84c8ab6a3932b39adbfbe2cb8144fae39ba51d..e35cb75a3ae7f03a8ec296e054b9131aed8592e9 100644 (file)
@@ -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);