From patchwork Tue Dec 22 14:14:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58882 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3260780lbb; Tue, 22 Dec 2015 06:14:16 -0800 (PST) X-Received: by 10.66.254.100 with SMTP id ah4mr23475844pad.121.1450793656025; Tue, 22 Dec 2015 06:14:16 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fc7si4639946pab.144.2015.12.22.06.14.15; Tue, 22 Dec 2015 06:14: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 S1754072AbbLVOOP (ORCPT + 4 others); Tue, 22 Dec 2015 09:14:15 -0500 Received: from mail-lf0-f53.google.com ([209.85.215.53]:34879 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753860AbbLVOOO (ORCPT ); Tue, 22 Dec 2015 09:14:14 -0500 Received: by mail-lf0-f53.google.com with SMTP id l133so129549187lfd.2 for ; Tue, 22 Dec 2015 06:14:14 -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=LVxBz+YNqffk2jAetoaya6T6VidTkOLI4qwpE5vc6Tw=; b=RZ12WQTOk7TSJfbDPY5eOdttuNDDecMz9xzM2V6504nW9rJO4qnXJG6nKRaJmbWKFR P3cnR6mvnc3CAEddJZEnAOazRek3/r2LcyGtoGjMa3ve8oTsbWok6Afrt6ad+3r3yQKo bMrGZ7Tsy6FEOfad0BxZCH3oKfqsy00hr5MPg= 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=LVxBz+YNqffk2jAetoaya6T6VidTkOLI4qwpE5vc6Tw=; b=HbBG5ZhLYx5oGIBQBpdssmTa3SZEwj7cFdWiKbx6pWajcLgGRdJMcdkduX1H3ZolGY mSEJ9PR0FZ6TTnEDIZ5LheaVt6Fh+nfvmdiqQyu+/uQoVidl98a/yyxGeoBysXC8fV5C DY8EkdNXoBRSDwChtF1Ua6bA9o/OvTADvQDcUvqO5WYjsnIl/8famOuza8hZh6ehb9WF kMvgXZ+MofZgMV25KrINfUQYIJPCQznLw5c441s0Sw+6RIQ0MP7FqWzIqIiTQSdBZrBH LszNfvt3WIOCSsOz869BzXcIgkfhgi1/AR6fMt34APSjEojkfS5EfHAyer+PQZQa5oj6 HZhw== X-Gm-Message-State: ALoCoQlJsASOru4uFnzrrg9ucRXHj4yC+x5iBkaBkx9CseH4LwmJFeyZZ/h04mFpoxyg2HtgCRscT9BJbRRQy6wb67jHiXGzaA== X-Received: by 10.25.141.70 with SMTP id p67mr8800637lfd.151.1450793653464; Tue, 22 Dec 2015 06:14:13 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id q8sm5716964lbr.1.2015.12.22.06.14.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:14:12 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Marek Vasut , Semen Protsenko Cc: Linus Walleij , Nicholas Krause Subject: [PATCH 09/54] gpio: max732x: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:14:10 +0100 Message-Id: <1450793650-22300-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 to propagate the error code here as the end of the series fixes this to work for all drivers. Cc: Nicholas Krause Cc: Marek Vasut Cc: Semen Protsenko Signed-off-by: Linus Walleij --- drivers/gpio/gpio-max732x.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-max732x.c b/drivers/gpio/gpio-max732x.c index a1094984b666..880ce94e6077 100644 --- a/drivers/gpio/gpio-max732x.c +++ b/drivers/gpio/gpio-max732x.c @@ -207,9 +207,9 @@ static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off) ret = max732x_readb(chip, is_group_a(chip, off), ®_val); if (ret < 0) - return 0; + return ret; - return reg_val & (1u << (off & 0x7)); + return !!(reg_val & (1u << (off & 0x7))); } static void max732x_gpio_set_mask(struct gpio_chip *gc, unsigned off, int mask,