From patchwork Tue Dec 22 14:43:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58915 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3277518lbb; Tue, 22 Dec 2015 06:43:30 -0800 (PST) X-Received: by 10.66.141.109 with SMTP id rn13mr35470794pab.83.1450795410618; Tue, 22 Dec 2015 06:43:30 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qj4si4537557pac.33.2015.12.22.06.43.30; Tue, 22 Dec 2015 06:43:30 -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 S1753677AbbLVOn3 (ORCPT + 4 others); Tue, 22 Dec 2015 09:43:29 -0500 Received: from mail-lb0-f180.google.com ([209.85.217.180]:32865 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752816AbbLVOn3 (ORCPT ); Tue, 22 Dec 2015 09:43:29 -0500 Received: by mail-lb0-f180.google.com with SMTP id sv6so25432206lbb.0 for ; Tue, 22 Dec 2015 06:43:28 -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=6+ErQNsPe0hzdPs9p+2xWKkfVZ3iIEAph2FE9oksvxU=; b=CgxQGHjCd6iLJ+eYqTpG1ZY25oQccyUmQ9434hS8WinzwAd4veXKjAOcKURCODW3q+ CwFQNktdu8u6iG5Bm2iYNrJYjlORp1KGhXRbJ/WzVkoDrx9qP5AKlBAujusCKyq3vtgE 8zD99NM6Fq1ihW+pieb28vSxQgaH+GtBAQ2UI= 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=6+ErQNsPe0hzdPs9p+2xWKkfVZ3iIEAph2FE9oksvxU=; b=dnF1Rr6MaxscmvO6VCUdeu4fbjgba47+j++HqydzELcokm5lptE2ta4OTRC6dSmCAa qF3SKj0IF9V+pQh3P3e1MFUp5F4r5GZQhnBhdLSYL2m3ojTFF61POiPK1yQEoFZ1tHWe dsEFYvSyj86PZYWkLRAlNcWXlhw4UIh982YOwd7Z+SmjoIZlWRTw4SRc9UyrRUW3qjx4 yDT4DoZHNkjG0I+2UfgvUYa6J+0ImR1JDz6dipi2lTJ8/k3kTwHh38Ghc7nBbbzVHBMm DwoWtKUQoX1PU/eqsV6hRqUJGEr8gzQuC1uLWib65LnChDWx4XS0hElpvRSBUp0MX3yP 949g== X-Gm-Message-State: ALoCoQnYqwXaGEFnL7YO/+QItJHdqWwzfjG2ugx/A7XkdMYehwbZ+iJJusXqxBts2H20DCSfeYlN5onapC/DNMl7BEkIR9WrGg== X-Received: by 10.112.63.68 with SMTP id e4mr8468310lbs.130.1450795407972; Tue, 22 Dec 2015 06:43:27 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id eb3sm197806lbc.31.2015.12.22.06.43.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:43:27 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Anatolij Gustschin , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: Linus Walleij Subject: [PATCH 42/54] powerpc: qe_lib/gpio: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:43:24 +0100 Message-Id: <1450795404-27707-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: 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/qe_lib/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/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c index 521e67a49dc4..d950d409afde 100644 --- a/arch/powerpc/sysdev/qe_lib/gpio.c +++ b/arch/powerpc/sysdev/qe_lib/gpio.c @@ -63,7 +63,7 @@ static int qe_gpio_get(struct gpio_chip *gc, unsigned int gpio) struct qe_pio_regs __iomem *regs = mm_gc->regs; u32 pin_mask = 1 << (QE_PIO_PINS - 1 - gpio); - return in_be32(®s->cpdata) & pin_mask; + return !!(in_be32(®s->cpdata) & pin_mask); } static void qe_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)