From patchwork Tue Dec 22 14:13: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: 58881 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3260447lbb; Tue, 22 Dec 2015 06:13:41 -0800 (PST) X-Received: by 10.98.79.66 with SMTP id d63mr36097566pfb.34.1450793621500; Tue, 22 Dec 2015 06:13:41 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fc7si4639946pab.144.2015.12.22.06.13.41; Tue, 22 Dec 2015 06:13:41 -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 S1754342AbbLVONl (ORCPT + 4 others); Tue, 22 Dec 2015 09:13:41 -0500 Received: from mail-lb0-f174.google.com ([209.85.217.174]:34019 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753609AbbLVONk (ORCPT ); Tue, 22 Dec 2015 09:13:40 -0500 Received: by mail-lb0-f174.google.com with SMTP id pv2so45811600lbb.1 for ; Tue, 22 Dec 2015 06:13:39 -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=20q0nLtfAFkZ74kz/UlNGd9FICYMpEfqjfcv9VvzSs4=; b=iFp7xskPGkN2JdciP9hn1MrpT750bwu1oCetlbdqc+sSofirWn6QMgyYtAevkKZwpU PPRHKrCmNxYFMYadVehKRK3WrKqE17Yt3ho0ejn2bR2B/EvDfKd+14As6qy6DoqdBIXU M5VtBqGHWIgwZLQfuSjVCoGPmJA2D3tCkSCKk= 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=20q0nLtfAFkZ74kz/UlNGd9FICYMpEfqjfcv9VvzSs4=; b=BMFVy0+EE+7n/lxl+Z9kTi71ZHcKIaI+EAcsZdivKMJcHerbJ8aEH0BsUQi4cXC+X7 Ah57AbxBTX98jIJ7SOl1O/twvJNWUV5tHGFOooB/P1hF/k3M9n0tDDRWplYVb1yU1NrI I73zWl3y7+4rZg+SmrxO7QDR3uyli3cyL9lwA2Fs5z6C5VUcD0GKZTZYqU9oNcY1Hfo3 i2UsQgTc++077Bth0+2et0SuFtUURuIWGhu8APyPNmri4uBhD+5Y9RCgCcr/m4FwYgfm eGT6Q+AJnjfOjI9O0sEWVslFXGiiY01E4gM2HY6i4l1u8c34nJkHlxUqrPDL7TI79zUu Hnqw== X-Gm-Message-State: ALoCoQkz+3vioJU55/f1EkJBjPATZ/6TMXc873s+xAvgWXWdPVLIpYRj+ryX+RxXXEhjLTFcPa0kLCM1jQQQnyUG4nabaiWCsA== X-Received: by 10.112.12.233 with SMTP id b9mr4138264lbc.63.1450793618646; Tue, 22 Dec 2015 06:13:38 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id d203sm5816966lfg.39.2015.12.22.06.13.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:13:37 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Roland Stigge Cc: Linus Walleij , Vladimir Zapolskiy Subject: [PATCH 08/54] gpio: lpc32xx: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:13:35 +0100 Message-Id: <1450793615-22239-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: Roland Stigge Cc: Vladimir Zapolskiy Signed-off-by: Linus Walleij --- drivers/gpio/gpio-lpc32xx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 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-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c index 47e2dde63734..e888b5fcd236 100644 --- a/drivers/gpio/gpio-lpc32xx.c +++ b/drivers/gpio/gpio-lpc32xx.c @@ -288,21 +288,21 @@ static int lpc32xx_gpio_get_value_p012(struct gpio_chip *chip, unsigned pin) { struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); - return __get_gpio_state_p012(group, pin); + return !!__get_gpio_state_p012(group, pin); } static int lpc32xx_gpio_get_value_p3(struct gpio_chip *chip, unsigned pin) { struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); - return __get_gpio_state_p3(group, pin); + return !!__get_gpio_state_p3(group, pin); } static int lpc32xx_gpi_get_value(struct gpio_chip *chip, unsigned pin) { struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); - return __get_gpi_state_p3(group, pin); + return !!__get_gpi_state_p3(group, pin); } static int lpc32xx_gpio_dir_output_p012(struct gpio_chip *chip, unsigned pin, @@ -364,7 +364,7 @@ static int lpc32xx_gpo_get_value(struct gpio_chip *chip, unsigned pin) { struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip); - return __get_gpo_state_p3(group, pin); + return !!__get_gpo_state_p3(group, pin); } static int lpc32xx_gpio_request(struct gpio_chip *chip, unsigned pin)