From patchwork Tue Dec 22 14:31:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58903 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3270913lbb; Tue, 22 Dec 2015 06:31:42 -0800 (PST) X-Received: by 10.66.162.9 with SMTP id xw9mr36122183pab.46.1450794702458; Tue, 22 Dec 2015 06:31:42 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si18989947pfj.114.2015.12.22.06.31.42; Tue, 22 Dec 2015 06:31: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 S932835AbbLVObl (ORCPT + 4 others); Tue, 22 Dec 2015 09:31:41 -0500 Received: from mail-lb0-f178.google.com ([209.85.217.178]:35439 "EHLO mail-lb0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932834AbbLVObl (ORCPT ); Tue, 22 Dec 2015 09:31:41 -0500 Received: by mail-lb0-f178.google.com with SMTP id bc4so32090909lbc.2 for ; Tue, 22 Dec 2015 06:31: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:mime-version:content-type :content-transfer-encoding; bh=75yLqR8qLL5huPLhp5lVo9M6mTxFNgP0eP6rOaSplyQ=; b=aM+YUunBjmpWAv53Ze3XrDs8a86lokF7jdZ/bvcHuixZvGeK+iWFiKfTKOAjVpatQV cC9RRYK5P9qxTXwiLOK6AQsgoLqVhUL8r+AyMmt7nBVxTOgP8xTUtNJCBEPuUdsvLLij WFLQNGVbMQAfswb0gw/c2H/MnOeONN4BDE/f0= 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=75yLqR8qLL5huPLhp5lVo9M6mTxFNgP0eP6rOaSplyQ=; b=VZ4yl64AnQjENVxPR76XoqhLOvda9iNNXaPEdbmdp2zOHSYY0vowcyDzwXdYQlwXDh qYytwCHQlFtCwcVuZFCWNtsjOdrZzgsxEsCtn4TEEUllmA3B5Ncb4k38y1N+/6RUIVX0 2K9zNTeDbgxbI2HVeqkWpj+4BRgqX1lHWzC1lHcnim/CisGV6O9f3yA48K/80Oa3X2rH 9sqwwgSitp/CkdCktry+cvINdj1rSDGcz7TZrBiGFOZ97NmxyrmUuABYhAw/63QpO2d2 GaRmrq0G3vCpRHvuUOQdg4ApLr9Q9eJeg3J49X67ztrJiN/iKOt5HfKQuZQdBOU96Yx5 0Sdg== X-Gm-Message-State: ALoCoQmpFh+o1JkzVcRPT7pbGsQjktcrEwjAlAmIXCAEGtwa6eqq/17lQMm2SIZdkyAyoRivy4Jt4/4m+6OQLRiE1JtINYxwAQ== X-Received: by 10.112.132.6 with SMTP id oq6mr4577632lbb.38.1450794699807; Tue, 22 Dec 2015 06:31:39 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o67sm5888421lfo.33.2015.12.22.06.31.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:31:39 -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 30/54] gpio: ssbi-mpp: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:31:32 +0100 Message-Id: <1450794693-24019-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. This code was also double-inverting a bool which makes no sense so I removed that code and moved clamping toward the end. Cc: Björn Andersson Signed-off-by: Linus Walleij --- drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 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-mpp.c b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c index 8f5c96cbf94e..23089d541230 100644 --- a/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c @@ -502,13 +502,13 @@ static int pm8xxx_mpp_get(struct gpio_chip *chip, unsigned offset) int ret; if (!pin->input) - return pin->output_value; + return !!pin->output_value; 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_mpp_set(struct gpio_chip *chip, unsigned offset, int value)