From patchwork Tue Dec 22 14:11:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58877 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3259214lbb; Tue, 22 Dec 2015 06:11:40 -0800 (PST) X-Received: by 10.98.74.5 with SMTP id x5mr8200523pfa.102.1450793500205; Tue, 22 Dec 2015 06:11:40 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 86si33061553pfs.88.2015.12.22.06.11.39; Tue, 22 Dec 2015 06:11:40 -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 S1754353AbbLVOLj (ORCPT + 4 others); Tue, 22 Dec 2015 09:11:39 -0500 Received: from mail-lb0-f173.google.com ([209.85.217.173]:34138 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753041AbbLVOLi (ORCPT ); Tue, 22 Dec 2015 09:11:38 -0500 Received: by mail-lb0-f173.google.com with SMTP id pv2so45780254lbb.1 for ; Tue, 22 Dec 2015 06:11:37 -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=1D1tijUTS2tahFVWpD6fJUg2QSD/3lZDBIpoeXQrezA=; b=SfMIE/QmmfwBq4ARFeYgAythOZ2+lc7JTI0GkRgsDbC8+/N5eCY9ZZ3L9EYdezyFdk FYRW9aXmDANqvWco5ghPZqzdoEX0fNwohyIUB05j4nyYiyTUoGv02gjgrHRqI4d/xF0c QLSdVlsXtJ2i0+aRQAtzvQu/1wO6axycd4ISw= 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=1D1tijUTS2tahFVWpD6fJUg2QSD/3lZDBIpoeXQrezA=; b=AnQ7GwBOwIYZfIg0hekWx0CmT/oSVk0ib7HGdpE07+IwW7RNTdyBZRcv5Y4oEtrieu MRe4+Yt/VE4K535gJYnwmDBZvsO7sYZsvln6rz1HR6onzZB28mwzuTJAE/8g00BDTsE5 AutvH6e40dcqHUPwKV5cx7qn6jt5g5eGOZ0JPNRwUliBSiYRHUUntyvrd3ERdInlow3R yv/k2zZ7mhGEDDfQ28iUng/wy4/WFvo/A7MEaEG9G9l7kL3vSccCPCkK0owQnGfbDqXj TDKm8lc23LqEz3KdsFKFKHHBZVProAKHW2JbrKp/RZ/sFG1RO5Xn+t0eCh8WvqLoj1Du 7SWQ== X-Gm-Message-State: ALoCoQl+f9k+riYiWY9d78dAEBkfS1KNt/qACfLIHWLpGw8DPLGyooBxNvhuxy28YWHqtvt8w160eDZiBgXrWCXUBjG+tYj1LA== X-Received: by 10.112.55.97 with SMTP id r1mr8383322lbp.117.1450793497249; Tue, 22 Dec 2015 06:11:37 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l67sm2025583lfi.2.2015.12.22.06.11.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:11:36 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Aaron Sierra Cc: Linus Walleij Subject: [PATCH 04/54] gpio: ich: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:11:33 +0100 Message-Id: <1450793493-21995-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: Aaron Sierra Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ich.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 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-ich.c b/drivers/gpio/gpio-ich.c index 8623d12e23c1..68e525a3cea3 100644 --- a/drivers/gpio/gpio-ich.c +++ b/drivers/gpio/gpio-ich.c @@ -236,9 +236,9 @@ static int ich6_gpio_get(struct gpio_chip *chip, unsigned nr) spin_unlock_irqrestore(&ichx_priv.lock, flags); - return (data >> 16) & (1 << nr) ? 1 : 0; + return !!((data >> 16) & (1 << nr)); } else { - return ichx_gpio_get(chip, nr); + return !!ichx_gpio_get(chip, nr); } }