From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8FBBEC43334 for ; Sat, 11 Jun 2022 16:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RLIrgPwGwPRsyKv07bDxkAlrGDpb5h4bRRC3F5F5dT4=; b=iMGgYwOeTv2D9D k6EsJTVJ79dUrlhLPtVnuJqHVC2LwRj41KIRVSJsKAy9/5YJSr+tKv38E994cwcVJqDF9Sld2OZBz Apr+FbTBRGWF3ZSwfgBv2tXjQ9k+um2tpTX2t9fSXSxDOlRGxxnmOzRU9UbW3zkq0PZUxWvD+xXpf vOH9/Eod3FTSrhBJqddZeT2V6KlNrzAxPbeDx2QVc+N3KRzig4dR+Meah9kpZAO+O6yRCnGKwjMS7 jMe1w0HGgvO8A8+fKORHhO+pbWk7g92FBxNSnIu/N/tmqtz76n9w0ZVrEwGX9//gMGevk6git8BIX 8DOETkWWA4ED/VyZ423w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o03ab-00DivQ-0T; Sat, 11 Jun 2022 16:03:53 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o03aX-00Diuk-Hw for linux-arm-kernel@lists.infradead.org; Sat, 11 Jun 2022 16:03:51 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EFE62B802C7; Sat, 11 Jun 2022 16:03:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17F1DC34116; Sat, 11 Jun 2022 16:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654963426; bh=pXHToWyY4mQlOO2SpdBWrNbDgW1ppK7DRYcXS5SEyLY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=uwuPyfLgxPj2gsic7f2BhqkH5xVXwidkQq9VAN0ltcK0I6r804hmrQwTTpOF5QIHd uXy5fSoBEPOSosIa3OpoK0MIezJFgnXjHErvmsSIKjZqpy63mD2f1WwDaukkaxYmuf zQ/KJU5IJ82sTzb6/XhUsi9VU9zhn24o76wG/Z649z3gHYQk+/VAFYPBVDC8f6UEu+ y2rhrimXdZtLOE29TPlhdDkeGhzHSlM//EkV3QpCtWSgpE/Z+whCiPgIhg2Hy1lQce skzlD5swkGL11Ax5ZdaqtvPDh9sKZHspPm30rb37TMBMIdghRO+QtMLbd6gpMfW6+g qJ7qr+aD/GCdQ== Date: Sat, 11 Jun 2022 17:12:55 +0100 From: Jonathan Cameron To: Olivier Moysan Cc: Alexandre Torgue , Fabrice Gasnier , Lars-Peter Clausen , Maxime Coquelin , Paul Cercueil , Wan Jiabing , , , , Subject: Re: [PATCH] iio: adc: stm32: fix vrefint wrong calibration value handling Message-ID: <20220611171255.6cbc16c0@jic23-huawei> In-Reply-To: <20220609095856.376961-1-olivier.moysan@foss.st.com> References: <20220609095856.376961-1-olivier.moysan@foss.st.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220611_090349_941385_6C5BFAE2 X-CRM114-Status: GOOD ( 26.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 9 Jun 2022 11:58:56 +0200 Olivier Moysan wrote: > If the vrefint calibration is zero, the vrefint channel output value > cannot be computed. Currently, in such case, the raw conversion value > is returned, which is not relevant. > Do not expose the vrefint channel when the output value cannot be > computed, instead. > > Fixes: 0e346b2cfa85 ("iio: adc: stm32-adc: add vrefint calibration support") > No line break here. Fixes is part of the tag block (and a pull request sent with this gap will get rejected). Fixed up whilst applying. > Signed-off-by: Olivier Moysan Applied to the fixes-togreg branch of iiogit. I initially wondered if using -ENOENT for this was safe in that it couldn't come from anywhere else. Looks like it is given how little this function does so fair enough. Thanks, Jonathan > --- > drivers/iio/adc/stm32-adc.c | 27 +++++++++++++++++---------- > 1 file changed, 17 insertions(+), 10 deletions(-) > > diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c > index a68ecbda6480..f13c112f540f 100644 > --- a/drivers/iio/adc/stm32-adc.c > +++ b/drivers/iio/adc/stm32-adc.c > @@ -1365,7 +1365,7 @@ static int stm32_adc_read_raw(struct iio_dev *indio_dev, > else > ret = -EINVAL; > > - if (mask == IIO_CHAN_INFO_PROCESSED && adc->vrefint.vrefint_cal) > + if (mask == IIO_CHAN_INFO_PROCESSED) > *val = STM32_ADC_VREFINT_VOLTAGE * adc->vrefint.vrefint_cal / *val; > > iio_device_release_direct_mode(indio_dev); > @@ -1979,10 +1979,10 @@ static int stm32_adc_populate_int_ch(struct iio_dev *indio_dev, const char *ch_n > > for (i = 0; i < STM32_ADC_INT_CH_NB; i++) { > if (!strncmp(stm32_adc_ic[i].name, ch_name, STM32_ADC_CH_SZ)) { > - adc->int_ch[i] = chan; > - > - if (stm32_adc_ic[i].idx != STM32_ADC_INT_CH_VREFINT) > - continue; > + if (stm32_adc_ic[i].idx != STM32_ADC_INT_CH_VREFINT) { > + adc->int_ch[i] = chan; > + break; > + } > > /* Get calibration data for vrefint channel */ > ret = nvmem_cell_read_u16(&indio_dev->dev, "vrefint", &vrefint); > @@ -1990,10 +1990,15 @@ static int stm32_adc_populate_int_ch(struct iio_dev *indio_dev, const char *ch_n > return dev_err_probe(indio_dev->dev.parent, ret, > "nvmem access error\n"); > } > - if (ret == -ENOENT) > - dev_dbg(&indio_dev->dev, "vrefint calibration not found\n"); > - else > - adc->vrefint.vrefint_cal = vrefint; > + if (ret == -ENOENT) { > + dev_dbg(&indio_dev->dev, "vrefint calibration not found. Skip vrefint channel\n"); > + return ret; > + } else if (!vrefint) { > + dev_dbg(&indio_dev->dev, "Null vrefint calibration value. Skip vrefint channel\n"); > + return -ENOENT; > + } > + adc->int_ch[i] = chan; > + adc->vrefint.vrefint_cal = vrefint; > } > } > > @@ -2030,7 +2035,9 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev, > } > strncpy(adc->chan_name[val], name, STM32_ADC_CH_SZ); > ret = stm32_adc_populate_int_ch(indio_dev, name, val); > - if (ret) > + if (ret == -ENOENT) > + continue; > + else if (ret) > goto err; > } else if (ret != -EINVAL) { > dev_err(&indio_dev->dev, "Invalid label %d\n", ret); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel