From patchwork Tue Dec 22 14:45:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58918 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3278614lbb; Tue, 22 Dec 2015 06:45:34 -0800 (PST) X-Received: by 10.98.42.210 with SMTP id q201mr36112365pfq.12.1450795534636; Tue, 22 Dec 2015 06:45:34 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si19043393pfj.114.2015.12.22.06.45.34; Tue, 22 Dec 2015 06:45:34 -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 S932235AbbLVOpe (ORCPT + 4 others); Tue, 22 Dec 2015 09:45:34 -0500 Received: from mail-lf0-f44.google.com ([209.85.215.44]:33011 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752917AbbLVOpd (ORCPT ); Tue, 22 Dec 2015 09:45:33 -0500 Received: by mail-lf0-f44.google.com with SMTP id p203so132009590lfa.0 for ; Tue, 22 Dec 2015 06:45:32 -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=Opq6izDab2BxySc9N7YJNqwlNzL/7jP9SSOhciqbv9s=; b=eqVy0LGebFfTWzSUC4KtRo7yLUavGvnCmy4fsI8fUtXEG4qiZ6jQiskmRtXO13uvjk kSXyiTdpHWZW88LfHlQo6TCdTRMLYb8WCeGMulY8UbOwH2tMbdutn4cG4Dev+TQHyTHv sC6PUsxSyCwjcoy5UTts5BgsgTPAng9zhAjHE= 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=Opq6izDab2BxySc9N7YJNqwlNzL/7jP9SSOhciqbv9s=; b=DFh+spU7Q+zc5mrLpqszPnrGgWSuyq6pdz+n9x4qOoucaXpG9hkZD4RGTgxTtBD627 CQYdWC5wtmGRzh/UO1Y1Uc/ESXNcj93kNhgJsd0GhOOYz5eV/P/Rj4RW9m+A2D6Tt8Ut kr68hXL/aDuiC85jqZBHLoDv+Rh+1WlJ9xHWuii3hphAfZvHyEUETvLgIUFliB6DCWsg 6sxkWec3ui36uTbO5HCDmBUEe6AIdLsENL0eiBL1Gtw4DSaxmPpsDm19jJD/3Lv0m/SR liKMjSkRPLUDnAqqWn8fYpS6mcj/OFif20eqxauRXFop55TPuOASO42ZBbWzOTf8PX2H cuNg== X-Gm-Message-State: ALoCoQktMgI4LEfiMv9pSFT1oMHNYc0m/HwG4RiYxsNP3qHyR2905vprry8SfeNN/h7EorxREHJPk7+jal6YJCxbnTpIOsTyyw== X-Received: by 10.25.25.142 with SMTP id 136mr1607480lfz.42.1450795531858; Tue, 22 Dec 2015 06:45:31 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id p69sm5814777lfe.42.2015.12.22.06.45.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:45:31 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Guan Xuetao Cc: Linus Walleij , Paul Parsons , Lee Jones Subject: [PATCH 45/54] mfd: asic3: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:45:26 +0100 Message-Id: <1450795526-27949-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: Paul Parsons Cc: Lee Jones Signed-off-by: Linus Walleij --- Lee: as mentioned in 00/54: either apply this directly or ACK it and I will take it into the GPIO tree. --- drivers/mfd/asic3.c | 3 ++- 1 file changed, 2 insertions(+), 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/mfd/asic3.c b/drivers/mfd/asic3.c index a726f01e3b02..58c4d9cb8e8d 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c @@ -502,7 +502,8 @@ static int asic3_gpio_get(struct gpio_chip *chip, return -EINVAL; } - return asic3_read_register(asic, gpio_base + ASIC3_GPIO_STATUS) & mask; + return !!(asic3_read_register(asic, gpio_base + ASIC3_GPIO_STATUS) + & mask)); } static void asic3_gpio_set(struct gpio_chip *chip,