Skip to content

Commit

Permalink
staging: iio: adc: ad7192: fail probe on get_voltage
Browse files Browse the repository at this point in the history
This patch makes the ad7192_probe fail in case
regulator_get_voltage will return an error or voltage
is set to 0.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
Alexandru Tachici authored and Jonathan Cameron committed Mar 8, 2020
1 parent 1d8690f commit ab0afa6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/staging/iio/adc/ad7192.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,13 @@ static int ad7192_probe(struct spi_device *spi)

voltage_uv = regulator_get_voltage(st->avdd);

if (voltage_uv)
if (voltage_uv > 0) {
st->int_vref_mv = voltage_uv / 1000;
else
} else {
ret = voltage_uv;
dev_err(&spi->dev, "Device tree error, reference voltage undefined\n");
goto error_disable_avdd;
}

spi_set_drvdata(spi, indio_dev);
st->devid = spi_get_device_id(spi)->driver_data;
Expand Down

0 comments on commit ab0afa6

Please sign in to comment.