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: 560102 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0DD42140313 for ; Wed, 23 Dec 2015 01:41:10 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=ESbhd40o; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752308AbbLVOlI (ORCPT ); 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(-) 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)