From patchwork Tue Dec 22 14:47:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58920 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3279548lbb; Tue, 22 Dec 2015 06:47:16 -0800 (PST) X-Received: by 10.98.79.77 with SMTP id d74mr36556532pfb.44.1450795636666; Tue, 22 Dec 2015 06:47:16 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s19si12413445pfi.212.2015.12.22.06.47.16; Tue, 22 Dec 2015 06:47:16 -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 S932658AbbLVOrN (ORCPT + 4 others); Tue, 22 Dec 2015 09:47:13 -0500 Received: from mail-lb0-f169.google.com ([209.85.217.169]:34491 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932243AbbLVOrK (ORCPT ); Tue, 22 Dec 2015 09:47:10 -0500 Received: by mail-lb0-f169.google.com with SMTP id pv2so46322182lbb.1 for ; Tue, 22 Dec 2015 06:47:10 -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=BIKvbDir37mj3pZ+8yhwwWVEy5KaxTe4zStWvgTUdROQcqdbW+tFGvFSBRNGj91qf6 vdPlRwJFNSxSiQI3EQSL/6e+2NqL/7f207mlLwksxZSzVnyR/323YLSpl+JFTN6EfSYS 8jy8UO2ThzHNyZqbsvrs1GHeyQ9HvFuyBC7Mc= 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=j00uQLDLQ/zZVVE7EY0IK1NhrbqDWIHH0lY3BCESMvmJUVp64JggOJXHwLAjC7r6bv l0qB8TS8YvPGyGufsiKry8uQy2lYr3Ttc21SOhvF2jAd4sk1AbV9ClfVgeNmeUS/b4u3 8zGssr3TULu77AesRpYzyszrhxfcVJFSwtLwsPv3IVqkrR0fj0WntAo3nv6KKzk4PzZG ElUeMZ1ta51OrgytGEMKZ8xRvsdXMFN7yMg3YD7G+Z6M5aOPdPm8qLF4adRQwRfYFUzX eYRu/INPCKsg3P9aUoAHfIo43m2lCGmTLZW//0ptDKzTiYyljr5GdG6mClNsW8+IAsoR LJwQ== X-Gm-Message-State: ALoCoQmeuH3enZckdAScCNDPxxUxm0NqA0uXSmXSbIaLIpE6X0F9bohr/hVV64SCMWEP4IKllEhEWb+VI+yy1ACQErEJjloUag== X-Received: by 10.112.42.67 with SMTP id m3mr8898541lbl.2.1450795629364; Tue, 22 Dec 2015 06:47:09 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u12sm5795214lbk.45.2015.12.22.06.47.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:47:08 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Lee Jones Cc: Linus Walleij , Paul Parsons Subject: [PATCH 45/54] mfd: asic3: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:47:05 +0100 Message-Id: <1450795625-28120-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,