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: 58929 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3282012lbb; Tue, 22 Dec 2015 06:51:45 -0800 (PST) X-Received: by 10.67.14.74 with SMTP id fe10mr36589997pad.151.1450795905513; Tue, 22 Dec 2015 06:51:45 -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.51.45; Tue, 22 Dec 2015 06:51:45 -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 S932967AbbLVOvo (ORCPT + 4 others); Tue, 22 Dec 2015 09:51:44 -0500 Received: from mail-lb0-f182.google.com ([209.85.217.182]:33392 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754252AbbLVOvo (ORCPT ); Tue, 22 Dec 2015 09:51:44 -0500 Received: by mail-lb0-f182.google.com with SMTP id sv6so25555977lbb.0 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=ijg8/HEMFtwYRVUOUHJ3tvPqtNrpY3UPwKBa+3Gu+v+5twQloPdU1iIrmFUK2x7CzA U4MmVz6qhc/uLryMyUog6taKdpEKghsRpjz3IRUmLk7sCB73/djDXacnrYFHWHf+2XXA vRGuOYRZ4HdFv/7cEOEtANyPiDpcofPpT7ffhpmp+zDcBqVe6Mvk/i8gmt+Mkhxv9BVb KkNOSgonX5gHjjALpfsJ2zpuZDjrRjc5yve8T/odO7Ue6YhEspnbVwHo4wSNRbSO6ABJ 2V1hcev/jqH++Y4EwwOkRpMXrjkMvi8ow2/Lta6NhW5S0QSjowgkP4WjikKZRFLI4pea IYgQ== X-Gm-Message-State: ALoCoQm7gyM7DLRN5uxIfPjuuW14yEIALuN8ZXWRum1rnUKTJQe91vVOpMIp2Y7SBBtHudBFSBWu4lDNQbSUKKbYhsB9d4QTsg== 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 Cc: Linus Walleij Subject: [PATCH 53/54] sound: soc: ac97: Be sure to clamp return value 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 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: 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(-) -- 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/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,