From patchwork Tue Dec 22 14:12:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58878 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3259553lbb; Tue, 22 Dec 2015 06:12:12 -0800 (PST) X-Received: by 10.98.72.203 with SMTP id q72mr35883825pfi.55.1450793532631; Tue, 22 Dec 2015 06:12:12 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 86si33061553pfs.88.2015.12.22.06.12.12; Tue, 22 Dec 2015 06:12:12 -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 S1754260AbbLVOMM (ORCPT + 4 others); Tue, 22 Dec 2015 09:12:12 -0500 Received: from mail-lb0-f175.google.com ([209.85.217.175]:33399 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753041AbbLVOML (ORCPT ); Tue, 22 Dec 2015 09:12:11 -0500 Received: by mail-lb0-f175.google.com with SMTP id sv6so24955074lbb.0 for ; Tue, 22 Dec 2015 06:12:10 -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=AO5BFd8GgVz31bDTZJslU87Z9YOBSdjLRpjx06H/e8I=; b=RPmGnyYsr0lpno1oi3GAhY0Qg48SxME8boJ1geKquDpYOlWGjw3x8eT9wl6XPFyFMv frlbhk1Dg7//3pe1uEuQQ9jpLbmOtgan7KTUndibKN2+abxryOzTx2/N8XCWFItLJoUR 2ThnxFCUPIz65Tu53jzqLpeg+azEArUzIE4cI= 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=AO5BFd8GgVz31bDTZJslU87Z9YOBSdjLRpjx06H/e8I=; b=FGdpTvwemcZVI9ElkuSVE6lixn2OE1Cwcou0XCUrxwrKNcao5xyyTkQxmamNidWeeI 87SCZAyb07fgIIVGJy7T3MCu1Dx3G0Q104NcFnIsAn8tpnoYMRi6CAcB5vrDvGQUjmSg alLVo2ePNSS+ZKdE78xOHyF+nZAXbs5T+mN6rPsA3AnBOzd1N6taTnOGcYAICUUcAJDZ azeTzYfzCZG7VCByk1EUkkHxCRxhD/aT0DH0Iffbdx7TEruMvziqqfZSqw/9vjFhBQOI BNJCEugyuVXUilfxGMvJXkt6R0lctg9XpwkIxNCOmg5Y+kcGtTyhqFSkBQzbsvEfNUeD 7zfg== X-Gm-Message-State: ALoCoQlJ+T51msT3NrGZ04t+9Ve3jNa238tTbrf8vy8dAULPaObpcmXQeT2t3U1EclO8SzAw/Koadk97/O4YSIQHPSJOhMn+yQ== X-Received: by 10.112.50.134 with SMTP id c6mr8721176lbo.14.1450793529828; Tue, 22 Dec 2015 06:12:09 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id n65sm5733320lfb.43.2015.12.22.06.12.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:12:08 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, David Cohen Cc: Linus Walleij Subject: [PATCH 05/54] gpio: intel-mid: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:12:05 +0100 Message-Id: <1450793525-22057-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: David Cohen Signed-off-by: Linus Walleij --- drivers/gpio/gpio-intel-mid.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-intel-mid.c b/drivers/gpio/gpio-intel-mid.c index 1c46a7ef2680..26d2083a5901 100644 --- a/drivers/gpio/gpio-intel-mid.c +++ b/drivers/gpio/gpio-intel-mid.c @@ -120,7 +120,7 @@ static int intel_gpio_get(struct gpio_chip *chip, unsigned offset) { void __iomem *gplr = gpio_reg(chip, offset, GPLR); - return readl(gplr) & BIT(offset % 32); + return !!(readl(gplr) & BIT(offset % 32)); } static void intel_gpio_set(struct gpio_chip *chip, unsigned offset, int value)