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=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED 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 07CB5C43381 for ; Sat, 16 Mar 2019 17:26:50 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C2448218FE for ; Sat, 16 Mar 2019 17:26:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="euWCsJWD"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="sfxIgnaY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2448218FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject: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=B/xBsKcnx7Kdjxbua6Z55zT7hCseQ/PvhUJ00oJGR1g=; b=euWCsJWDe5rwAQ Zm/UeSdM17FP2d3XbZd+PblXVqcReUtGVvt3B5vzR6wYSCFf4NZBQiy4/XLXsc5SeYDEavsgnPFUn 4iMNMhQCracji6qjtR1hCJAcGylAKBLKHPOuLVaBEw+b1YpnJNumJ6o5Jb4G2mx/oS/kNIMatTiIf ryCnJhti3E+Y8cJUBeqvjBkc8GMh3Wo5h4EVZoAZNgV6nFywfgcZmYg9i5Bq9OcrMAG2uafc9CDvr KrzlilKWVhaxukXqE94labsq8nST32D2g6lgwYUY6YJtcC/YICFmzykWDAGhJsA5fLuMD9FgwEU/g eIe1muZ5/bLmDuBMbcEw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5D52-0004qE-1r; Sat, 16 Mar 2019 17:26:44 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5D4y-0004pr-GL for linux-arm-kernel@lists.infradead.org; Sat, 16 Mar 2019 17:26:41 +0000 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (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 BD30F218E0; Sat, 16 Mar 2019 17:26:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552757200; bh=VU0rq3reJeDpVpe22htPUgcmEuUYpu353RKnyZe2zAQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=sfxIgnaYNjhLvtMnLx+9GCiTFgcKV3ShEfUuXfQhAsHeJgJPYPMh2AISS3ycimOS6 ZfOjMQdDxEXKu8T0YVbY5ZwuDN3KqBQDvVkITqCzXbt2C8OcwhnoamNIrPO/u6WSJM /R63sCSBBblsrmECDVlU/EWXr14DIx18Y1VqOi4U= Date: Sat, 16 Mar 2019 17:26:34 +0000 From: Jonathan Cameron To: Gregory CLEMENT Subject: Re: [PATCH v2 3/4] iio: adc: lpc32xx: Add scale feature Message-ID: <20190316172634.4bb51753@archlinux> In-Reply-To: <20190315095231.17001-4-gregory.clement@bootlin.com> References: <20190315095231.17001-1-gregory.clement@bootlin.com> <20190315095231.17001-4-gregory.clement@bootlin.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; 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-20190316_102640_580323_DC5B40B9 X-CRM114-Status: GOOD ( 20.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Lars-Peter Clausen , Thomas Petazzoni , linux-iio@vger.kernel.org, Hartmut Knaack , Vladimir Zapolskiy , Rob Herring , Peter Meerwald-Stadler , Sylvain Lemieux , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 15 Mar 2019 10:52:30 +0100 Gregory CLEMENT wrote: > Until now this driver only exposed the raw value of the channels. With > this patch, the scale value is also exposed. > > It depends of a regulator supply, and unlike most of the other driver, do > not having this regulator won't prevent to use the driver. The reason for > it is to allow to continue to use this driver with an old device tree. If > there is no regulator supply then the scale won't be exposed. > > Signed-off-by: Gregory CLEMENT I made a minor tweak to downgrade the message if the regulator isn't specified. Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > drivers/iio/adc/lpc32xx_adc.c | 44 ++++++++++++++++++++++++++++++----- > 1 file changed, 38 insertions(+), 6 deletions(-) > > diff --git a/drivers/iio/adc/lpc32xx_adc.c b/drivers/iio/adc/lpc32xx_adc.c > index f391c1e10136..5d1c76e3aad8 100644 > --- a/drivers/iio/adc/lpc32xx_adc.c > +++ b/drivers/iio/adc/lpc32xx_adc.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > > /* > * LPC32XX registers definitions > @@ -45,6 +46,7 @@ struct lpc32xx_adc_state { > void __iomem *adc_base; > struct clk *clk; > struct completion completion; > + struct regulator *vref; > > u32 value; > }; > @@ -57,7 +59,9 @@ static int lpc32xx_read_raw(struct iio_dev *indio_dev, > { > struct lpc32xx_adc_state *st = iio_priv(indio_dev); > int ret; > - if (mask == IIO_CHAN_INFO_RAW) { > + > + switch (mask) { > + case IIO_CHAN_INFO_RAW: > mutex_lock(&indio_dev->mlock); > ret = clk_prepare_enable(st->clk); > if (ret) { > @@ -77,22 +81,36 @@ static int lpc32xx_read_raw(struct iio_dev *indio_dev, > mutex_unlock(&indio_dev->mlock); > > return IIO_VAL_INT; > - } > > - return -EINVAL; > + case IIO_CHAN_INFO_SCALE: > + *val = regulator_get_voltage(st->vref) / 1000; > + *val2 = 10; > + > + return IIO_VAL_FRACTIONAL_LOG2; > + default: > + return -EINVAL; > + } > } > > static const struct iio_info lpc32xx_adc_iio_info = { > .read_raw = &lpc32xx_read_raw, > }; > > -#define LPC32XX_ADC_CHANNEL(_index) { \ > +#define LPC32XX_ADC_CHANNEL_BASE(_index) \ > .type = IIO_VOLTAGE, \ > .indexed = 1, \ > .channel = _index, \ > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ > .address = LPC32XXAD_IN * _index, \ > - .scan_index = _index, \ > + .scan_index = _index, > + > +#define LPC32XX_ADC_CHANNEL(_index) { \ > + LPC32XX_ADC_CHANNEL_BASE(_index) \ > +} > + > +#define LPC32XX_ADC_SCALE_CHANNEL(_index) { \ > + LPC32XX_ADC_CHANNEL_BASE(_index) \ > + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \ > } > > static const struct iio_chan_spec lpc32xx_adc_iio_channels[] = { > @@ -101,6 +119,12 @@ static const struct iio_chan_spec lpc32xx_adc_iio_channels[] = { > LPC32XX_ADC_CHANNEL(2), > }; > > +static const struct iio_chan_spec lpc32xx_adc_iio_scale_channels[] = { > + LPC32XX_ADC_SCALE_CHANNEL(0), > + LPC32XX_ADC_SCALE_CHANNEL(1), > + LPC32XX_ADC_SCALE_CHANNEL(2), > +}; > + > static irqreturn_t lpc32xx_adc_isr(int irq, void *dev_id) > { > struct lpc32xx_adc_state *st = dev_id; > @@ -159,6 +183,15 @@ static int lpc32xx_adc_probe(struct platform_device *pdev) > return retval; > } > > + st->vref = devm_regulator_get(&pdev->dev, "vref"); > + if (IS_ERR(st->vref)) { > + iodev->channels = lpc32xx_adc_iio_channels; > + dev_err(&pdev->dev, > + "Missing vref regulator: No scaling available\n"); It isn't an error, so downgraded to dev_info. > + } else { > + iodev->channels = lpc32xx_adc_iio_scale_channels; > + } > + > platform_set_drvdata(pdev, iodev); > > init_completion(&st->completion); > @@ -167,7 +200,6 @@ static int lpc32xx_adc_probe(struct platform_device *pdev) > iodev->dev.parent = &pdev->dev; > iodev->info = &lpc32xx_adc_iio_info; > iodev->modes = INDIO_DIRECT_MODE; > - iodev->channels = lpc32xx_adc_iio_channels; > iodev->num_channels = ARRAY_SIZE(lpc32xx_adc_iio_channels); > > retval = devm_iio_device_register(&pdev->dev, iodev); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel