From patchwork Tue Dec 22 14:10:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58875 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3258498lbb; Tue, 22 Dec 2015 06:10:33 -0800 (PST) X-Received: by 10.98.89.27 with SMTP id n27mr6410876pfb.70.1450793433520; Tue, 22 Dec 2015 06:10:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kk7si4786635pab.19.2015.12.22.06.10.33; Tue, 22 Dec 2015 06:10:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752775AbbLVOKc (ORCPT + 4 others); Tue, 22 Dec 2015 09:10:32 -0500 Received: from mail-lb0-f181.google.com ([209.85.217.181]:35486 "EHLO mail-lb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751599AbbLVOKc (ORCPT ); Tue, 22 Dec 2015 09:10:32 -0500 Received: by mail-lb0-f181.google.com with SMTP id bc4so31771647lbc.2 for ; Tue, 22 Dec 2015 06:10:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=LQVW5c43xdIBjAi4fSvdMCbjRe58jaFMGCyz9iey5aw=; b=gIO+rEY7mr+/W+/B8dsjqx2k4bqVNjWpndfIv9LR3qESLj/BFDEB3sHVjcuGOxS+3D 0Zt4NPYJvozSDgGzUsSx0vHXlXs/2Rhw7FffuzGvITV/rW4HV9rMkzaofZ6gBk1eYjQt enImG/E9QKcl+lUXlB78qmlRWV1TgMQ1ryEWc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LQVW5c43xdIBjAi4fSvdMCbjRe58jaFMGCyz9iey5aw=; b=XKwGesgFBIy4tzSx58dEBVzvDAx1V8LaQg02181Eqzly+oA4a7OneQb1byPvYb7k/V SPleNVZQfJN0DS+Rm53kSoI8DUv4csQTe+IMhRJmzH81848RwyOSOWIoUXrN8rg4Fb18 NKnsHJw4oQ212JPxkAMmUu5Y4h05cMoeyV3JQLONQyXnqFa1jBRAtj5MLu65lBveoUqx o7F2YwL0IJeOoqjThvwINYxH4C3FWxMzEYzOJJ96LHe+bfA0Qi3lyek8HwKknHtvsu8+ XSRpdqlIp43XBN9r5du/LUfTB7karvrjKKUUI6Lu+O8jhWEJyvaElG3qt2Rl2PU5ESao 3oUw== X-Gm-Message-State: ALoCoQmnemuXY2LpEuj3fo4Pg32Ab09Kr9P3IhVHl1+8xWxVF7i/6WdbTXcUeP+bMVHdEjD6asmdnk99JGLvmLou52Bem33rVw== X-Received: by 10.112.165.69 with SMTP id yw5mr8536922lbb.1.1450793430814; Tue, 22 Dec 2015 06:10:30 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id g7sm5672460lbs.34.2015.12.22.06.10.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:10:29 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Grygorii Strashko , Sekhar Nori , Santosh Shilimkar Cc: Linus Walleij Subject: [PATCH 02/54] gpio: davinci: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:10:27 +0100 Message-Id: <1450793427-21871-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Grygorii Strashko Cc: Sekhar Nori Cc: Santosh Shilimkar Signed-off-by: Linus Walleij --- drivers/gpio/gpio-davinci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 65ebaef935e1..1e3a617e0c10 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -125,7 +125,7 @@ static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset) struct davinci_gpio_controller *d = chip2controller(chip); struct davinci_gpio_regs __iomem *g = d->regs; - return (1 << offset) & readl_relaxed(&g->in_data); + return !!((1 << offset) & readl_relaxed(&g->in_data)); } /*