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

Commit 5379a5fd authored by Phil Sutter's avatar Phil Sutter Committed by Ralf Baechle
Browse files

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: default avatarPhil Sutter <n0-1@freewrt.org>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent f839490a
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -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);