From patchwork Tue Dec 22 14:43:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58916 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3277685lbb; Tue, 22 Dec 2015 06:43:50 -0800 (PST) X-Received: by 10.98.44.213 with SMTP id s204mr18351104pfs.1.1450795430636; Tue, 22 Dec 2015 06:43:50 -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.43.50; Tue, 22 Dec 2015 06:43:50 -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 S1753986AbbLVOnt (ORCPT + 4 others); Tue, 22 Dec 2015 09:43:49 -0500 Received: from mail-lb0-f175.google.com ([209.85.217.175]:34053 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752917AbbLVOnt (ORCPT ); Tue, 22 Dec 2015 09:43:49 -0500 Received: by mail-lb0-f175.google.com with SMTP id pv2so46271909lbb.1 for ; Tue, 22 Dec 2015 06:43:48 -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=xIAP5sIku4Z7Mahg5L+083Fz5bq51aARW0fX0w21U+8=; b=GbYrdnAY0uZ7Dbu1Q5ifEsa31t3rCCJOvNsPFhM0JK5VW3bspdXzQRhNeQoj/3Y9I0 IRSCGitg15Zm6X+juCJLcIpMnQAjyIOuV5vU6REW03a96QSz6cSbCF1YDs8yi/H/5rwE 0TqRd5fjKLAnQ3m4l4g+OPt0grEPuCi7PgBsk= 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=xIAP5sIku4Z7Mahg5L+083Fz5bq51aARW0fX0w21U+8=; b=B8bdjcQfIfu77W6MeaUc/iKz3P7VazExb+TzqASLewaEGRVRYnBLj+JDbRkidiMr6s XLXH4Sd2yaknKz4y2zx+mDdBasPcpp9LRj79mffs4qujiOJ/6Ad3nFTJq+RUn3V4LqiG hzzduzr/j85ysL2+SsS+JC/LikhFYBmrn3DrCazl1WEbJWkbQS19mw+b8x8TxDMCxCvS +jZLckWeUyniDdRAk/xxaO4Ym0ArjYTvtgdCPGfmwHb9qy9Yp8z24XylrjGd2qflA7BO pqrsulP+EqYZZug+dTtUtnKj6T7qbK5ytgoj+ULzQf5jbnwN+EmphUQaqKWbFug45/NH ZMdA== X-Gm-Message-State: ALoCoQliFcqKImLHUqDI3ruOJ8Mtw+S9Prnf783J5xX0J1f+XQHMSF1WTdLxVGR5Aoj3lj4RPZJo5CDQmCKLHjbU8yFi9LCn3w== X-Received: by 10.112.136.103 with SMTP id pz7mr1649091lbb.3.1450795427979; Tue, 22 Dec 2015 06:43:47 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id d2sm5735071lbc.11.2015.12.22.06.43.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:43:47 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Anatolij Gustschin , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: Linus Walleij , Anton Vorontsov Subject: [PATCH 43/54] powerpc: simple_gpio: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:43:43 +0100 Message-Id: <1450795423-27756-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: Anton Vorontsov Cc: Anatolij Gustschin Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Signed-off-by: Linus Walleij --- POWERPC folks: as mentioned in 00/54: either apply this directly or ACK it and I will take it into the GPIO tree. --- arch/powerpc/sysdev/simple_gpio.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/arch/powerpc/sysdev/simple_gpio.c b/arch/powerpc/sysdev/simple_gpio.c index ff5e73230a36..56ce8ca3281b 100644 --- a/arch/powerpc/sysdev/simple_gpio.c +++ b/arch/powerpc/sysdev/simple_gpio.c @@ -46,7 +46,7 @@ static int u8_gpio_get(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); - return in_8(mm_gc->regs) & u8_pin2mask(gpio); + return !!(in_8(mm_gc->regs) & u8_pin2mask(gpio)); } static void u8_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)