From patchwork Tue Dec 22 14:27:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58895 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3268742lbb; Tue, 22 Dec 2015 06:28:00 -0800 (PST) X-Received: by 10.66.120.200 with SMTP id le8mr36000687pab.61.1450794480019; Tue, 22 Dec 2015 06:28:00 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ez9si4868056pab.20.2015.12.22.06.27.59; Tue, 22 Dec 2015 06:27:59 -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 S932793AbbLVO17 (ORCPT + 4 others); Tue, 22 Dec 2015 09:27:59 -0500 Received: from mail-lb0-f178.google.com ([209.85.217.178]:36809 "EHLO mail-lb0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932294AbbLVO16 (ORCPT ); Tue, 22 Dec 2015 09:27:58 -0500 Received: by mail-lb0-f178.google.com with SMTP id oh2so31973942lbb.3 for ; Tue, 22 Dec 2015 06:27:58 -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=B/7sSKUK3f+bTBntDhD7X5bBWKWjFrkK2RBFRi39enE=; b=kNOgv2FY5DVGFW+95tXYPUEymW+2z7mnuanGnHCiG346t7vLwVhpUggzAc4xhpku6P icOPWmrT6v9afwttsh9Kcece3iP98pTm2pou+rKsvN1c+2WBeOzXbc5Ho4oaAB7u6jn0 GCqvtHjD3MIzM1YwBUjl18JPRsyjT88q0wV34= 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=B/7sSKUK3f+bTBntDhD7X5bBWKWjFrkK2RBFRi39enE=; b=e7LOL9A/8sZWDrFCLaj0L2vTybwHC5M6bsAGcwzg1aYhMD6kRuqSSqICuREjgiv9bf 2oFwSJL1YRxDF6kRcQQfIpsFXBHLUASI+2i5ExA8VLUHA8mHI+F31H3XO7OHBnqjzo8w pjoiBJhZTURzq5/pHmIfTTP13Fe/n9q865z+vqMSSPs7MGGk75q4yiiQI8gsAhOMe7rF thNhBbSAMlKWEfe+0InhNI44vbHcVP0LILKSObIL/be44+7SXB+/V/UumDHEahr9tdrB CFH92nAbrukNel/U8AmfiLAy8i6uJB9s1IiA4BEV91W1O2RjSkPYKlH+wpeKmSeFKvE1 zpww== X-Gm-Message-State: ALoCoQkKRvMSuh1vxYc3OwivCadEc1tGTftlHw9oRjt7yYzXMoF5Ap3UTKRJFh0gk771w4DRPA8QNF2n11nvsdTkQMp+swC+Pg== X-Received: by 10.112.50.134 with SMTP id c6mr8749945lbo.14.1450794477339; Tue, 22 Dec 2015 06:27:57 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r2sm5777550lfe.28.2015.12.22.06.27.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:27:56 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Linus Walleij Subject: [PATCH 22/54] gpio: ucb1400: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:27:54 +0100 Message-Id: <1450794474-23525-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. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ucb1400.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-ucb1400.c b/drivers/gpio/gpio-ucb1400.c index d502825159b9..cca78fb9b0df 100644 --- a/drivers/gpio/gpio-ucb1400.c +++ b/drivers/gpio/gpio-ucb1400.c @@ -33,7 +33,7 @@ static int ucb1400_gpio_get(struct gpio_chip *gc, unsigned off) { struct ucb1400_gpio *gpio; gpio = container_of(gc, struct ucb1400_gpio, gc); - return ucb1400_gpio_get_value(gpio->ac97, off); + return !!ucb1400_gpio_get_value(gpio->ac97, off); } static void ucb1400_gpio_set(struct gpio_chip *gc, unsigned off, int val)