From patchwork Tue Dec 22 14:42:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58914 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3277340lbb; Tue, 22 Dec 2015 06:43:12 -0800 (PST) X-Received: by 10.66.216.73 with SMTP id oo9mr36211435pac.148.1450795392286; Tue, 22 Dec 2015 06:43:12 -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.12; Tue, 22 Dec 2015 06:43:12 -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 S1753724AbbLVOnL (ORCPT + 4 others); Tue, 22 Dec 2015 09:43:11 -0500 Received: from mail-lf0-f42.google.com ([209.85.215.42]:36617 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752855AbbLVOnK (ORCPT ); Tue, 22 Dec 2015 09:43:10 -0500 Received: by mail-lf0-f42.google.com with SMTP id z124so125729021lfa.3 for ; Tue, 22 Dec 2015 06:43: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=76A59mt7+ggweyeay6eZeELvVjMHif6ucF1hUSoAwec=; b=gZzniJtd/XVr90ujJ+iEWs4yZ7i3dRNY23pdYs3gFLBGkUqptJgCaOa9ynE33GzKM6 UJ7C592gjjrZeyViZ/RhTlFGRNp/rh79MAwrYYQgmuTsVqpyTkmIeimInrhcVlG6vV7q Sa576g3eG1w3bezGc9I5dbiOXD1iuRIaQGGHM= 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=76A59mt7+ggweyeay6eZeELvVjMHif6ucF1hUSoAwec=; b=CK67HkIp+yx03dIvq9MxKB7KBQbzulme5PGvZ2j7NE0p/9ojdmq5FgsUSMEkgviSFJ JNVraWACn+QyTOuKh6ZoWygnUuiFuzLgNWtfRsVjlGFmORm+BpBPPfRRA0zTeBQx1Gri wmiZ1PMGUVNtia6qo/4GTvxClT+xgb8wOwR72b5pzFHKOVyUNTyLE+iLlHdAaQ8IBodP wjWAqqVMirzMG+BSPmd3+8EVDnEMy1KujllIkMoKfAcJmDiQ2qrtcXFXDcNwHGG7tmD4 ynAw0zOKhT5Z1ncu1be0l6VFr287eYR62ndvtGeP/Ka1ShWWgZxRk+0MWnTQkwBI/QXt ew3A== X-Gm-Message-State: ALoCoQm8T/m3pw/9EZVNvhremf7/hc2JTpnU+uPYKtr5NCPZ7aB4KjICqiCqG6h+yMgAfNiRzrxKMmHBLo6Tu74mAMFXAPG/uQ== X-Received: by 10.25.86.9 with SMTP id k9mr8897576lfb.36.1450795389286; Tue, 22 Dec 2015 06:43:09 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id xn8sm5757034lbb.41.2015.12.22.06.43.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:43:08 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Anatolij Gustschin , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: Linus Walleij Subject: [PATCH 41/54] powerpc: ppc4cc/gpio: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:42:58 +0100 Message-Id: <1450795378-27657-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/ppc4xx_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/ppc4xx_gpio.c b/arch/powerpc/sysdev/ppc4xx_gpio.c index fc65ad1b3293..d7a7ef135b9f 100644 --- a/arch/powerpc/sysdev/ppc4xx_gpio.c +++ b/arch/powerpc/sysdev/ppc4xx_gpio.c @@ -78,7 +78,7 @@ static int ppc4xx_gpio_get(struct gpio_chip *gc, unsigned int gpio) struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct ppc4xx_gpio __iomem *regs = mm_gc->regs; - return in_be32(®s->ir) & GPIO_MASK(gpio); + return !!(in_be32(®s->ir) & GPIO_MASK(gpio)); } static inline void