From: Peng Fan Date: Mon, 23 May 2016 17:15:19 +0800 Subject: [U-Boot] [PATCH] gpio: pca953x: Fix register reading past 8th GPIO In-Reply-To: <1463990096-2977-1-git-send-email-mario.six@gdsys.cc> References: <1463990096-2977-1-git-send-email-mario.six@gdsys.cc> Message-ID: <20160523091517.GA5377@linux-7smt.suse> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Mario, On Mon, May 23, 2016 at 09:54:56AM +0200, Mario Six wrote: >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 Reviewed-by: Peng Fan Regards, Peng. >--- > drivers/gpio/pca953x_gpio.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > >diff --git a/drivers/gpio/pca953x_gpio.c b/drivers/gpio/pca953x_gpio.c >index 987d10e..3cbfa09 100644 >--- a/drivers/gpio/pca953x_gpio.c >+++ b/drivers/gpio/pca953x_gpio.c >@@ -145,11 +145,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, >-- >2.7.0.GIT >