From patchwork Tue Dec 22 14:24:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58893 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3266828lbb; Tue, 22 Dec 2015 06:24:33 -0800 (PST) X-Received: by 10.98.11.3 with SMTP id t3mr735757pfi.79.1450794273496; Tue, 22 Dec 2015 06:24:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xk9si4644477pab.38.2015.12.22.06.24.32; Tue, 22 Dec 2015 06:24:33 -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 S1754340AbbLVOYc (ORCPT + 4 others); Tue, 22 Dec 2015 09:24:32 -0500 Received: from mail-lf0-f48.google.com ([209.85.215.48]:34553 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753443AbbLVOYb (ORCPT ); Tue, 22 Dec 2015 09:24:31 -0500 Received: by mail-lf0-f48.google.com with SMTP id y184so130047557lfc.1 for ; Tue, 22 Dec 2015 06:24:31 -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=VNwIdS3B0p02IYi3hV8pBEU1IOg5jR22tCpTISyIl3M=; b=Zpk99hcjTGYbQwPVZXbcgP9k1jtPGJ3fGeD1e76O/DNEDgjXZYmzbepFF/XaZ7A0Bo vzWqd4D0OWmJftqA07tnEu5R760oN0FVrWC0+SHxe3fXeeVwK5f/6BM/wUIhuZMC/Fo3 seC9FP9DJn9MdU4PTpvNnB7xI9df055EZjKk0= 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=VNwIdS3B0p02IYi3hV8pBEU1IOg5jR22tCpTISyIl3M=; b=TIdVh8GzzFoKQokRtuX96AyabY0uUOkQmIdusu78RvaNdChnxkRLuhtFY8YiAJa4ft yGNLdexPuQjmVPVcI3ebrFspg6qTW8lZjeCGHH8tUs1WQ/PKDQ002o+nK0Kw/HbWrIya Qdiyle1/SwonAUMfNzqEohz+vvUdEUM9B+PvQ6oQ/0aqYk6xGNKM1RWsDbbqcucxe4sg NXb8l5snHpMffafEkNIdrSQvqKnGMZKqlIsG51MGfXEboDTCe8MaVZRgt4ioHwfC4kDj 008ResLEoQIF/z1WaebfCM/u8ttWZ7YpC6ZX+0ZYWgiL57Ket1PU9/SdBqV5Tz9x7m3n by9Q== X-Gm-Message-State: ALoCoQn4v1UVX7zQdiszH5o9jj6b0iY9TaNoNEnPim4kQ5XvamjjwqeG8TQhG7MVK1X3fKJy5HVHGdfdLNkCh4jMEreKBho6bA== X-Received: by 10.25.162.144 with SMTP id l138mr8350382lfe.30.1450794269883; Tue, 22 Dec 2015 06:24:29 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id zm10sm5758381lbb.49.2015.12.22.06.24.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:24:29 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, James Hogan Cc: Linus Walleij Subject: [PATCH 20/54] gpio: tz1090: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:24:26 +0100 Message-Id: <1450794266-23370-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: James Hogan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tz1090.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/drivers/gpio/gpio-tz1090.c b/drivers/gpio/gpio-tz1090.c index 79ef6e1ce568..a4a822542ac1 100644 --- a/drivers/gpio/gpio-tz1090.c +++ b/drivers/gpio/gpio-tz1090.c @@ -214,7 +214,7 @@ static int tz1090_gpio_get(struct gpio_chip *chip, unsigned int offset) { struct tz1090_gpio_bank *bank = to_bank(chip); - return tz1090_gpio_read_bit(bank, REG_GPIO_DIN, offset); + return !!tz1090_gpio_read_bit(bank, REG_GPIO_DIN, offset); } /*