From af32e02ec9276897951fb3868fbe699326c59717 Mon Sep 17 00:00:00 2001 From: David Wu Date: Wed, 13 Feb 2019 17:29:08 +0800 Subject: [PATCH] iio: adc: rockchip: Don't return fail at probe when the regulator is dummy If the referenced regulator is a dummy, the voltage is invalid, but someone doesn't need the voltage, just need the adc value, so don't return fail at probe when the regulator is dummy. If he wants the voltage, configures the actual referenced regulator at dts. Change-Id: I8eaecc1a8e7e57c3a87aa69b9b852735bf4a025a Signed-off-by: David Wu --- drivers/iio/adc/rockchip_saradc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c index 2d6389b5b430..1882961f54ba 100644 --- a/drivers/iio/adc/rockchip_saradc.c +++ b/drivers/iio/adc/rockchip_saradc.c @@ -93,6 +93,10 @@ 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: + /* It is a dummy regulator */ + if (info->uv_vref < 0) + return info->uv_vref; + *val = info->uv_vref / 1000; *val2 = info->data->num_bits; return IIO_VAL_FRACTIONAL_LOG2; @@ -293,11 +297,6 @@ static int rockchip_saradc_probe(struct platform_device *pdev) } 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; - goto err_reg_voltage; - } ret = clk_prepare_enable(info->pclk); if (ret < 0) {