Message ID | 20230623085830.749991-4-herve.codina@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5637111vqr; Fri, 23 Jun 2023 02:16:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KxAvbqsYcJCUwMYegM0GRRaYKb1/oiZmdgSfyNmOskQ7YzuQYUiVHwIx2VWg1gsexFWSX X-Received: by 2002:a05:6a21:9983:b0:121:bf66:a715 with SMTP id ve3-20020a056a21998300b00121bf66a715mr11736939pzb.45.1687511819292; Fri, 23 Jun 2023 02:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687511819; cv=none; d=google.com; s=arc-20160816; b=iPqBDvEhbb5ZBKuMjy/VCi+qoaNJBfSbGOov119UXbi9mPknldOlfTNCY+UtEUbwlk PLc8WxqiGDsf6lUQ6v9VV9tU5LoGESItWFBDXjALJoqcD2Z+IrJykJ4mAVNemojdcOyM ZXih0qosKIB95HYcg8ihMgC3eYg5L0wzabdQv6QdCwUfGg0yr0BYI99TxBLO2kSgYsj7 za4Ih0HKGKKI9FeRJLJl83ot83HHWwn8kHNh34pq7Qwb4yZPnwgTCRb0D63DTNZ3qFSK +U1c3Mo5D5V94yHPNrkUJ3Y2gejr7UfXWKg3QZTdUXYAt9B5FbwI2XmhLeIid2u//pEx TYmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rfYOy7L85MdtcQ88k+lfhIIjhcOaxuYtKNcPHMwEQsI=; b=ZI3ELCGW3yazPS1Z+F51FeY5wFRMQDqMqL3Vgt9fiXKTKLWjuYctOhSbIFiqsmYWmw KsHilmqE3rGwoCfv8mMYvqYKfZkO6oB8id1UUTHwSGmBwlQQfrVnLGxA931xEnAmehZZ uSejCyqSm209tdPnMaTUYxNyib66Q0Qzu1xy5zRfAUOa1oGae5RTr2dRZ6ITQfiUoR3X 05kOdJ0ZRXXbral88X2hDqPpK+JGP+jH088/vHbZUBxD1ihUCWL7SmgpX0FWNuPIMd2W BNXoSe10rH64Xo4rFEX+I7IZuRCwlsH3+13UGP/qFekML6VJVQQ3x4iQiFm3prXNTy6a wKhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=knWhzUEE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a170903234700b001ac2ff9fbf8si5416053plh.403.2023.06.23.02.16.44; Fri, 23 Jun 2023 02:16:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=knWhzUEE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231968AbjFWI64 (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Fri, 23 Jun 2023 04:58:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229999AbjFWI6s (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 23 Jun 2023 04:58:48 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A968A10C1; Fri, 23 Jun 2023 01:58:46 -0700 (PDT) X-GND-Sasl: herve.codina@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1687510725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rfYOy7L85MdtcQ88k+lfhIIjhcOaxuYtKNcPHMwEQsI=; b=knWhzUEEAUpZM8lHUEu/eXc+ozD4+EQx9Vv/n38Hd/h+Xap3AJYOXF/5VTV6+22Zre7/1M oOUXew1BzvDWkjKyNE8Xs7CQlPwhnyA4JW0qqnlIuenZlcOvaDXXFXn0qGFJuE9yTQE834 Xo3P8dWJ6gA+9BfIXNVlurWsMPIVI8uw47FDWBsYMUZo7KMyNkN7qbDZXIOJTNFaZ2QAOw UUSBPO1mIBjQGH06CySF6+pZcYuaLxhxtFclCKF6yuSckGrw0IZrJ/SKdsXWimflP9xp+W MYyVvW7poaLHVR/8ilityk7Npvsac90w/h1JE8wUBe0JR5J2dXQuu3RYB4i7Lw== X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id 5832BE000A; Fri, 23 Jun 2023 08:58:43 +0000 (UTC) From: Herve Codina <herve.codina@bootlin.com> To: Herve Codina <herve.codina@bootlin.com>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Jonathan Cameron <jic23@kernel.org>, Lars-Peter Clausen <lars@metafoo.de>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>, Andy Shevchenko <andy.shevchenko@gmail.com> Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Wojciech Ziemba <wojciech.ziemba@intel.com>, Christophe Leroy <christophe.leroy@csgroup.eu>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Jonathan Cameron <Jonathan.Cameron@huawei.com> Subject: [PATCH v6 03/13] iio: inkern: Check error explicitly in iio_channel_read_max() Date: Fri, 23 Jun 2023 10:58:20 +0200 Message-Id: <20230623085830.749991-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230623085830.749991-1-herve.codina@bootlin.com> References: <20230623085830.749991-1-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769484393531825216?= X-GMAIL-MSGID: =?utf-8?q?1769484393531825216?= |
Series |
Add support for IIO devices in ASoC
|
|
Commit Message
Herve Codina
June 23, 2023, 8:58 a.m. UTC
The current implementation returns the error code as part of the default switch case. This can lead to returning an incorrect positive value in case of iio_avail_type enum entries evolution. In order to avoid this case, be more strict in error checking. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> --- drivers/iio/inkern.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Comments
Le 23/06/2023 à 10:58, Herve Codina a écrit : > The current implementation returns the error code as part of the > default switch case. > This can lead to returning an incorrect positive value in case of > iio_avail_type enum entries evolution. > > In order to avoid this case, be more strict in error checking. > > Signed-off-by: Herve Codina <herve.codina@bootlin.com> > Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> > --- > drivers/iio/inkern.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c > index 872fd5c24147..f738db9a0c04 100644 > --- a/drivers/iio/inkern.c > +++ b/drivers/iio/inkern.c > @@ -858,6 +858,9 @@ static int iio_channel_read_max(struct iio_channel *chan, > val2 = &unused; > > ret = iio_channel_read_avail(chan, &vals, type, &length, info); > + if (ret < 0) > + return ret; > + > switch (ret) { > case IIO_AVAIL_RANGE: > switch (*type) { > @@ -888,7 +891,7 @@ static int iio_channel_read_max(struct iio_channel *chan, > return 0; > > default: > - return ret; > + return -EINVAL; > } > } >
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 872fd5c24147..f738db9a0c04 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -858,6 +858,9 @@ static int iio_channel_read_max(struct iio_channel *chan, val2 = &unused; ret = iio_channel_read_avail(chan, &vals, type, &length, info); + if (ret < 0) + return ret; + switch (ret) { case IIO_AVAIL_RANGE: switch (*type) { @@ -888,7 +891,7 @@ static int iio_channel_read_max(struct iio_channel *chan, return 0; default: - return ret; + return -EINVAL; } }