From patchwork Tue Dec 22 14:51:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 7904921 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 4B8C99F350 for ; Tue, 22 Dec 2015 14:52:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 766B420544 for ; Tue, 22 Dec 2015 14:52:10 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 40E5A20532 for ; Tue, 22 Dec 2015 14:52:09 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 441A3265703; Tue, 22 Dec 2015 15:52:08 +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 951C22625CF; Tue, 22 Dec 2015 15:52: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 8A0DD2625CF; Tue, 22 Dec 2015 15:52:03 +0100 (CET) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by alsa0.perex.cz (Postfix) with ESMTP id 696D3265703 for ; Tue, 22 Dec 2015 15:51:43 +0100 (CET) Received: by mail-lb0-f182.google.com with SMTP id bc4so32393944lbc.2 for ; Tue, 22 Dec 2015 06:51:43 -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=rDqF64y67UsOcJUbwCVepOs9Og3R4yO7dsNQbVn60N4=; b=hRKTM3LUMB/rPjdsF+81r5dK2HFLMyuMf/Rd5fmIbm0+0g9xL1UI95jefvig2voXO+ q7jPe83hqEPGDgFRSHzG0aohpTxJwuxIbY3jFScYLpHwSYy+1r/vGCH2Frms0+RY6sLX 8ojQ4/3kMxmZv5HGj0lO+T/kpQsKsih+orKds= 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=rDqF64y67UsOcJUbwCVepOs9Og3R4yO7dsNQbVn60N4=; b=c+XjdBBPfFKVFyqnEoE3jcMBih20lKevhiJ3CLoSxgr/LeJakiqUELhKWaGjawoqcj NUHaAt82NBHDYMEOASFgKoMfb0MHC8B38CtGYPIF6QtB+h9ItEHx/y+o0did1mZu/niU fGKFGPr6ime1RyA5dqBFqeMenDsfdSwXf3QeIa2jrzCmntWqojkoH0B3gj4DloOHeiP1 Ol+0BOl8IrGj4N1qT9cKhdOjt7H3IsQJFihXRIOQA2C5D1ZzgBxFvKCIzoaJY5b6rt9W RF7eTaCgkaVIa3uOaqojC9sEDW9CEzTnc7uj1x/5AgZkr5ujrlnPD2PUTfMTTpNtOSTK DPNg== X-Gm-Message-State: ALoCoQmNs5DU0aXmymf9iGi2IFTfD2b/gv0xwaH7MTtiHuGs/0uaK4kUg2to+1qo2FHL6wiTTUGiuy2YrXX0698SHfvIR51VcQ== X-Received: by 10.112.25.40 with SMTP id z8mr8782573lbf.13.1450795902998; Tue, 22 Dec 2015 06:51:42 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m70sm5858992lfb.17.2015.12.22.06.51.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:51:42 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Liam Girdwood , alsa-devel@alsa-project.org, Mark Brown Date: Tue, 22 Dec 2015 15:51:39 +0100 Message-Id: <1450795899-28693-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 Cc: Linus Walleij Subject: [alsa-devel] [PATCH 53/54] sound: soc: ac97: 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: 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/soc-ac97.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c index a2012652f212..7e0acd83b0e6 100644 --- a/sound/soc/soc-ac97.c +++ b/sound/soc/soc-ac97.c @@ -92,7 +92,7 @@ static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset) dev_dbg(codec->dev, "get gpio %d : %d\n", offset, ret < 0 ? ret : ret & (1 << offset)); - return ret < 0 ? ret : ret & (1 << offset); + return ret < 0 ? ret : !!(ret & (1 << offset)); } static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset,