]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
blackfin: gpio: Use proper mask for comparing function
authorAxel Lin <axel.lin@ingics.com>
Fri, 28 Jun 2013 06:45:06 +0000 (14:45 +0800)
committerSonic Zhang <sonic.zhang@analog.com>
Wed, 31 Jul 2013 08:56:03 +0000 (16:56 +0800)
The function return from P_FUNCT2MUX(per) takes 2 bits, however
for BF537_FAMILY with offset != 1 the function is 1 bit.

Also has small refactor for better readability.
In portmux_setup(), it looks odd having "muxreg &= ~(3 << 1);"
while in current code we do muxreg |= (function << offset);.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
arch/blackfin/cpu/gpio.c

index a4d10d51608d6fbeabdddd394ed19dafb8cfafde..f9aff4d894ae95f2d69239e60127485cc5b1a1cc 100644 (file)
@@ -247,7 +247,7 @@ static struct {
 
 static void portmux_setup(unsigned short per)
 {
-       u16 y, offset, muxreg;
+       u16 y, offset, muxreg, mask;
        u16 function = P_FUNCT2MUX(per);
 
        for (y = 0; y < ARRAY_SIZE(port_mux_lut); y++) {
@@ -258,12 +258,13 @@ static void portmux_setup(unsigned short per)
                        offset = port_mux_lut[y].offset;
                        muxreg = bfin_read_PORT_MUX();
 
-                       if (offset != 1)
-                               muxreg &= ~(1 << offset);
+                       if (offset == 1)
+                               mask = 3;
                        else
-                               muxreg &= ~(3 << 1);
+                               mask = 1;
 
-                       muxreg |= (function << offset);
+                       muxreg &= ~(mask << offset);
+                       muxreg |= ((function & mask) << offset);
                        bfin_write_PORT_MUX(muxreg);
                }
        }