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 3A614C43334 for ; Thu, 9 Jun 2022 12:24:34 +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:In-Reply-To:From:References:CC:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Fh87EWWr2lvKGyrS/y1VIWRIK/iFtYaoU3q5cXe5MQM=; b=LZWUuGRa/yVJ3z zIJqSL8n4Ox+zh0ccQLRHQIty+IOXvyUkDkuuuwRSWJJ5Uhl7S2skSbMSRhDrI+YfhJ1LddHt0mJC rRg3J4KRRemTnEAl4INlWzOZ+iQmQEcpAs1LO190o0CeRyhGJvmuA4j83xxN1Yzcw4Q+oHfxCA58x +mHJqVucnzsCiR3HJFtWOfeRKdRoHCmNWj6EleZmjGjDkHqJt50rSeCHeOMGJfedTYbH9Fja3bxFd bTMvGXqne1R123O8+sCt4AZCrJ00RbLWL/UBU41CO5FAaOSOVU6SG3fa1cvjY4f5jhVMMAUG7RcRa ZJsvz+oN+AlG0GZnrmXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzHBm-001hf4-SW; Thu, 09 Jun 2022 12:23:03 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzH3g-001dkV-MF for linux-arm-kernel@lists.infradead.org; Thu, 09 Jun 2022 12:14:43 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2598eb83003698; Thu, 9 Jun 2022 14:14:24 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=dihmS9b4+ZD15BfhGqktp7iB3RHiJWGEWYwAh8uOGfQ=; b=Gabn07qE8OwQ5z7NE3OhIVdNPVDZEO7iRmwlDpdQolnbI3JsOec3Bp3dFBE88w4SO/W4 Hj2mvq4vSHwaT/hGS4y8vbPKJIqi4MsVsWI9oom00z7wLFL3VtAOmvwJafOlj81Wx0Tq AthLjVxxJnLu6ROl/YSL8dLeWQTg7riuMMHb3Ag9gjOccVqeeFpsZivxTVKMw74RGtY/ L/xhgI3rTG9jNkLX95/y1Fs8Naxtj/eV5j3an7WfMcsLUNtoy9O/hj+3tKiJ6ZDNJNSK 02le+f9BlXiVbZ4CJHnCxml9SsS0YGz7Mx4qOZH2qurqr0qGLNR180vwjtfBIzbC55Pt qQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3gjqqw1kee-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 09 Jun 2022 14:14:23 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 42BAE10002A; Thu, 9 Jun 2022 14:14:23 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node2.st.com [10.75.129.70]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 36B522171EC; Thu, 9 Jun 2022 14:14:23 +0200 (CEST) Received: from [10.48.1.102] (10.75.127.47) by SHFDAG1NODE2.st.com (10.75.129.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Thu, 9 Jun 2022 14:14:21 +0200 Message-ID: Date: Thu, 9 Jun 2022 14:14:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] iio: adc: stm32: fix vrefint wrong calibration value handling Content-Language: en-US To: Olivier Moysan , Alexandre Torgue , Jonathan Cameron , Lars-Peter Clausen , Maxime Coquelin , Paul Cercueil , Wan Jiabing CC: , , , References: <20220609095856.376961-1-olivier.moysan@foss.st.com> From: Fabrice Gasnier In-Reply-To: <20220609095856.376961-1-olivier.moysan@foss.st.com> X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SHFDAG1NODE2.st.com (10.75.129.70) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-09_09,2022-06-09_01,2022-02-23_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_051441_616529_8E3822DB X-CRM114-Status: GOOD ( 23.97 ) 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 6/9/22 11:58, 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") > > Signed-off-by: Olivier Moysan Hi Olivier, You can add my: Reviewed-by: Fabrice Gasnier Thanks, Fabrice > --- > 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