Skip to content

Commit b24c623

Browse files
SuperDavidWurkhuangtao
authored andcommitted
iio: adc: rockchip_saradc: Just get referenced voltage once at probe
The referenced voltage is not changed after initiation, so just only get referenced voltage once. Change-Id: I1eeab03f68855fafe010db328ec7bbcfa7d52310 Signed-off-by: David Wu <david.wu@rock-chips.com>
1 parent 5c97311 commit b24c623

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

drivers/iio/adc/rockchip_saradc.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct rockchip_saradc {
5555
struct clk *clk;
5656
struct completion completion;
5757
struct regulator *vref;
58+
int uv_vref;
5859
struct reset_control *reset;
5960
const struct rockchip_saradc_data *data;
6061
u16 last_val;
@@ -65,7 +66,6 @@ static int rockchip_saradc_read_raw(struct iio_dev *indio_dev,
6566
int *val, int *val2, long mask)
6667
{
6768
struct rockchip_saradc *info = iio_priv(indio_dev);
68-
int ret;
6969

7070
switch (mask) {
7171
case IIO_CHAN_INFO_RAW:
@@ -93,13 +93,7 @@ static int rockchip_saradc_read_raw(struct iio_dev *indio_dev,
9393
mutex_unlock(&indio_dev->mlock);
9494
return IIO_VAL_INT;
9595
case IIO_CHAN_INFO_SCALE:
96-
ret = regulator_get_voltage(info->vref);
97-
if (ret < 0) {
98-
dev_err(&indio_dev->dev, "failed to get voltage\n");
99-
return ret;
100-
}
101-
102-
*val = ret / 1000;
96+
*val = info->uv_vref / 1000;
10397
*val2 = info->data->num_bits;
10498
return IIO_VAL_FRACTIONAL_LOG2;
10599
default:
@@ -298,6 +292,13 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
298292
return ret;
299293
}
300294

295+
info->uv_vref = regulator_get_voltage(info->vref);
296+
if (info->uv_vref < 0) {
297+
dev_err(&pdev->dev, "failed to get voltage\n");
298+
ret = info->uv_vref;
299+
goto err_reg_voltage;
300+
}
301+
301302
ret = clk_prepare_enable(info->pclk);
302303
if (ret < 0) {
303304
dev_err(&pdev->dev, "failed to enable pclk\n");

0 commit comments

Comments
 (0)