From patchwork Tue Dec 22 14:20:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58887 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3264887lbb; Tue, 22 Dec 2015 06:21:06 -0800 (PST) X-Received: by 10.67.14.74 with SMTP id fe10mr36358751pad.151.1450794066281; Tue, 22 Dec 2015 06:21:06 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fm5si4624328pab.89.2015.12.22.06.21.06; Tue, 22 Dec 2015 06:21:06 -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 S1754614AbbLVOVB (ORCPT + 4 others); Tue, 22 Dec 2015 09:21:01 -0500 Received: from mail-lb0-f169.google.com ([209.85.217.169]:34920 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754612AbbLVOU7 (ORCPT ); Tue, 22 Dec 2015 09:20:59 -0500 Received: by mail-lb0-f169.google.com with SMTP id bc4so31930834lbc.2 for ; Tue, 22 Dec 2015 06:20:58 -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=zzqWMnkAjTyPHs5s7EjGlm++PLDFYMCk5+itE1qoOiE=; b=SVEMFMPgh6ohn7lWdeeudBOBRdzP48eDw52WDk7qfGkceDpiU1k1/me6YZTzMh+bY7 26ZF7jK4Qt0B7I5VjqlP1JNjwtiBa+dp3kAs83T1LjBqs27yLHDYgCtp/+l9Ow0/cOoN 6EYxcqebcw/1cvy9CxJEWBlRMBHWAKsJM7RQE= 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=zzqWMnkAjTyPHs5s7EjGlm++PLDFYMCk5+itE1qoOiE=; b=gnTPqqZLGaOZgm8CDhzwUvQdxw5/tt32vIwpLfgcDsZmUbpUtNOX0E7pJEnTNBJ3Px uchYzWATEDd6JaGbxGggECpjJ75YlSu5W6FaFO+pUbLelCF1qnFuX+5Hte6ILp9f0NK1 6m0xID5wnL8tyi5URETQGJHd20CgP5o4sH7CKqwlvYcrTZbzbmoDJt/LzuC+pGDLye8s M25+vMD+OUvArKcyKKHOcM00mN8ZyJr1Z4nqN3QIM2tis5UpPNfK5ys0Wg2B11gF/ILv Ap+oym8uZHWBTv/m9995EYlLHEsUczwzYsWMvy2wpPztWH9Ykr/CgYkXQ1OgEMuHKM3F 65zw== X-Gm-Message-State: ALoCoQkc5vUPFy1oc083mDf1lZPA+d27rje88ObpINO9IlC2VLKqVkDh4ZHSkYZimlTYP4VeVDNydKRO3nvBmqtqDzyhDxxsKQ== X-Received: by 10.112.12.5 with SMTP id u5mr7878739lbb.87.1450794057652; Tue, 22 Dec 2015 06:20:57 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l5sm5643047lbc.36.2015.12.22.06.20.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:20:56 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Thierry Reding , Daniel Krueger , Jean Delvare Cc: Linus Walleij Subject: [PATCH 14/54] gpio: pch: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:20:54 +0100 Message-Id: <1450794054-22948-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: Thierry Reding Cc: Daniel Krueger Cc: Jean Delvare Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pch.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-pch.c b/drivers/gpio/gpio-pch.c index af0715f8524b..8c45b74dcf21 100644 --- a/drivers/gpio/gpio-pch.c +++ b/drivers/gpio/gpio-pch.c @@ -127,7 +127,7 @@ static int pch_gpio_get(struct gpio_chip *gpio, unsigned nr) { struct pch_gpio *chip = container_of(gpio, struct pch_gpio, gpio); - return ioread32(&chip->reg->pi) & (1 << nr); + return !!(ioread32(&chip->reg->pi) & (1 << nr)); } static int pch_gpio_direction_output(struct gpio_chip *gpio, unsigned nr,