From patchwork Tue Dec 22 14:27:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58894 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3268525lbb; Tue, 22 Dec 2015 06:27:38 -0800 (PST) X-Received: by 10.66.197.131 with SMTP id iu3mr15316095pac.57.1450794458876; Tue, 22 Dec 2015 06:27:38 -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.38; Tue, 22 Dec 2015 06:27:38 -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 S932164AbbLVO1e (ORCPT + 4 others); Tue, 22 Dec 2015 09:27:34 -0500 Received: from mail-lf0-f45.google.com ([209.85.215.45]:35842 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932720AbbLVO13 (ORCPT ); Tue, 22 Dec 2015 09:27:29 -0500 Received: by mail-lf0-f45.google.com with SMTP id z124so125455938lfa.3 for ; Tue, 22 Dec 2015 06:27:29 -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=0p4ZhFc8oDFgk49QCD2i+rXd8UO3eevPquCcCD6erTg=; b=VyrnzacUG5ATOTVc793JXGaQBp9mkwcCEUCqPgojMfkDeDrgo6IW4jYVMkPmb7kvz5 7z1SBoWYJqtBKcX5l/FQkkSrmRl1RQ5sVq825hgGzgL5Be9Ly/wAw8pBNhkT9sgdvXvb uqgcALrwcSCiiceNHckZGemMG+FDVy8eauRbI= 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=0p4ZhFc8oDFgk49QCD2i+rXd8UO3eevPquCcCD6erTg=; b=I4WWKTJKYb7Pue/BhvlOswWzQCWkvEPTeolNOJ+fIkmGzaLAN6PDyRL5MkM7uouybs 0Sqj5spG033KcQRL4v8VBcaTa4r+uVsqoqY3MO4b46eKVpeX0SpRXC1aW5W+H5MoJrtv i1/hiYh+7u41hpiIGC5l7Q2/YETKKvTTEYWuljXTYRn3V+3yx0wureltOtuT6Gt7+kTi O2TtKYSx8OgwHUN7fGzVSDIf/A7DEi0qeI6ClPFfiYY8mIW7TnsRZungy3iTnbrvWUJY aYfgK0UZfkcZfAoNzee1cfqxoY/gMw+dfvLUJMGy6+EGBlS81NXz1kSr1T4CvbwjBSjf mKZw== X-Gm-Message-State: ALoCoQl3eRuSzEQ/zMRvJ71DFFNFAQnqRzBbfaj7QGkmGRSoa1YbWoPvOwrUCM2Hx9LohKKrIgK4Nxkoag14m+w5LzHURm2jXw== X-Received: by 10.25.161.78 with SMTP id k75mr7097294lfe.31.1450794448221; Tue, 22 Dec 2015 06:27:28 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id f197sm5716140lff.8.2015.12.22.06.27.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:27:27 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, James Hogan Cc: Linus Walleij Subject: [PATCH 21/54] gpio: tx1090-pdc: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:27:24 +0100 Message-Id: <1450794444-23461-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: James Hogan Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tz1090-pdc.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-tz1090-pdc.c b/drivers/gpio/gpio-tz1090-pdc.c index 0a01c8736aff..b08b22b1b111 100644 --- a/drivers/gpio/gpio-tz1090-pdc.c +++ b/drivers/gpio/gpio-tz1090-pdc.c @@ -113,7 +113,7 @@ static int tz1090_pdc_gpio_direction_output(struct gpio_chip *chip, static int tz1090_pdc_gpio_get(struct gpio_chip *chip, unsigned int offset) { struct tz1090_pdc_gpio *priv = to_pdc(chip); - return pdc_read(priv, REG_SOC_GPIO_STATUS) & BIT(offset); + return !!(pdc_read(priv, REG_SOC_GPIO_STATUS) & BIT(offset)); } static void tz1090_pdc_gpio_set(struct gpio_chip *chip, unsigned int offset,