Message ID | 20230614074904.29085-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 k13csp1067062vqr; Wed, 14 Jun 2023 00:52:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4t8Zvy0hysFI9ZvOv+LlGUTqMd0emwLuhISIkVZBRDlF5IqE4Yly0bPMmBdxOBADKTav56 X-Received: by 2002:a17:907:36c3:b0:973:9f60:c57e with SMTP id bj3-20020a17090736c300b009739f60c57emr15929924ejc.2.1686729145190; Wed, 14 Jun 2023 00:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686729145; cv=none; d=google.com; s=arc-20160816; b=OXiMN7i98wwLEsQyAgBlfbUShiZQTc4DlBp9ToaU+1KBtss/UaL8qt3XEfgnvFTqpT su4CUUiRYVv1FxeHWw4HBwaGGhdpQmSj4cTL0k4/tEoAUStp6am1tPrk2jFtN+8xSsTF XVA/EuITK21tdxiRMJ7TSNlUQs//2DAwO1sP+6Bxqdvsr1/WA/FDytqdreh6MZdi4WWq WgIrXc6hs7d5mIx/nEO6y8kB6LZzWvb8wbXyl6IlwH2Iz+KeseGPHVwvhw96nUhn1Iou qv0dqOSYa5+W4zFtacd4NnKEqEOAmhhUrXPcLsdrLd3Zf5a9WK04gFHMJzPf/rZdI7Zx GHZQ== 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=ww4XRIlQcl9ukEOJA6L8kG+cVjnoxwHTdzkMJW6QDeFAIDle+5hI24mvmC++lUSOdw KOR+zWASUB7Bpr5J8RonEOSYVduLTSkykTt9zpod5QomBUWxggW7BENbRACsi5lBCaIo fuBSosoIImUX9j7HWRDVEKThGvfSY/3fC9Zis8skJqFabaYXVoHfio3x1iPDSmOfHM7k Mv2C/8luOtT1568ScjmFlwb5D8+Z6YuwE/SbOBXhY5ACFHiarW4ZtLNpj8wmtDAeni66 6uuV+BIFfEPmWiUfL8KtJcm2VXoxKIrDaoo5k6BrwL3ecf4XMVGoWTLBEXfdUrFUfHto 5cZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=COfOgeF0; 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 v17-20020a170906339100b00973aab0b96esi7587255eja.386.2023.06.14.00.52.00; Wed, 14 Jun 2023 00:52:25 -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=COfOgeF0; 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 S243077AbjFNHuT (ORCPT <rfc822;jesperjuhl76@gmail.com> + 99 others); Wed, 14 Jun 2023 03:50:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243205AbjFNHtf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 14 Jun 2023 03:49:35 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BEECE62; Wed, 14 Jun 2023 00:49:34 -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=1686728973; 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=COfOgeF0jmouxFkryE8iefc+Fl8Wp8TIdgAO4vwJpICa78tA/Ib57dXScd7eizuu6/Xsoz RWcB2hbJ0X4ME0OmEXQDd0BzMCwocyiVhSTB9mVSAaNoMYutDxpQPnT3UKuH4t9tVShhF5 OjRqDhsC2K5Bq2p6ns3KCRbwkaQRkl6VfJ8y0j/piQVPhGmvwRVwU9q0Hz9Mfx+D+HkD6X ryL+PjEjO8vxV91FRHa8wklRps4rT8AyJzeD5teZQKi9z2bvifA0gEL/4T6SPuKuYclIjf GaEgm+RJlFXteoSl+IAmz0LBuzLCqEH++JclgnoHwmN7bbVfoA6aSxprEVj/Xw== 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 65C0C1C0015; Wed, 14 Jun 2023 07:49:30 +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 v4 03/13] iio: inkern: Check error explicitly in iio_channel_read_max() Date: Wed, 14 Jun 2023 09:48:54 +0200 Message-Id: <20230614074904.29085-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230614074904.29085-1-herve.codina@bootlin.com> References: <20230614074904.29085-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_NONE, 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?1768663700102655109?= X-GMAIL-MSGID: =?utf-8?q?1768663700102655109?= |
Series |
Add support for IIO devices in ASoC
|
|
Commit Message
Herve Codina
June 14, 2023, 7:48 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(-)
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; } }