From patchwork Tue Dec 22 14:11: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: 58876 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3258945lbb; Tue, 22 Dec 2015 06:11:14 -0800 (PST) X-Received: by 10.66.100.228 with SMTP id fb4mr34971247pab.84.1450793474723; Tue, 22 Dec 2015 06:11:14 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h87si19053310pfj.183.2015.12.22.06.11.14; Tue, 22 Dec 2015 06:11:14 -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 S1754315AbbLVOLL (ORCPT + 4 others); Tue, 22 Dec 2015 09:11:11 -0500 Received: from mail-lf0-f52.google.com ([209.85.215.52]:35872 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754287AbbLVOLG (ORCPT ); Tue, 22 Dec 2015 09:11:06 -0500 Received: by mail-lf0-f52.google.com with SMTP id z124so125168002lfa.3 for ; Tue, 22 Dec 2015 06:11: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=neUzeQ1dBINKvob0RWb6Mzs7eAhhwvaik/F3MosBD7Y=; b=DmazeaZ9p9knSk5g9VXnUPDdE0xbcbqyduRAdKgMvr6YXgU7RM3ebtO8rLgQnKQWA5 6cQtzYAILQWN9xFJ14ml7lcIPDSw83xZLX5qRdI6enyJvA2xnPq3NfJf3nsywonhf4/r RLqiTP4ziMpTEs97EUXTTEII3aL8VidniqWnA= 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=neUzeQ1dBINKvob0RWb6Mzs7eAhhwvaik/F3MosBD7Y=; b=QJMxxgUtUnvQ8z535GeQrU2e+R/HZLlX3KBo+u70ZzOPZ1Av70UD6tNF4V0S71D43T p/i2Eej9h4+oWhvt91oTH1hz1vc93ANHkdqc60jqPZSy8XFOOJKsFZYLID5Gt02VdkYf lSBZCeK03FD4FegsYUHPsz5UjrtIDZK8k3rEwqAHwLzBzNWfFXbEWRCe/DjnRpnwPSLg JkJc3HgqapCBo6oy5yhid6DovzM34kglr4SUfNpSE4hNMpmNFoKH5BGKjKM+Ki3P0Qmh JVE1XtyySwRUJ8S2dzqWkUnplxnk5Ecq61nbEvNHtjz4w5oknRgBAi39D9WGstJuK6mn InTg== X-Gm-Message-State: ALoCoQms3p+z7pc0h2HHwShoHmAK75sXIJAbP+FXw/q9NMuZn2+7jxmnHTSX5oCmf3ECcYupIFe3/btBGGZDPRJSMTC70jSaig== X-Received: by 10.25.151.69 with SMTP id z66mr6964136lfd.122.1450793464594; Tue, 22 Dec 2015 06:11:04 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m75sm5752225lfg.15.2015.12.22.06.11.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:11:03 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Geert Uytterhoeven , Magnus Damm Cc: Linus Walleij Subject: [PATCH 03/54] gpio: em: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:11:01 +0100 Message-Id: <1450793461-21934-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: Geert Uytterhoeven Cc: Magnus Damm Signed-off-by: Linus Walleij --- drivers/gpio/gpio-em.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-em.c b/drivers/gpio/gpio-em.c index c3ca2b1c1dfe..d726c68c4a65 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c @@ -203,7 +203,7 @@ static int em_gio_direction_input(struct gpio_chip *chip, unsigned offset) static int em_gio_get(struct gpio_chip *chip, unsigned offset) { - return (int)(em_gio_read(gpio_to_priv(chip), GIO_I) & BIT(offset)); + return !!(em_gio_read(gpio_to_priv(chip), GIO_I) & BIT(offset)); } static void __em_gio_set(struct gpio_chip *chip, unsigned int reg,