From patchwork Tue Dec 22 23:05:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58964 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3527380lbb; Tue, 22 Dec 2015 15:05:47 -0800 (PST) X-Received: by 10.98.89.210 with SMTP id k79mr18428524pfj.45.1450825547297; Tue, 22 Dec 2015 15:05:47 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tr2si7127515pac.112.2015.12.22.15.05.47; Tue, 22 Dec 2015 15:05:47 -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 S934076AbbLVXFq (ORCPT + 4 others); Tue, 22 Dec 2015 18:05:46 -0500 Received: from mail-lb0-f169.google.com ([209.85.217.169]:33957 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932485AbbLVXFq (ORCPT ); Tue, 22 Dec 2015 18:05:46 -0500 Received: by mail-lb0-f169.google.com with SMTP id pv2so52643452lbb.1 for ; Tue, 22 Dec 2015 15:05:45 -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=GwyiGKfwG8KWr40rTBous1WDc6n0zmWbz9/khe4N7SU=; b=R99w7J18K7aT8XUEJ6nx61Z4/rnbPwiXPSM+qrh7y8ORbNEsnFyEWDreRRH3WeW/Wc lDPSLLyW8ipEZWMTbhkSQykQYWHN7BJH48YYKNIoL4izMZSnzLqXm+KPA5j4+puHy/14 1XUdWAYFIbkjaBMYyxozDEo+CqtTWb0xXAyP8= 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=GwyiGKfwG8KWr40rTBous1WDc6n0zmWbz9/khe4N7SU=; b=mlQSKxax8CWETcLfj7tLqLKwL3zRYwBDM3OA56mHwLMeuJFvyy8vWXsfNvYxqLU/cc xsHEpHvh7C+YmI5uMmt9FL1+VHuqWWbCJrrxEL1o2k0l0u0dacx8UhT//qofCIfwGqto /XwrVrdH8uL9tZLDBpvzs12RkA8TvdPN8LRkSW+AmLp2i7/enKMXAyQvJ22oU4G/IcbP ydo5Dim5eV7ocZXg5ecR9e+JDNDRTDEOH9qKhGT5U8h4yCvlGfJ0STTo1EKEpo+RhA4V 2+T6rLcTr+1SupamTAbenNByN6eDdUVHhyh/aqF0qxSTUV9n6/uI9J8HTnV38DNnlGrb zEJA== X-Gm-Message-State: ALoCoQlDYcoRiINt+UbtnSy4Yqey9xIwJS9esuUgB9hH6/Oy+TZLOuEcbQ9Zcm7sYNE8691DckXJ/51AKyr4bzYTMcb1eoeapw== X-Received: by 10.112.198.131 with SMTP id jc3mr4428919lbc.118.1450825544422; Tue, 22 Dec 2015 15:05:44 -0800 (PST) Received: from localhost.localdomain.localdomain (c-297471d5.01-192-6c756e10.cust.bredbandsbolaget.se. [213.113.116.41]) by smtp.gmail.com with ESMTPSA id l138sm6184600lfe.47.2015.12.22.15.05.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 15:05:43 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Lee Jones , Paul Parsons Cc: Linus Walleij Subject: [PATCH 45/54 v2] mfd: asic3: Be sure to clamp return value Date: Wed, 23 Dec 2015 00:05:36 +0100 Message-Id: <1450825536-8830-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 --- ChangeLog v1->v2: fixed a compilation issue, I was hammering to much on parentheses sorry. --- 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..927e2c2a9a39 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,