]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
gpio: pca953x: Fix register reading past 8th GPIO
authormario.six@gdsys.cc <mario.six@gdsys.cc>
Mon, 23 May 2016 07:54:56 +0000 (09:54 +0200)
committerSimon Glass <sjg@chromium.org>
Sun, 19 Jun 2016 23:05:55 +0000 (17:05 -0600)
A bug in the pca953x driver prevents correct reading of GPIO input
values beyond the 8th GPIO; all values are reported as zero. Setting of
GPIO output values is not affected.

This patch fixes the reading behavior.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
Reviewed-by: Peng Fan <van.freenix@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
drivers/gpio/pca953x_gpio.c

index 065b181bd237d0c3c259d961ad44fa2a5444bd96..0410add5183cb607ac55b5a41d1d19c9f5573755 100644 (file)
@@ -148,11 +148,13 @@ static int pca953x_get_value(struct udevice *dev, unsigned offset)
        int ret;
        u8 val = 0;
 
+       int off = offset % BANK_SZ;
+
        ret = pca953x_read_single(dev, PCA953X_INPUT, &val, offset);
        if (ret)
                return ret;
 
-       return (val >> offset) & 0x1;
+       return (val >> off) & 0x1;
 }
 
 static int pca953x_set_value(struct udevice *dev, unsigned offset,