From patchwork Tue Dec 22 14:48:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58926 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3280374lbb; Tue, 22 Dec 2015 06:48:44 -0800 (PST) X-Received: by 10.98.89.207 with SMTP id k76mr20062641pfj.36.1450795724763; Tue, 22 Dec 2015 06:48:44 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k12si22752529pfb.207.2015.12.22.06.48.42; Tue, 22 Dec 2015 06:48:44 -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 S932243AbbLVOsj (ORCPT + 4 others); Tue, 22 Dec 2015 09:48:39 -0500 Received: from mail-lb0-f173.google.com ([209.85.217.173]:34078 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752665AbbLVOsh (ORCPT ); Tue, 22 Dec 2015 09:48:37 -0500 Received: by mail-lb0-f173.google.com with SMTP id pv2so46343379lbb.1 for ; Tue, 22 Dec 2015 06:48:37 -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=O4TamGAi0jGUhVFZJllrUdD+rFM1V9nls7voRmvYB/E=; b=YDIrsA1XejO+Yx8mtOiosdPFDn1+lKrjMymfXD4A/EvB9uxVa+TgaLE4b74NTj4o/L JvCyJXIqLgnPQB1NJS90RIAAFstmuLkNMsDAfK23C1aIN9oqgrnEGlWK1/w9HeannL3a NHkvWhpn7hDgIhx5FL0m2hupsq9idsgXVqKRU= 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=O4TamGAi0jGUhVFZJllrUdD+rFM1V9nls7voRmvYB/E=; b=HHRPG6a+WLGbd+gh+Q6TNGDZCIJDTlHs3RcJufnE2/D5Djr9tZEx6d+ewuIBra/IER /l9iYDB9EchsKDg+jCXb4GIIiKALipvThMlcTeJKjbXxCGliqiyQcdi7qA9Rgr6Ergn2 YAkgX/ULw1VCZH0HIJC2mv20QHuKDXsSzCICMbbGLGiGyuo4DLSifTnkzgr2XVL6v/6J Vb3vuNEvcYLlq7N5gYuFfpBUrLcDrKWg6UUbVe1vk5Tk143zgU3aLnyIGh4OOit22nws G2QbvvwY3E+RD9HN/gbh2VkOS46og9/Z6KXR6E8URl9ajhsYxePBMrUgPnhBiCfGTLyf 3wDQ== X-Gm-Message-State: ALoCoQnyVA+HK0aQhjgvVvFoPD6imxU9XuVOAa/Xy6jqYSkdLxciPCNp/E51a0XvCXWFuGugFnIU/Gazs543unZUBHJ42PTwCg== X-Received: by 10.112.165.69 with SMTP id yw5mr8604419lbb.1.1450795716253; Tue, 22 Dec 2015 06:48:36 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id w132sm5839624lfd.11.2015.12.22.06.48.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:48:35 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Lee Jones Cc: Linus Walleij Subject: [PATCH 50/54] mfd: ucb1x00-core: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:48:33 +0100 Message-Id: <1450795713-28414-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: Lee Jones Signed-off-by: Linus Walleij --- Lee: as mentioned in 00/54: either apply this directly or ACK it and I will take it into the GPIO tree. --- drivers/mfd/ucb1x00-core.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/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c index a6ec7cc0fac6..bcafe1ecd71c 100644 --- a/drivers/mfd/ucb1x00-core.c +++ b/drivers/mfd/ucb1x00-core.c @@ -133,7 +133,7 @@ static int ucb1x00_gpio_get(struct gpio_chip *chip, unsigned offset) val = ucb1x00_reg_read(ucb, UCB_IO_DATA); ucb1x00_disable(ucb); - return val & (1 << offset); + return !!(val & (1 << offset)); } static int ucb1x00_gpio_direction_input(struct gpio_chip *chip, unsigned offset)