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 a220765c61
commit 72dd938512

View File

@@ -116,6 +116,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 = chan->scan_type.realbits;
return IIO_VAL_FRACTIONAL_LOG2;