Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <n0-1@freewrt.org>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Phil Sutter and committed by
Ralf Baechle
5379a5fd f839490a

+2 -4
+2 -4
arch/mips/rb532/gpio.c
··· 119 119 unsigned long flags; 120 120 u32 val; 121 121 122 - bitval = !!bitval; /* map parameter to {0,1} */ 123 - 124 122 local_irq_save(flags); 125 123 126 124 val = readl(ioaddr); 127 - val &= ~( ~bitval << offset ); /* unset bit if bitval == 0 */ 128 - val |= ( bitval << offset ); /* set bit if bitval == 1 */ 125 + val &= ~(!bitval << offset); /* unset bit if bitval == 0 */ 126 + val |= (!!bitval << offset); /* set bit if bitval == 1 */ 129 127 writel(val, ioaddr); 130 128 131 129 local_irq_restore(flags);