From patchwork Tue Dec 22 14:50:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58928 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3281602lbb; Tue, 22 Dec 2015 06:51:00 -0800 (PST) X-Received: by 10.98.13.16 with SMTP id v16mr35812686pfi.129.1450795860307; Tue, 22 Dec 2015 06:51:00 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 82si11710824pfh.152.2015.12.22.06.50.59; Tue, 22 Dec 2015 06:51:00 -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 S1754268AbbLVOu7 (ORCPT + 4 others); Tue, 22 Dec 2015 09:50:59 -0500 Received: from mail-lb0-f169.google.com ([209.85.217.169]:34064 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753448AbbLVOu6 (ORCPT ); Tue, 22 Dec 2015 09:50:58 -0500 Received: by mail-lb0-f169.google.com with SMTP id pv2so46378217lbb.1 for ; Tue, 22 Dec 2015 06:50:57 -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=SJWwQpNPxTGmV3TjMCigA0vG0TxkbpE7POElBCCkwNE=; b=MZimgSdLCGH4jGiJuu5BLkMTWEzid2tzwsjo2hnSW7+yyW7PofR/1UAF24qC8GBTLz Mcugphj0ppez7joYIckw7o0gxBJy4hsSvrdJF7geJfm+QYOxlC6JcOXp1/xdU/LNkKvg qlkJiFEhfNTzMZj8gvb00gQLFPe8YKuijEA5A= 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=SJWwQpNPxTGmV3TjMCigA0vG0TxkbpE7POElBCCkwNE=; b=HrPambKN6I1yYkLTPJKG07tqIgi6BAC7gbYIlnT0qCkexA7Ztaf7jlqaZfgSdwvAk7 +pnRduVDqSb71dIllF/LFlfXIn0ktUfoetfVHD/lAW3cHvVbA3S15Kw1Db8lCnpu4WAP SSA+J8EfglSbzIOoLSb4RZV/YyiedXZ3oNTyRkUyXUBrVxa1rlZxvqV4nGbX1L2TUQqs hCyOsp+1RJkZxVddrSJLwmJIJrMSpPLvjBzsmffeopBKHnh/OKyoJ0ik+or9fCbKJvVP gksUj8ORNvpSDFRDxEONsJbSjaCreOSnx9bQMQj1obUpt3bnXspmgdz8gXDtfmIGgkNa 9ROg== X-Gm-Message-State: ALoCoQllLkQmYy6R23JpJFl8SDhfV5FQC1tN7ncHiLF1U6QmItv+6CbpiSol3ovyg+iyCE4GZ4CKst5+2E5fFuB8DET8ydpwOQ== X-Received: by 10.112.169.34 with SMTP id ab2mr8681106lbc.140.1450795857081; Tue, 22 Dec 2015 06:50:57 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id h82sm5797469lfh.27.2015.12.22.06.50.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:50:55 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Liam Girdwood , alsa-devel@alsa-project.org, Charles Keepax , Mark Brown Cc: Linus Walleij Subject: [PATCH 52/54] sound: soc: wm8903: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:50:49 +0100 Message-Id: <1450795849-28642-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: Liam Girdwood Cc: alsa-devel@alsa-project.org Cc: Charles Keepax Cc: Mark Brown Signed-off-by: Linus Walleij --- Mark: as mentioned in 00/54: either apply this directly or ACK it and I will take it into the GPIO tree. --- sound/soc/codecs/wm8903.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/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index 2512def0d349..a82b8bc2cfc0 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -1804,7 +1804,7 @@ static int wm8903_gpio_get(struct gpio_chip *chip, unsigned offset) regmap_read(wm8903->regmap, WM8903_GPIO_CONTROL_1 + offset, ®); - return (reg & WM8903_GP1_LVL_MASK) >> WM8903_GP1_LVL_SHIFT; + return !!((reg & WM8903_GP1_LVL_MASK) >> WM8903_GP1_LVL_SHIFT); } static int wm8903_gpio_direction_out(struct gpio_chip *chip,