From patchwork Tue Dec 22 14:22:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58889 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3265857lbb; Tue, 22 Dec 2015 06:22:42 -0800 (PST) X-Received: by 10.98.74.207 with SMTP id c76mr3858613pfj.147.1450794162270; Tue, 22 Dec 2015 06:22:42 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d22si9139012pfj.41.2015.12.22.06.22.42; Tue, 22 Dec 2015 06:22:42 -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 S1754100AbbLVOWl (ORCPT + 4 others); Tue, 22 Dec 2015 09:22:41 -0500 Received: from mail-lb0-f173.google.com ([209.85.217.173]:32858 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752037AbbLVOWk (ORCPT ); Tue, 22 Dec 2015 09:22:40 -0500 Received: by mail-lb0-f173.google.com with SMTP id sv6so25114780lbb.0 for ; Tue, 22 Dec 2015 06:22:40 -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=TSwjX+nZ4fPaCcU9t9ETqmIP+A0oORnVs4BZoZllqQQ=; b=gWi5obFndgqNIeBIh9tWugOavNilEu1msFWAj7f+BRJ5G/s8YSKL42HHwqfM3JIapf ORq56Hl71nGOa/M2sbl/gIM/MfepT0F5zOEH9GYJmXf743t3JXihJtIdTtqZFywrYy/k Y7RTeBIhOwA+tPk0k50sbIrnQEnsfgqeB90fo= 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=TSwjX+nZ4fPaCcU9t9ETqmIP+A0oORnVs4BZoZllqQQ=; b=QLpOJmQw0B+B4U4nA60k0EAMad20Mwc2yaD0ZmLIHayelKc+wwcfVx++58q7rmT0n1 D+ftv50BcrF3flM/KCSxvNS0MTZZXxbebTRyinXy9OFjpt00SVDgxNYNX1s98BWtgFYb RudnIHSv6Acn2G4lKUVvE2k91KmBWO3hxTAyvDHEwuB7T9z0/2yJAnJC6OMcn2CJea9s 34+j1cLFk+WiN2kmc76yMOgKh0c10iaWUZNmgCCmGHqBfSB/NdkF3acSn0TT7Rl+Kegg Nuv60j1HfVhQ8ZSyMfD2ySBJwCi0m7VwYN3PXSalrUUF9VsMNB8P0OLPxsMm3ndzFw89 KVaw== X-Gm-Message-State: ALoCoQk2ifxvgzStBHwqjnBjfD7yizNPme13CRa6G3dmoYU4KNfCbeHFLWBmQZvECalS4ImEZR24HoV10+P4lbtHxEOhABuAWg== X-Received: by 10.112.97.176 with SMTP id eb16mr8768331lbb.138.1450794159518; Tue, 22 Dec 2015 06:22:39 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l138sm5863970lfe.47.2015.12.22.06.22.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:22:38 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alessandro Rubini Cc: Linus Walleij Subject: [PATCH 16/54] gpio: sta2x11: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:22:35 +0100 Message-Id: <1450794155-23122-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: Alessandro Rubini Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sta2x11.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-sta2x11.c b/drivers/gpio/gpio-sta2x11.c index 55e47828ddfc..af0be81ad2b6 100644 --- a/drivers/gpio/gpio-sta2x11.c +++ b/drivers/gpio/gpio-sta2x11.c @@ -90,7 +90,7 @@ static int gsta_gpio_get(struct gpio_chip *gpio, unsigned nr) struct gsta_regs __iomem *regs = __regs(chip, nr); u32 bit = __bit(nr); - return readl(®s->dat) & bit; + return !!(readl(®s->dat) & bit); } static int gsta_gpio_direction_output(struct gpio_chip *gpio, unsigned nr,