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 X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9DAEC433FE for ; Sun, 5 Sep 2021 11:17:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD79B60F4A for ; Sun, 5 Sep 2021 11:17:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230390AbhIELSE (ORCPT ); Sun, 5 Sep 2021 07:18:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:40940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230145AbhIELSD (ORCPT ); Sun, 5 Sep 2021 07:18:03 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 21362608FB; Sun, 5 Sep 2021 11:16:54 +0000 (UTC) Date: Sun, 5 Sep 2021 12:20:17 +0100 From: Jonathan Cameron To: Hui Liu Cc: , , , , , , , , , , , , , , , Subject: Re: [PATCH v2 1/1] iio: mtk-auxadc: update case IIO_CHAN_INFO_PROCESSED Message-ID: <20210905122017.645dd9b3@jic23-huawei> In-Reply-To: <20210831054207.13236-2-hui.liu@mediatek.com> References: <20210831054207.13236-1-hui.liu@mediatek.com> <20210831054207.13236-2-hui.liu@mediatek.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Tue, 31 Aug 2021 13:42:07 +0800 Hui Liu wrote: > Convert raw data to processed data, the processed data is input voltage. > > Signed-off-by: Hui Liu Looks very much to be a fix. Please track down appropriate patch and let me know what the Fixes: tag should be. If you reply to this thread I'll add it plus a not saying it is an ABI change, but a necessary one as the driver was previously buggy. Whilst we are here, what is the cali_data() function actually there for? Seems to only set *val = *val which is rather pointless. Thanks, Jonathan > --- > drivers/iio/adc/mt6577_auxadc.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c > index 79c1dd68b909..d4fccd52ef08 100644 > --- a/drivers/iio/adc/mt6577_auxadc.c > +++ b/drivers/iio/adc/mt6577_auxadc.c > @@ -82,6 +82,10 @@ static const struct iio_chan_spec mt6577_auxadc_iio_channels[] = { > MT6577_AUXADC_CHANNEL(15), > }; > > +/* For Voltage calculation */ > +#define VOLTAGE_FULL_RANGE 1500 /* VA voltage */ > +#define AUXADC_PRECISE 4096 /* 12 bits */ > + > static int mt_auxadc_get_cali_data(int rawdata, bool enable_cali) > { > return rawdata; > @@ -191,6 +195,10 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev, > } > if (adc_dev->dev_comp->sample_data_cali) > *val = mt_auxadc_get_cali_data(*val, true); > + > + /* Convert adc raw data to voltage: 0 - 1500 mV */ > + *val = *val * VOLTAGE_FULL_RANGE / AUXADC_PRECISE; > + > return IIO_VAL_INT; > > default: