From patchwork Tue Dec 22 14:12:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58879 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3259858lbb; Tue, 22 Dec 2015 06:12:42 -0800 (PST) X-Received: by 10.67.24.104 with SMTP id ih8mr35917510pad.124.1450793562524; Tue, 22 Dec 2015 06:12:42 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 86si33061553pfs.88.2015.12.22.06.12.42; Tue, 22 Dec 2015 06:12:42 -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 S1754056AbbLVOMm (ORCPT + 4 others); Tue, 22 Dec 2015 09:12:42 -0500 Received: from mail-lf0-f52.google.com ([209.85.215.52]:36670 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752914AbbLVOMl (ORCPT ); Tue, 22 Dec 2015 09:12:41 -0500 Received: by mail-lf0-f52.google.com with SMTP id z124so125196180lfa.3 for ; Tue, 22 Dec 2015 06:12:40 -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=JTHooWRIX7Qu+Gj1XIaab+z/VrQ2cAXUi6SXEjdM2uo=; b=MFheKcM3jD0s8tKvyMo8Z6dsO9Hap5q75HlfUVttOhrtBGq/mk1SNtl8xl96ygEiXr GbPc0nvyIUGrQq4ZSBLKt5aSb8+xCEuQS/EGNeYTMmlUBwz0Nq+wTsFVTILVl2dAi02S 4ujj7RAhcVSqogxIxB3pwO8unAr/jpPxqUleE= 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=JTHooWRIX7Qu+Gj1XIaab+z/VrQ2cAXUi6SXEjdM2uo=; b=Kbs9lIu2TwWmTCCl7m7u8lAUhl3W5NddfjxaEb65JycC3BqH2HfYyKqGxBBKs4NsBb KKrwuWBoijkovuNAzVkf+EsvEALwEb6cDaylsLldpJe+mH7Kztd9ObM55ixjmVnPGCB2 z4iMhOzLYIEg8aKv6jh72ZRzYKEDoir6Qgnuxo4c8hD7PMGTiSllQlO+Ld44qojsRMjc S34/d+I2TN8BCs1/pfPFrxSstJTeSxjcnSgWa1rkko9Q8Tond8uncsTjWdxQi2M9wS6l 0Hl/9AP4n2y2nYkVHiXfa7pJuEnpeYQjlWfE/by8HwYtG3FO3c9oBRbvJgx5guHy3ktw ayzQ== X-Gm-Message-State: ALoCoQliqDBENgKALKxqOgU0BzDUckTrSGd1puR+eoXyCGcOuT6qswWguipd9+vyPTjsRjXsT1WlOqHgScznLTAkcCac+35xUA== X-Received: by 10.25.90.195 with SMTP id o186mr8713773lfb.9.1450793560126; Tue, 22 Dec 2015 06:12:40 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id d130sm5802162lfe.18.2015.12.22.06.12.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:12:39 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, "Ira W. Snyder" Cc: Linus Walleij Subject: [PATCH 06/54] gpio: janz-ttl: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:12:36 +0100 Message-Id: <1450793556-22116-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: Ira W. Snyder Signed-off-by: Linus Walleij --- drivers/gpio/gpio-janz-ttl.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-janz-ttl.c b/drivers/gpio/gpio-janz-ttl.c index e5f85cab0100..236d322a0b5e 100644 --- a/drivers/gpio/gpio-janz-ttl.c +++ b/drivers/gpio/gpio-janz-ttl.c @@ -76,7 +76,7 @@ static int ttl_get_value(struct gpio_chip *gpio, unsigned offset) spin_lock(&mod->lock); ret = *shadow & (1 << offset); spin_unlock(&mod->lock); - return ret; + return !!ret; } static void ttl_set_value(struct gpio_chip *gpio, unsigned offset, int value)