From patchwork Tue Dec 22 14:18:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58884 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3263625lbb; Tue, 22 Dec 2015 06:18:57 -0800 (PST) X-Received: by 10.67.6.1 with SMTP id cq1mr35604173pad.78.1450793937041; Tue, 22 Dec 2015 06:18:57 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 70si13680372pfo.185.2015.12.22.06.18.56; Tue, 22 Dec 2015 06:18:57 -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 S1753452AbbLVOS4 (ORCPT + 4 others); Tue, 22 Dec 2015 09:18:56 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:35110 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753341AbbLVOSz (ORCPT ); Tue, 22 Dec 2015 09:18:55 -0500 Received: by mail-lf0-f49.google.com with SMTP id l133so129629407lfd.2 for ; Tue, 22 Dec 2015 06:18:55 -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:mime-version:content-type :content-transfer-encoding; bh=8CvVPR2+0IWT06FKp7rNgJIh5O3GxuhzBFKT/3+r2ps=; b=NQC3ce70Apqs8HbI4wTpdCsA1wFYBDJZ2G24ELsob6ciOq3l1H3zpeuZxXNy44aaId 3RcYKoqDiXmhf83SFUEkxbW/vE/4tZu1UhvKeZECYepfR2413lfsH0dsgOsUkmw2mQCO xR78WBfcqzOqebXqDb/jIYqG22OhVIl3DdF+o= 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:mime-version :content-type:content-transfer-encoding; bh=8CvVPR2+0IWT06FKp7rNgJIh5O3GxuhzBFKT/3+r2ps=; b=idZ8ebLmuCZ8nMOjXyf7kOqZXG5jYuhN3H6uRmvAZUvkEPSFYOyCaX2jw+sYz0q9ax pBdAedqRnnb1JZPcfhVH4ucfiNsiRIvpWquXl3uVOwW29xcelCtySzGn1YCE49ilHhkV y8GYS08WX1x+jrRTpoflJU10ZDdxswuEiKofgQ9EErazKeVfwFvcvjHX8eyuwEkFhDok Wa2jfL7suxFcSCOgnBYMQ/EKxZVqvcADIc3bW53IyDE/ZSpbyLzs8IWiHNtkqc1nurw8 n8P7DgrTqPc2OFuXcINpdHLdcmP0jGE7xsqCfDNWOqMmh3YG7eS/4UqUvKux1o68D7G8 Ewug== X-Gm-Message-State: ALoCoQnUHNvbV2D08opxuwtLNVOgdm81RJ02RcfwAtq7nX0Lfg2xxTpfiuPMAr03GI7P/oQGIvHOn/um/8aQmND+WZXTNRUaAw== X-Received: by 10.25.138.68 with SMTP id m65mr8475972lfd.69.1450793934443; Tue, 22 Dec 2015 06:18:54 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id x13sm5842126lfd.7.2015.12.22.06.18.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:18:53 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Alexander Stein Cc: Linus Walleij Subject: [PATCH 11/54] gpio: mpc8xxx: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:18:51 +0100 Message-Id: <1450793931-22741-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 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: Uwe Kleine-König Cc: Alexander Stein Signed-off-by: Linus Walleij --- drivers/gpio/gpio-mpc8xxx.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-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index 48ef368347ab..de4cd22a5014 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -79,7 +79,7 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio) val = in_be32(mm->regs + GPIO_DAT) & ~out_mask; out_shadow = mpc8xxx_gc->data & out_mask; - return (val | out_shadow) & mpc8xxx_gpio2mask(gpio); + return !!((val | out_shadow) & mpc8xxx_gpio2mask(gpio)); } static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio)