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: 7904911 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D50409F350 for ; Tue, 22 Dec 2015 14:51:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BECF52053E for ; Tue, 22 Dec 2015 14:51:15 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 811572053C for ; Tue, 22 Dec 2015 14:51:14 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 36369265789; Tue, 22 Dec 2015 15:51:12 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2F0A02625CF; Tue, 22 Dec 2015 15:51:04 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 450C52650D4; Tue, 22 Dec 2015 15:51:03 +0100 (CET) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by alsa0.perex.cz (Postfix) with ESMTP id 89CE4261A1A for ; Tue, 22 Dec 2015 15:50:57 +0100 (CET) Received: by mail-lb0-f178.google.com with SMTP id sv6so25544609lbb.0 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=DsuMYUaZycvEidZ3qVlXQSiOI1Afw1vghXz+6JHvUHUX1CC0Kgr/aXXQ5JsukuaU5d r7CRSvRAW0H0LkN3ULOJXqFJ+UZb5XEHjQD/k8PW5CpCFNqksh8qmMvHNMIr3Jk77YZ9 eXQIKB/bwjLteg8BD10mpE3xUd+wn0fLqn/xSQrW15jBxYuyxUIDG2/yQJjnXXuDo+gY 721oT02IEyotwiaFH4Kkp4bTBc7JUSkSyT5UGlk+kITISs/ssGfLcHW9QzQ+sHYpXcUa ItjHyTfS6XdA+u6kHUuMEwWoPNy/edHiX+xixw/b8pwxnR+VxDfZ8Rx81fqn7ZJJzRft 6CSA== X-Gm-Message-State: ALoCoQl5CUoRnOUafA2vWGzzy7ZvtHVlT919SdU2V8vvCg2/Yj6EYba/ZnKoDNVkG9+7fdXekknIrHOciLF+A3xSai/5bIpOiA== 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 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 Cc: Linus Walleij Subject: [alsa-devel] [PATCH 52/54] sound: soc: wm8903: Be sure to clamp return value X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Charles Keepax --- 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(-) 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,