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 D35FDC43216 for ; Mon, 30 Aug 2021 14:20:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6C4960F57 for ; Mon, 30 Aug 2021 14:20:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237105AbhH3OVj (ORCPT ); Mon, 30 Aug 2021 10:21:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:33138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237015AbhH3OVi (ORCPT ); Mon, 30 Aug 2021 10:21:38 -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 EC4DE60F23; Mon, 30 Aug 2021 14:20:38 +0000 (UTC) Date: Mon, 30 Aug 2021 15:23:51 +0100 From: Jonathan Cameron To: Miquel Raynal Cc: Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring , Lee Jones , bcousson@baylibre.com, Tony Lindgren , Tero Kristo , Michael Turquette , Stephen Boyd , Thomas Petazzoni , "Ryan J . Barnett" , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-omap@vger.kernel.org, linux-clk@vger.kernel.org Subject: Re: [PATCH 36/40] iio: adc: ti_am335x_adc: Add the scale information Message-ID: <20210830152351.175946db@jic23-huawei> In-Reply-To: <20210825152518.379386-37-miquel.raynal@bootlin.com> References: <20210825152518.379386-1-miquel.raynal@bootlin.com> <20210825152518.379386-37-miquel.raynal@bootlin.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 Wed, 25 Aug 2021 17:25:14 +0200 Miquel Raynal wrote: > Without the scale, the values returned to the user are just a picture of > the input voltage against the full scale range of the ADC. We need to > provide the actual conversion factor to get milli-Volts values. > > Signed-off-by: Miquel Raynal Odd no one did this before, but such is life ;) Acked-by: Jonathan Cameron > --- > drivers/iio/adc/ti_am335x_adc.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c > index d4619fd6fd54..f644898b47dd 100644 > --- a/drivers/iio/adc/ti_am335x_adc.c > +++ b/drivers/iio/adc/ti_am335x_adc.c > @@ -417,6 +417,7 @@ static int tiadc_channel_init(struct device *dev, struct iio_dev *indio_dev, > chan->indexed = 1; > chan->channel = adc_dev->channel_line[i]; > chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW); > + chan->info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE); > chan->datasheet_name = chan_name_ain[chan->channel]; > chan->scan_index = i; > chan->scan_type.sign = 'u'; > @@ -441,6 +442,23 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, > unsigned long timeout; > int ret; > > + switch (mask) { > + case IIO_CHAN_INFO_RAW: > + break; > + case IIO_CHAN_INFO_SCALE: > + switch (chan->type) { > + case IIO_VOLTAGE: > + *val = 1800; > + *val2 = chan->scan_type.realbits; > + return IIO_VAL_FRACTIONAL_LOG2; > + default: > + return -EINVAL; > + } > + break; > + default: > + return -EINVAL; > + } > + > if (iio_buffer_enabled(indio_dev)) > return -EBUSY; >