From patchwork Tue Dec 22 14:21:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58888 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3265342lbb; Tue, 22 Dec 2015 06:21:50 -0800 (PST) X-Received: by 10.98.13.8 with SMTP id v8mr36062622pfi.49.1450794110394; Tue, 22 Dec 2015 06:21:50 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fc7si4676534pab.144.2015.12.22.06.21.50; Tue, 22 Dec 2015 06:21:50 -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 S1752526AbbLVOVt (ORCPT + 4 others); Tue, 22 Dec 2015 09:21:49 -0500 Received: from mail-lb0-f175.google.com ([209.85.217.175]:35272 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752431AbbLVOVs (ORCPT ); Tue, 22 Dec 2015 09:21:48 -0500 Received: by mail-lb0-f175.google.com with SMTP id bc4so31943302lbc.2 for ; Tue, 22 Dec 2015 06:21:48 -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=S8gzbYtKr+HsCrgQUrrJwkEelb+nPYk5InHQU6XfG2k=; b=LrKmBj2xgRIaIIEeijDkI17FgZ23BhxkXkGkHcExv/M3Dt37fwgaianjt7d5mKm1xO 4H5VFKifC1IhKBNC+7T2b+5nWjS+fQsGW9RtnO1A2TB8F1I/hH9PkzA2dlu+Ofqz/ixr 1YXzdTxl7R/4vRP6boH1emurUSV9f5V3eNC9g= 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=S8gzbYtKr+HsCrgQUrrJwkEelb+nPYk5InHQU6XfG2k=; b=APZQcVfOasCDHN/BdOh0/F3tWLARXGdk7vUp5QWcjkej4+8B4wDmt/yVT+VwOICsCZ 7x9WP66HU+ZB1lCGkhirhgiQZOd2Kzra7ABbA7Wj9xpQNf/6zocMyFR5awj65wbS1/Gy 7tSLvpL4l4mC4edt8O8vPuJjcFeh9KINn42DUuCOgZHLy/2FCfcQMGgLYEHAP50Ae6DO +bjBbhB4kZK9gbbYOV56CvP/kjPZpPTO+owhKkpQVmDfdoU3eGPZue6nXjdTG/uIGQNg R1HWsTpKTTzxbcYEDdWWltGrrz64ZGO0ym8YDM/s2xS9JUqsweXZX2izzCy8mLZfRwxb qpnA== X-Gm-Message-State: ALoCoQnRMHGNyIzF8l0Z/VFHcNuQVrDhC7vu4NAuWQKp/sPH4Zi3rvqha/51zB7bMt9EMWN27TJwFDbiXmSDtGwPszJKudJxKg== X-Received: by 10.112.131.105 with SMTP id ol9mr8684467lbb.45.1450794107539; Tue, 22 Dec 2015 06:21:47 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id d75sm5837708lfb.1.2015.12.22.06.21.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:21:46 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Dmitry Eremin-Solenikov Cc: Russell King , Kristoffer Ericson , Linus Walleij Subject: [PATCH 15/54] gpio: sa1100: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:21:42 +0100 Message-Id: <1450794102-23007-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: Russell King Cc: Dmitry Eremin-Solenikov Cc: Kristoffer Ericson Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sa1100.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-sa1100.c b/drivers/gpio/gpio-sa1100.c index 990fa9023e22..9d590166e952 100644 --- a/drivers/gpio/gpio-sa1100.c +++ b/drivers/gpio/gpio-sa1100.c @@ -17,7 +17,7 @@ static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset) { - return GPLR & GPIO_GPIO(offset); + return !!(GPLR & GPIO_GPIO(offset)); } static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value)