From patchwork Tue Dec 22 14:24:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58892 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3266630lbb; Tue, 22 Dec 2015 06:24:11 -0800 (PST) X-Received: by 10.98.9.80 with SMTP id e77mr36256992pfd.162.1450794250966; Tue, 22 Dec 2015 06:24:10 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xk9si4644477pab.38.2015.12.22.06.24.10; Tue, 22 Dec 2015 06:24:10 -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 S1754515AbbLVOYK (ORCPT + 4 others); Tue, 22 Dec 2015 09:24:10 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:35677 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753443AbbLVOYJ (ORCPT ); Tue, 22 Dec 2015 09:24:09 -0500 Received: by mail-lf0-f49.google.com with SMTP id l133so129721725lfd.2 for ; Tue, 22 Dec 2015 06:24:08 -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=bh+k7upT3U/9/1U/bSRrOPINGzlRY9G862PbhKJ/DfI=; b=Up9zLkFslq15YvziEzBIfscUub+RWFk7qzS2CbfqcPCKw7RUysTdxeuJL2LVm56et8 iIg9QJ2qmpwAFG8fDQP/m7RVftYy4vN7Q8N/hqN2WWgeJr6+jzuDakskW3I1t7d1B+ge 3fOL4fdJ33xdygKtfFv+X3Y9S74yf7PZo60O4= 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=bh+k7upT3U/9/1U/bSRrOPINGzlRY9G862PbhKJ/DfI=; b=ZfN4ghKuPowU0Y/dBmljMkXz2/cym9L13b5lh6sg0nPByT0LEA3iKh1+mCkAt5KZV0 +fCJMVq9CSznGq+vCEJqo47so5Ul8ff7GqMFFQR9XTvB9MIOfZBAzJrA4tJlMOlL55GF VMjIYuIoDxvyTDlc2+3qXBqzk8aNaAh97UeQ86t8OgG/afFxFb/Zxaq2Eh7zpWucm25/ mElUKHIIGPUvp7dUv719VVTN3NfRuVdb2yQ92NGS6hg+ufK29467kfLnbrDuBTA1Y8BL S3LYt57DTIrdu0zMIp03LoBxrxG6Eio/ckMPcDq9nx+xaExDS4LSa7MqRnTr5MQIfMGN iopQ== X-Gm-Message-State: ALoCoQn30h8f66bupEW046Kxk0RTkirCk4UaZwILBZ6AcXyCQoX/as/gfcPsZ9+FHs1kptnlcPxdpMg50bROATClGCZIw/9riA== X-Received: by 10.25.29.202 with SMTP id d193mr6884485lfd.55.1450794247929; Tue, 22 Dec 2015 06:24:07 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id ki2sm5720277lbc.15.2015.12.22.06.24.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:24:07 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Roger Quadros , Tony Lindgren Cc: Linus Walleij Subject: [PATCH 19/54] gpio: twl4030: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:24:03 +0100 Message-Id: <1450794243-23310-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. This also makes the driver start to return the error code, as the end of the series make this work. Cc: Roger Quadros Cc: Tony Lindgren Signed-off-by: Linus Walleij --- drivers/gpio/gpio-twl4030.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-twl4030.c b/drivers/gpio/gpio-twl4030.c index 14f40bf64e34..f5590514838a 100644 --- a/drivers/gpio/gpio-twl4030.c +++ b/drivers/gpio/gpio-twl4030.c @@ -327,7 +327,7 @@ static int twl_get(struct gpio_chip *chip, unsigned offset) else status = twl4030_get_gpio_datain(offset); - ret = (status <= 0) ? 0 : 1; + ret = (status < 0) ? status : !!status; out: mutex_unlock(&priv->mutex); return ret;