From patchwork Tue Dec 22 14:41:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58911 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3276230lbb; Tue, 22 Dec 2015 06:41:10 -0800 (PST) X-Received: by 10.98.67.74 with SMTP id q71mr35198361pfa.134.1450795269873; Tue, 22 Dec 2015 06:41:09 -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.41.09; Tue, 22 Dec 2015 06:41:09 -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 S1752308AbbLVOlI (ORCPT + 4 others); Tue, 22 Dec 2015 09:41:08 -0500 Received: from mail-lb0-f172.google.com ([209.85.217.172]:32826 "EHLO mail-lb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752413AbbLVOlG (ORCPT ); Tue, 22 Dec 2015 09:41:06 -0500 Received: by mail-lb0-f172.google.com with SMTP id sv6so25395819lbb.0 for ; Tue, 22 Dec 2015 06:41:05 -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=MfSEB722wOd40uCF76eY9sTMLwL/w+YOOIsha1ZZv9s=; b=ESbhd40ormPuGenfQP5ucHVw3u8pTHIMIJfXbd25XHvViu9f2b6F2INYeukQZ3ozZE E+PHDW1qQG8+unSs8vv//kp2vVQQn7IC8VPzw3EaCpwMwsOH7yMVO0sHh/wK3UOkW7B7 s13vtMmhvWHklWUYWDZ6/vbkH8bDHQuFBD1dM= 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=MfSEB722wOd40uCF76eY9sTMLwL/w+YOOIsha1ZZv9s=; b=ip/jnwQ88EQ97JDTul+7se5qePv1ti7SPYgtxVQQfOlBm888JU6g9ARE6fdKxblg9n 5Og2nkBLFTPhxHPxhyeH4J6CUGufUSqztwGIdfiJTld06ZUldiq5619ktMCMsKqe87GJ 4+uvLIZM1F6p/ZlpZwNA5FB8V61B1wB6XjiCrrxxc0ui0RDN2eLfacKvu0gkJn592c4I er/wY6grVbkFrsiF/yS/rM8RVfAUOvOaQQVpooqHSaSqNG5GL2CGGho5gw/9OWOAKnIj +6w7mbHvTCN1O3oQhJG4R/OdOS/7wMnQ0B6n7dIj3+cBYLURC6eVPtSAX2Bvu0sdDY/A VDQw== X-Gm-Message-State: ALoCoQk/2KM3Is9zeyUEX2Ct1hCxoEeQ5lYASJcJ9G7Y+3sUQr/cU0dM1IZzjCAv9iCf2JFP/QkHzFsY/ynllaobeIOh7gH0JA== X-Received: by 10.112.219.197 with SMTP id pq5mr7195129lbc.73.1450795264732; Tue, 22 Dec 2015 06:41:04 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id p1sm3400546lbo.30.2015.12.22.06.41.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:41:04 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, linux-mips@linux-mips.org, Ralf Baechle Cc: Linus Walleij Subject: [PATCH 38/54] mips: txx9: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:41:01 +0100 Message-Id: <1450795261-27465-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: Ralf Baechle Signed-off-by: Linus Walleij --- MIPS folks: as mentioned in 00/54: either apply this directly or ACK it and I will take it into the GPIO tree. --- arch/mips/kernel/gpio_txx9.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/kernel/gpio_txx9.c b/arch/mips/kernel/gpio_txx9.c index c6854d9df926..705be43c3533 100644 --- a/arch/mips/kernel/gpio_txx9.c +++ b/arch/mips/kernel/gpio_txx9.c @@ -21,7 +21,7 @@ static struct txx9_pio_reg __iomem *txx9_pioptr; static int txx9_gpio_get(struct gpio_chip *chip, unsigned int offset) { - return __raw_readl(&txx9_pioptr->din) & (1 << offset); + return !!(__raw_readl(&txx9_pioptr->din) & (1 << offset)); } static void txx9_gpio_set_raw(unsigned int offset, int value)