From patchwork Tue Dec 22 14:23:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58891 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3266250lbb; Tue, 22 Dec 2015 06:23:28 -0800 (PST) X-Received: by 10.66.161.133 with SMTP id xs5mr35720985pab.70.1450794208217; Tue, 22 Dec 2015 06:23:28 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xk9si4644477pab.38.2015.12.22.06.23.27; Tue, 22 Dec 2015 06:23:28 -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 S1754411AbbLVOX1 (ORCPT + 4 others); Tue, 22 Dec 2015 09:23:27 -0500 Received: from mail-lb0-f174.google.com ([209.85.217.174]:34192 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754321AbbLVOX1 (ORCPT ); Tue, 22 Dec 2015 09:23:27 -0500 Received: by mail-lb0-f174.google.com with SMTP id pv2so45960784lbb.1 for ; Tue, 22 Dec 2015 06:23:26 -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=DP+gRHiFoFnw7xVjxG9K0/1AY10qBzW+EYykn95W5+Q=; b=Ce9C8346o8q75/N1sLg5Zbv9NRUu1mPIvapIlsEnt0LOZK1IjrqjX24BGf2hFXqyUf DlXD6vGV9C+KQqxc5D4DTrEReRhhNuy6AqR8q22TLmSZ7qJdzhvfrVyNnLnrr7798cFI mGj/aQhGBlAYbvKUJPrNGVGR/WA4yaLJM3Sxc= 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=DP+gRHiFoFnw7xVjxG9K0/1AY10qBzW+EYykn95W5+Q=; b=e89wR2JKfWdjDpTV7SDLruc/KLSWiRllOFhT9EW62LO0/7cT7w3B85Uzqsq5uSmhGL sEUGOm3A42Q15eTDXuLMj2/pMNXywgRPs1mo5E4R8BuYktSxVGMsPDlrgLNp8yYjh5qv YmKifDLoWpiXNGLOREw38nLPz5C/oD+QYCLDmHc0/ncmZgwOR48TsRAk7D5rifn0gJQN uHmKYjkg3GUMRQ3TTmYyKTR6gWLvm49ZIA0C6N1ZkJyetRFGH0OHfNdPeJPVqVKpUvP6 iLFdaqjVNUrpFutX7urk/t7MrOafhv+iKZFLSYdHeDyUkDwt7dW3EDL+OCdERwpegA4S uIQw== X-Gm-Message-State: ALoCoQmdKKdh0DAl1JJhM63Zk904mHcH5ATgKXvKpTnbc+nBHbS3ISLQhUCbHsj0rJi1z+FBfTWEAiuXWB5Yg2043yl5fd7wYg== X-Received: by 10.112.39.5 with SMTP id l5mr8404923lbk.101.1450794205712; Tue, 22 Dec 2015 06:23:25 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t4sm609949lbw.25.2015.12.22.06.23.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:23:25 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Linus Walleij Subject: [PATCH 18/54] gpio: tc3589x: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:23:22 +0100 Message-Id: <1450794202-23248-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. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tc3589x.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-tc3589x.c b/drivers/gpio/gpio-tc3589x.c index 7c1537ed6dff..2896aef5aec4 100644 --- a/drivers/gpio/gpio-tc3589x.c +++ b/drivers/gpio/gpio-tc3589x.c @@ -51,7 +51,7 @@ static int tc3589x_gpio_get(struct gpio_chip *chip, unsigned offset) if (ret < 0) return ret; - return ret & mask; + return !!(ret & mask); } static void tc3589x_gpio_set(struct gpio_chip *chip, unsigned offset, int val)