From patchwork Tue Dec 22 14:30:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58900 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3270356lbb; Tue, 22 Dec 2015 06:30:45 -0800 (PST) X-Received: by 10.98.18.69 with SMTP id a66mr36378836pfj.50.1450794645271; Tue, 22 Dec 2015 06:30:45 -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.30.44; Tue, 22 Dec 2015 06:30:45 -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 S932335AbbLVOao (ORCPT + 4 others); Tue, 22 Dec 2015 09:30:44 -0500 Received: from mail-lf0-f41.google.com ([209.85.215.41]:36445 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932139AbbLVOao (ORCPT ); Tue, 22 Dec 2015 09:30:44 -0500 Received: by mail-lf0-f41.google.com with SMTP id z124so125511713lfa.3 for ; Tue, 22 Dec 2015 06:30:43 -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=3URLTE1nd2ILQqZhbU5/E4Wn+IBroiKwDlwLYzYWAco=; b=afSq2ubn9LdsFu/Wa0ki3hDLbx2lRIaNv3kBLdHgB/vuSmyaJzuIER0ShWXW8E1m8K F3EHSYmHKgPCmFzg1YBSkQBvHCphUG4fibBikmt7ocTlbwNaUsgjWbZIGaur6tgW9MDX 8ICVNwMiKZtoF8ojVIS372x51BH+2bPXWWYLc= 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=3URLTE1nd2ILQqZhbU5/E4Wn+IBroiKwDlwLYzYWAco=; b=FFanlNAlGgLeV0E9IbL58890wWMydpuMaLqe+5s3/V/z1BuBpOyeErKeEqg04YEhio llt84hZAGv88EDNzUG0dMoAomRAlOlkIF+T40lO87zsRliBJ9u/j0LDDKFgCUAk0FPb6 2HEmO1BO8WiYff+qbP/mRcPtx2Tr7X/Bw6tVH0qJjGILZL1q1VXSlYPyZxzOMJ74vFs2 aCT6ljsYAVxJUE/B5ullpIcb66xfSm10vi0DYdgRGeETxRQGqk3l1Bz22/FoNgg/YQ96 JKmjHL6OdgySZhZqOgSQAR6oV94853QR6dN1gtdWGK109EWaa680WOSnxcIh/mrJLNzy IxgQ== X-Gm-Message-State: ALoCoQnPkPHkl+yzSi0nADx9tT/WAeEumNbuJyiclkuJ1hkEfMmDz6JR1OJXVfmBXkZx/SyisHAKdkZ4EObo/QWfd67U56EikA== X-Received: by 10.25.137.84 with SMTP id l81mr8652207lfd.45.1450794642557; Tue, 22 Dec 2015 06:30:42 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l138sm5869017lfe.47.2015.12.22.06.30.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:30:41 -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 27/54] pinctrl: spmi-gpio: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:30:38 +0100 Message-Id: <1450794638-23834-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. Cc: Ivan T. Ivanov Cc: Björn Andersson Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-spmi-gpio.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/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c index 3e5ccc76d59c..4460b2c9c8bd 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c @@ -533,7 +533,7 @@ static int pmic_gpio_get(struct gpio_chip *chip, unsigned pin) pad->out_value = ret & PMIC_MPP_REG_RT_STS_VAL_MASK; } - return pad->out_value; + return !!pad->out_value; } static void pmic_gpio_set(struct gpio_chip *chip, unsigned pin, int value)