mfd: AB8500 mask off irrelevant bits from the SPI message
authorLinus Walleij <linus.walleij@stericsson.com>
Fri, 28 May 2010 00:59:44 +0000 (02:59 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 12 Aug 2010 09:27:18 +0000 (11:27 +0200)
The registers on the AB8500 are only 8 bits wide, so the content
of the remaining bits is undefined. Let's mask off the undefined
stuff when returning a register in an SPI read.

Acked-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/ab8500-spi.c

index b81d4f768ef6ce410a78694118111075c9af38cd..e1c8b62b086d506ef46d8a52ccb6d5c4d73e0a18 100644 (file)
@@ -68,7 +68,12 @@ static int ab8500_spi_read(struct ab8500 *ab8500, u16 addr)
 
        ret = spi_sync(spi, &msg);
        if (!ret)
-               ret = ab8500->rx_buf[0];
+               /*
+                * Only the 8 lowermost bytes are
+                * defined with value, the rest may
+                * vary depending on chip/board noise.
+                */
+               ret = ab8500->rx_buf[0] & 0xFFU;
 
        return ret;
 }