Message ID | 20230612122926.107333-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 k13csp2558305vqr; Mon, 12 Jun 2023 05:43:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6YpvuT0+AGvSJqzh+qisv3IjaKjurb94lAHvmlkmUA2Qwue46EVZLXibooxi9SM5W645l6 X-Received: by 2002:a17:907:3184:b0:962:9ffa:be02 with SMTP id xe4-20020a170907318400b009629ffabe02mr9114184ejb.36.1686573821670; Mon, 12 Jun 2023 05:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686573821; cv=none; d=google.com; s=arc-20160816; b=CHXVD2WUtYQmptg1o0QLvVwZZjA6i4ejiILCLP+SFsd6zOgxbcYHyVCeYFYdyUKTPG FBvD9mWajBuXI1GFRvQV32Uh7M10Dv8hargWkB/O2JXDdEq1IE7KkJfGSoi4JzKVRU6N m35wKVSKz913RnBOy5wYVJufiqTNQ9ATu9J1l9g7jkQDzCxkmUiTTSxpBikbfQ4JSk7S e3V896LNDLR8pK14eF/sNxXq0ry+Z9lnW4KM4fvSV1pkvmYm5vAYSDHySilozzlmU4sI +dD8cxJQTHUcPy/2UE0mSA0S4U/5Ikzgf+IiZNPf4j5sKRQvPBnM+D7Ufk/AzQIPMk+3 fJgw== 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=fxihK5WvOxWe3kLHHpt2g1PiNniemigSf5773LJSuNI=; b=mb9d7Td97isfFGnlVy/yfMmDX+VKECcml6WyDOzBhUovNoPj3o6kr1ZU4Y0ANgo4cD 1BmmPSOYMfcxuSOyDoIX3gELzfznqwSIm4DL0/1OPkIDTWsu4Nb4YvAwRFTaTJOhNrbY wP9vvJa2SLTs9f+ni/+4W2+Pz0gM+tujgPWjgX4wglv97KllZskOq/ya0/kbby0PFZ8B j5gsCzzpQbt7NNwRt2R63NAZ6k9p680TOGTa+aTLlVnuSK+36zVjeRuzFfRHri64GAoI 0+pnvVfPn0p6dO5b/PPxh/NTK6EJwO4f5FIt9XcQiorSI0kGYwnXqd9EI7bABmg+RFQ4 sbhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=C8wzreCD; 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 xo6-20020a170907bb8600b0096f445350d8si1700578ejc.805.2023.06.12.05.43.16; Mon, 12 Jun 2023 05:43:41 -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=C8wzreCD; 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 S233368AbjFLMaT (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Mon, 12 Jun 2023 08:30:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233344AbjFLMaD (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 12 Jun 2023 08:30:03 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B92FA98; Mon, 12 Jun 2023 05:30:01 -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=1686573000; 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=fxihK5WvOxWe3kLHHpt2g1PiNniemigSf5773LJSuNI=; b=C8wzreCDiLenUXn7Nb6eOorDJJoB3hl00Lr0jwbMl1swMv5DC73t/KbiZ5RSaU1smiXbpB SYGduS0pAUP4IVMsmy4gdjr0gqVLR5leEB9u+Ii0rGmz08o6Gn3wZpGDofnXXC97b1FnO6 jOJzc4sBnHMPyKlcJrYmXnI6X9XLzyTsQ6H0X82U/j/dnsYanuuHAYLyb2NGwRXqiiHdwY 1Pe28U2Bjgav0LDJRQhur5BSIep73UQzt1ImOzXwwDzmm2U2GdPwtccKjIqx9qZK2vFFOY 2jZbdZmLk0qITHHJEmpUTvUdzLSn8kylw09vCD4I4rrmsjEZJseDv1vUTMG16A== 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 4E632240018; Mon, 12 Jun 2023 12:29:58 +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, Christophe Leroy <christophe.leroy@csgroup.eu>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Jonathan Cameron <Jonathan.Cameron@huawei.com> Subject: [PATCH v3 03/12] iio: inkern: Check error explicitly in iio_channel_read_max() Date: Mon, 12 Jun 2023 14:29:17 +0200 Message-Id: <20230612122926.107333-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612122926.107333-1-herve.codina@bootlin.com> References: <20230612122926.107333-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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?1768500831908887448?= X-GMAIL-MSGID: =?utf-8?q?1768500831908887448?= |
Series |
Add support for IIO devices in ASoC
|
|
Commit Message
Herve Codina
June 12, 2023, 12:29 p.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> --- drivers/iio/inkern.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Comments
On Mon, Jun 12, 2023 at 3:30 PM Herve Codina <herve.codina@bootlin.com> wrote: > > 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. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> > Signed-off-by: Herve Codina <herve.codina@bootlin.com> > Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > 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; > } > } > > -- > 2.40.1 >
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; } }