From patchwork Tue Dec 22 14:40:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58910 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3275938lbb; Tue, 22 Dec 2015 06:40:37 -0800 (PST) X-Received: by 10.98.72.203 with SMTP id q72mr36100345pfi.55.1450795237271; Tue, 22 Dec 2015 06:40:37 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id up8si3697670pac.111.2015.12.22.06.40.36; Tue, 22 Dec 2015 06:40:37 -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 S932633AbbLVOkf (ORCPT + 4 others); Tue, 22 Dec 2015 09:40:35 -0500 Received: from mail-lb0-f182.google.com ([209.85.217.182]:34656 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932547AbbLVOkc (ORCPT ); Tue, 22 Dec 2015 09:40:32 -0500 Received: by mail-lb0-f182.google.com with SMTP id pv2so46223003lbb.1 for ; Tue, 22 Dec 2015 06:40:32 -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=ti+yH1KIw5N2AgY1Id5bmyFlHBdjzzI3lBMCNNPO3Z0=; b=GsYdXXaUW/i8Tk6v7k5cHYozacOaG/MVDvEzcI6eYq8srREkU39aZgO2qOs95FbZeM bVurmy+8/hxIpLAC3QYimLMvsh9P04lXPxNe3fd3LqoVB3FAY3NZGQPpWotLkvDu4/+p A8r+cVHd00cbb5C5OmvtMopnKLBJI9Z6lB3Ak= 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=ti+yH1KIw5N2AgY1Id5bmyFlHBdjzzI3lBMCNNPO3Z0=; b=IWesrZdKaoT1va5C3mJV/3oC4rA7z07w71vridQ5ZmMNnpU3kWG2VyAPwDqZNgMUuf Wl0+M9ZBF5KfK0gh7lFDT6eGJQmC9xrVGeqsU3KtZhTcMcg60zpauFuRyze5Dq519L6+ Msiso3iofBCLB38tZlrPF5Hb7EVqV3d8Zxu4P/WAxk0IrkYix9fIAwb1yteIBfpY2Zfz xo7NPdgSJ1VJrBVlh4EHprxyKyKHvFarxzfKD6NOKTudJ3RsVOUm/Ucu+xt0ezbdnobK uuVWiIfoK+yahOdjvxgX2TRwycEQ5yd3m2WVKpagcKp3OjiMuFfl1f7PIPY1meTUEgpV vpFA== X-Gm-Message-State: ALoCoQkU/Tn7da7RJgEXVxw9wYp/zeZamXV5A20DZECUm/0w18WLeDS/IH3w/e0f260DInFYWDxKd4+xX22/scsjbYlmKq22wA== X-Received: by 10.112.161.228 with SMTP id xv4mr8958226lbb.60.1450795231512; Tue, 22 Dec 2015 06:40:31 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id pd9sm5726524lbc.48.2015.12.22.06.40.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:40:30 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, linux-mips@linux-mips.org, Ralf Baechle Cc: Linus Walleij , Alban Bedel Subject: [PATCH 37/54] mips: ar7/gpio: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:40:27 +0100 Message-Id: <1450795227-27411-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: linux-mips@linux-mips.org Cc: Alban Bedel Cc: Ralf Baechle Signed-off-by: Linus Walleij --- arch/mips/ar7/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/mips/ar7/gpio.c b/arch/mips/ar7/gpio.c index f4930456eb8e..f969f583c68c 100644 --- a/arch/mips/ar7/gpio.c +++ b/arch/mips/ar7/gpio.c @@ -37,7 +37,7 @@ static int ar7_gpio_get_value(struct gpio_chip *chip, unsigned gpio) container_of(chip, struct ar7_gpio_chip, chip); void __iomem *gpio_in = gpch->regs + AR7_GPIO_INPUT; - return readl(gpio_in) & (1 << gpio); + return !!(readl(gpio_in) & (1 << gpio)); } static int titan_gpio_get_value(struct gpio_chip *chip, unsigned gpio)