From patchwork Mon May 23 07:54:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Six X-Patchwork-Id: 625068 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3rCrSz3chLz9t3Z for ; Mon, 23 May 2016 17:56:02 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1EF3BA7506; Mon, 23 May 2016 09:55:58 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3t3HOADnaAoc; Mon, 23 May 2016 09:55:57 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1E9A3A74D0; Mon, 23 May 2016 09:55:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8294DA74D0 for ; Mon, 23 May 2016 09:55:54 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GCrPJK18j1bJ for ; Mon, 23 May 2016 09:55:54 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtprelay05.ispgateway.de (smtprelay05.ispgateway.de [80.67.31.97]) by theia.denx.de (Postfix) with ESMTPS id 4F391A7498 for ; Mon, 23 May 2016 09:55:51 +0200 (CEST) Received: from [195.243.218.178] (helo=bob3.testumgebung.local) by smtprelay05.ispgateway.de with esmtpa (Exim 4.84) (envelope-from ) id 1b4kiM-00018u-EK; Mon, 23 May 2016 09:55:50 +0200 From: Mario Six To: Simon Glass , Peng Fan , Michal Simek , U-Boot Mailing List Date: Mon, 23 May 2016 09:54:56 +0200 Message-Id: <1463990096-2977-1-git-send-email-mario.six@gdsys.cc> X-Mailer: git-send-email 2.7.0.GIT X-Df-Sender: bWFyaW8uc2l4QGdkc3lzLmNj Subject: [U-Boot] [PATCH] gpio: pca953x: Fix register reading past 8th GPIO X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Acked-by: Simon Glass --- 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,