From patchwork Wed Feb 5 13:14:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 24164 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A273420675 for ; Wed, 5 Feb 2014 13:14:23 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wp4sf1711932obc.1 for ; Wed, 05 Feb 2014 05:14:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=jwnH+qc8Zrt1F8d2ddS7zLMMAJt939leoAYh04LnZJY=; b=atUztVKXR6/dz/y2M8Te69wFkJjeJdQvkdkG7BdTitGwWlQsncpkWnRq8ANGVTJdRt alcJtmrFSHZkbSDLzaRDmAFOEdL2WBk/lX4FTAkJuMfbI/i4lW13F18a9IfCE6ii/WZp F/LVwRtqGUuJ72w3q56OZUayP9CiU+abPt6gvehq3sMyH3hyNwbVBNAvAFBrdU9wKpp4 VyGifdAxzuGCya5Dc8jkKB59A+85XaDy77HsmpLTOkRf6GBa4BFppn6GlZwet4GM6U4v O85Px6CZzQnLiZkUOnQfq8Pt5FNh2Hg3XYfw53/9MG7eo9/PXWJKmr0VSK2WuLPA2l9E lXdA== X-Gm-Message-State: ALoCoQld+MRs7glitBAhgSE6whIC9pe1Dd4G1mfoX/P/JiI1YbytGGocO/UsI0Qts5N7y2tm/y8w X-Received: by 10.182.19.231 with SMTP id i7mr507184obe.25.1391606062690; Wed, 05 Feb 2014 05:14:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.35.208 with SMTP id n74ls94035qgn.65.gmail; Wed, 05 Feb 2014 05:14:22 -0800 (PST) X-Received: by 10.221.34.211 with SMTP id st19mr1014727vcb.5.1391606062618; Wed, 05 Feb 2014 05:14:22 -0800 (PST) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id cy15si9646295veb.68.2014.02.05.05.14.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Feb 2014 05:14:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id id10so263619vcb.13 for ; Wed, 05 Feb 2014 05:14:22 -0800 (PST) X-Received: by 10.58.106.37 with SMTP id gr5mr20761veb.57.1391606062530; Wed, 05 Feb 2014 05:14:22 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp43769vcz; Wed, 5 Feb 2014 05:14:22 -0800 (PST) X-Received: by 10.194.77.7 with SMTP id o7mr1259662wjw.35.1391606061613; Wed, 05 Feb 2014 05:14:21 -0800 (PST) Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) by mx.google.com with ESMTPS id dq1si9330997wib.75.2014.02.05.05.14.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Feb 2014 05:14:21 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.51 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=74.125.82.51; Received: by mail-wg0-f51.google.com with SMTP id z12so275752wgg.30 for ; Wed, 05 Feb 2014 05:14:21 -0800 (PST) X-Received: by 10.180.87.9 with SMTP id t9mr16624664wiz.36.1391606061142; Wed, 05 Feb 2014 05:14:21 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id bm8sm61395275wjc.12.2014.02.05.05.14.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Feb 2014 05:14:20 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Evgeny Boger Cc: Alexandre Courbot , Linus Walleij , Alexandre Courbot Subject: [PATCH] gpio: generic: clamp retured value to [0,1] Date: Wed, 5 Feb 2014 14:14:13 +0100 Message-Id: <1391606053-12422-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.5.3 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The generic GPIO would return 0 for low generic GPIO, and something != 0 for high GPIO. Let's make this sane by clamping the returned value to [0,1]. Reported-by: Evgeny Boger Cc: Alexandre Courbot Signed-off-by: Linus Walleij --- drivers/gpio/gpio-generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c index d2196bf73847..de397823617e 100644 --- a/drivers/gpio/gpio-generic.c +++ b/drivers/gpio/gpio-generic.c @@ -139,7 +139,7 @@ static int bgpio_get(struct gpio_chip *gc, unsigned int gpio) { struct bgpio_chip *bgc = to_bgpio_chip(gc); - return bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio); + return !!(bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio)); } static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)