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 <david.wu@rock-chips.com>
This commit is contained in:
David Wu
2019-02-13 17:29:08 +08:00
committed by Tao Huang
parent 6e34d6d8e2
commit af32e02ec9

View File

@@ -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) {