From patchwork Tue Dec 22 14:14:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58883 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3261132lbb; Tue, 22 Dec 2015 06:14:53 -0800 (PST) X-Received: by 10.66.240.4 with SMTP id vw4mr35973333pac.9.1450793693147; Tue, 22 Dec 2015 06:14:53 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fc7si4639946pab.144.2015.12.22.06.14.52; Tue, 22 Dec 2015 06:14:53 -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 S1754023AbbLVOOw (ORCPT + 4 others); Tue, 22 Dec 2015 09:14:52 -0500 Received: from mail-lb0-f175.google.com ([209.85.217.175]:34524 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753802AbbLVOOv (ORCPT ); Tue, 22 Dec 2015 09:14:51 -0500 Received: by mail-lb0-f175.google.com with SMTP id pv2so45829469lbb.1 for ; Tue, 22 Dec 2015 06:14:51 -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=8pMoHl5312xIRSHYKqBklsF1KJLN87nz6Le44T6BRqM=; b=PkCZ3S+BVz+en5obUhoma9zgI5/IhgHvOOrrjKFis8tZLh6Zr5skna86s29B9Trnpf QZ9pugOLsKiNAUg/GxcJnmJO26wxTz+PiJXr70gmpY/hIHIbDWCJeOH/1fVJQwd7vc1w aOpYgP2Qwf6CtclsMOmXxw+JlHHXrSMq9iTWE= 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=8pMoHl5312xIRSHYKqBklsF1KJLN87nz6Le44T6BRqM=; b=kxYhMZDDekP2S72vJO9Kd0rBuVx/v29yUKTEIp+VNDNuC/+JEaLulI5xTLBb42S7JP bg9vzOmv3Qd78hkPNilX02jpS1MYb1llGksvig9uaWZ3UPvkXPFh5OBJhFg68JdRJZlL /ZzizEjhT7+1Kx+zlgIuALg+Jlo+ByAwpfBT7Qwzu/Aum6+2uCLmRR6f8gX6JT8NpXO8 OiOsjdvlkY5yQKSC6/h8ciylrg08MOvnlTTdcpMGrZX26abHfjgkbArcsNfiLUkhhyu2 NpGZN+t61Jt5SNlh9olPCRegWHRUrkJUkKg3ffxrBdiBwm+HHFHUR+MUFbaJlgGJMnoX 761g== X-Gm-Message-State: ALoCoQmjSoG10fuPZbZ0lSZ4jo0EMG+CUKuRtrChgNxjpu0RJXybzG43FGU5uyVhNe3kQSFYDgMCZd6tujROX4r1TKR0wuWmvw== X-Received: by 10.112.131.1 with SMTP id oi1mr8583920lbb.35.1450793690572; Tue, 22 Dec 2015 06:14:50 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id d75sm5833468lfb.1.2015.12.22.06.14.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:14:49 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Feng Tang , Tomoya MORINAGA Cc: Linus Walleij Subject: [PATCH 10/54] gpio: ml-ioh: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:14:47 +0100 Message-Id: <1450793687-22370-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: Feng Tang Cc: Tomoya MORINAGA Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ml-ioh.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-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c index 5536108aa9db..7ef704343f05 100644 --- a/drivers/gpio/gpio-ml-ioh.c +++ b/drivers/gpio/gpio-ml-ioh.c @@ -124,7 +124,7 @@ static int ioh_gpio_get(struct gpio_chip *gpio, unsigned nr) { struct ioh_gpio *chip = container_of(gpio, struct ioh_gpio, gpio); - return ioread32(&chip->reg->regs[chip->ch].pi) & (1 << nr); + return !!(ioread32(&chip->reg->regs[chip->ch].pi) & (1 << nr)); } static int ioh_gpio_direction_output(struct gpio_chip *gpio, unsigned nr,