From patchwork Tue Dec 22 14:20:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58886 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3264410lbb; Tue, 22 Dec 2015 06:20:16 -0800 (PST) X-Received: by 10.66.65.203 with SMTP id z11mr36023947pas.152.1450794016411; Tue, 22 Dec 2015 06:20:16 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qg5si3447886pab.45.2015.12.22.06.20.16; Tue, 22 Dec 2015 06:20:16 -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 S1754583AbbLVOUP (ORCPT + 4 others); Tue, 22 Dec 2015 09:20:15 -0500 Received: from mail-lf0-f52.google.com ([209.85.215.52]:33357 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754395AbbLVOUO (ORCPT ); Tue, 22 Dec 2015 09:20:14 -0500 Received: by mail-lf0-f52.google.com with SMTP id p203so131562216lfa.0 for ; Tue, 22 Dec 2015 06:20:13 -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=HDmLoduZVCNq/nXrDVcaq4iuTkhjmjWLdqku+LdNMd4=; b=LnRB4yMbEB5EOspUZVyXkLBBf0KnH6UPgsgz+sYmVNKv9JAb3NBTAYMz532qETuPmn xoEm+AWM8V+NHoTMInuKtbJ8fMFUwZjHyZRQkciEVxJbejJD5RFwu95eNzyvfoI6Ro3F VvgLP5gaVaI2Tq40fXg2DxnelPq0ZbnOTyBGQ= 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=HDmLoduZVCNq/nXrDVcaq4iuTkhjmjWLdqku+LdNMd4=; b=Z8QJqp7JkCBW2MuMOjtXNgaLdHcx8wbm8KXuTk/UBN7f+iqFsNwUahYjoQZeFCx/aX n1UMWzXQC+42mA664DAJSn/xZACI/W690kv5s9T1upo2wwniFJEwDkQNUaAiXTShIKzY MuN3OrG7ueB9AP5sOfopOrFP77ScekD9OOG/Z3CPveQggE2hq0wjfAQOOoGveJh7z/HU QnGPDZTuFRF7Iudgakq+ZpmDvRIGHdAhiz+HCem35BEfYID39frT9QI/hLwogkxTIB/R X4f4D9CE2A9QNxgDp2lQPt6W8jlbXX4sHxA63OqQ5uxzTb8akzHg68Cg6RmpN7qfa4I9 AOqw== X-Gm-Message-State: ALoCoQmIipVEY6gCQ6T2JQF5V0IGarHzbXnQOlb27iecrjL9YkL6MypgRm/FtJ+zqsCZ0gW7D8loK8aNQ2H8U+/iv/Gh/kn0BQ== X-Received: by 10.25.153.79 with SMTP id b76mr1233942lfe.102.1450794013111; Tue, 22 Dec 2015 06:20:13 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id k189sm5679163lfd.12.2015.12.22.06.20.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:20:12 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Grygorii Strashko , George Cherian Cc: Linus Walleij , Laurent Pinchart Subject: [PATCH 13/54] gpio: pcf857x: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:20:09 +0100 Message-Id: <1450794009-22885-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. Also start returning the error code if something fails, as the end of the series augment the core to support this. Cc: Grygorii Strashko Cc: George Cherian Cc: Laurent Pinchart Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pcf857x.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-pcf857x.c b/drivers/gpio/gpio-pcf857x.c index bf511c0efa48..f64380a7d004 100644 --- a/drivers/gpio/gpio-pcf857x.c +++ b/drivers/gpio/gpio-pcf857x.c @@ -154,7 +154,7 @@ static int pcf857x_get(struct gpio_chip *chip, unsigned offset) int value; value = gpio->read(gpio->client); - return (value < 0) ? 0 : (value & (1 << offset)); + return (value < 0) ? value : !!(value & (1 << offset)); } static int pcf857x_output(struct gpio_chip *chip, unsigned offset, int value)