devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: rockchip_saradc: just get referenced voltage once at probe
@ 2021-08-02  9:09 Simon Xue
  2021-08-02 10:42 ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Xue @ 2021-08-02  9:09 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-rockchip, devicetree, robh+dt, Johan Jonker, Heiko Stuebner,
	Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, David Wu,
	Simon Xue

From: David Wu <david.wu@rock-chips.com>

The referenced voltage is not changed after initiation, so just only
get referenced voltage once.

Signed-off-by: Simon Xue <xxm@rock-chips.com>
Signed-off-by: David Wu <david.wu@rock-chips.com>
---
 drivers/iio/adc/rockchip_saradc.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
index f3eb8d2e50dc..cd33c0b9d3eb 100644
--- a/drivers/iio/adc/rockchip_saradc.c
+++ b/drivers/iio/adc/rockchip_saradc.c
@@ -49,6 +49,7 @@ struct rockchip_saradc {
 	struct clk		*clk;
 	struct completion	completion;
 	struct regulator	*vref;
+	int			uv_vref;
 	struct reset_control	*reset;
 	const struct rockchip_saradc_data *data;
 	u16			last_val;
@@ -105,13 +106,7 @@ static int rockchip_saradc_read_raw(struct iio_dev *indio_dev,
 		mutex_unlock(&indio_dev->mlock);
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-		ret = regulator_get_voltage(info->vref);
-		if (ret < 0) {
-			dev_err(&indio_dev->dev, "failed to get voltage\n");
-			return ret;
-		}
-
-		*val = ret / 1000;
+		*val = info->uv_vref / 1000;
 		*val2 = chan->scan_type.realbits;
 		return IIO_VAL_FRACTIONAL_LOG2;
 	default:
@@ -410,6 +405,13 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	info->uv_vref = regulator_get_voltage(info->vref);
+	if (info->uv_vref < 0) {
+		dev_err(&pdev->dev, "failed to get voltage\n");
+		ret = info->uv_vref;
+		return ret;
+	}
+
 	ret = clk_prepare_enable(info->pclk);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to enable pclk\n");
-- 
2.25.1




^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-08-06  7:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-02  9:09 [PATCH] iio: adc: rockchip_saradc: just get referenced voltage once at probe Simon Xue
2021-08-02 10:42 ` Jonathan Cameron
2021-08-03  3:09   ` David Wu
2021-08-03 12:51     ` Jonathan Cameron
2021-08-05 11:56       ` David Wu
2021-08-05 12:07         ` Heiko Stübner
2021-08-06  7:09           ` David Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).