From patchwork Tue Dec 22 14:31:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58902 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3270703lbb; Tue, 22 Dec 2015 06:31:21 -0800 (PST) X-Received: by 10.98.9.199 with SMTP id 68mr2060831pfj.97.1450794681690; Tue, 22 Dec 2015 06:31:21 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dc17si4497352pac.86.2015.12.22.06.31.21; Tue, 22 Dec 2015 06:31:21 -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 S1752541AbbLVObV (ORCPT + 4 others); Tue, 22 Dec 2015 09:31:21 -0500 Received: from mail-lf0-f44.google.com ([209.85.215.44]:33912 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbbLVObU (ORCPT ); Tue, 22 Dec 2015 09:31:20 -0500 Received: by mail-lf0-f44.google.com with SMTP id y184so130166921lfc.1 for ; Tue, 22 Dec 2015 06:31:19 -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:mime-version:content-type :content-transfer-encoding; bh=ZSS+HjYX77UsOA1ZsLMJehaMORL5GRCkHcFLvDqxVoI=; b=G7oyLp0pGzWOyRqE0yyqQzZp+QMouIkMWUZkXjTLAOeVzILxwOxPGQ9KtZrTJUSp6B R6GAnRB+tyDQ/1WzBV04idHayeBoxrb8/V1eNFDbopv5vfTH153fE5EpSZjCS8GMt1if FQQFmqDXeYtscyOq1qhcHZjlUVKsnFbiTTbUE= 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:mime-version :content-type:content-transfer-encoding; bh=ZSS+HjYX77UsOA1ZsLMJehaMORL5GRCkHcFLvDqxVoI=; b=XzCzWjVZkihhRyUR79s3CGyl+m1dqXowxbdjkNHaPW/zb0k6Pz+lWTibzWJZbGT1MR uxyIDFOJFrnEVftzagtQsIY8lc/jYjKQ5BKPHUKzX1Iz64GTwuyKvuGHchtHkF3ZUdMe Nx5EkYz4rWQvqkS2duabXi8iPpXixBvUxrieXdXiVJT0jFs6rwh8p8X9+G55EucJViko HqiWGm1CY5oU7aNtaOkedKBQ/RaS60gyx8YSIve+dvAguOHvY2tOP1rtWxHSEDJLTMq7 tlajqdDqE/C5QY61DKQw/hWeGAYS1PpMAwufuWjNqRK1+9elPnbJ+o7xiY0UEpH5d4n3 GyKA== X-Gm-Message-State: ALoCoQn3V63k1Snni3qaUezk6NU95SWN7HpmqzKvCwORWa3FIjvc/I1pho7PioXHUfMFYoTRSoCC3WYW7MtzTQqKi8+GJGV78A== X-Received: by 10.25.159.9 with SMTP id i9mr1328612lfe.109.1450794679183; Tue, 22 Dec 2015 06:31:19 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t4sm614691lbw.25.2015.12.22.06.31.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:31:18 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, "Ivan T. Ivanov" , =?UTF-8?q?Bj=C3=B6rn=20Andersson?= Cc: Linus Walleij Subject: [PATCH 29/54] pinctrl: ssbi-gpio: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:31:14 +0100 Message-Id: <1450794674-23958-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 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. Also, this code was double-inverting a bool. That makes no sense whatsoever, so I removed the double-invert. Cc: Björn Andersson Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 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/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c index 7bea0df06fb1..394ca34bec4a 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c @@ -487,10 +487,10 @@ static int pm8xxx_gpio_get(struct gpio_chip *chip, unsigned offset) } else { ret = irq_get_irqchip_state(pin->irq, IRQCHIP_STATE_LINE_LEVEL, &state); if (!ret) - ret = !!state; + ret = state; } - return ret; + return !!ret; } static void pm8xxx_gpio_set(struct gpio_chip *chip, unsigned offset, int value)