80272aec404e2fb0848f2ee6427281718ab007be
[openwrt/svn-archive/archive.git] / target / linux / rb532 / patches-2.6.28 / 003-gpio_bit_setting.patch
1 The algorithm works unconditionally. If bitval is one, the first line is
2 a no op and the second line sets the bit at offset position. Vice versa,
3 if bitval is zero, the first line clears the bit at offset position and
4 the second line is a no op.
5
6 Signed-off-by: Phil Sutter <n0-1@freewrt.org>
7 ---
8 arch/mips/rb532/gpio.c | 6 ++----
9 1 files changed, 2 insertions(+), 4 deletions(-)
10
11 --- a/arch/mips/rb532/gpio.c
12 +++ b/arch/mips/rb532/gpio.c
13 @@ -119,13 +119,11 @@ static inline void rb532_set_bit(unsigne
14 unsigned long flags;
15 u32 val;
16
17 - bitval = !!bitval; /* map parameter to {0,1} */
18 -
19 local_irq_save(flags);
20
21 val = readl(ioaddr);
22 - val &= ~( ~bitval << offset ); /* unset bit if bitval == 0 */
23 - val |= ( bitval << offset ); /* set bit if bitval == 1 */
24 + val &= ~(!bitval << offset); /* unset bit if bitval == 0 */
25 + val |= (!!bitval << offset); /* set bit if bitval == 1 */
26 writel(val, ioaddr);
27
28 local_irq_restore(flags);