Skip to content

Commit

Permalink
iio: adc: modify NPCM ADC read reference voltage
Browse files Browse the repository at this point in the history
Checking if regulator is valid before reading
NPCM ADC regulator voltage to avoid system crash
in a case the regulator is not valid.

Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
  • Loading branch information
Tomer Maimon authored and Jonathan Cameron committed Apr 7, 2019
1 parent 131ac62 commit 4e63ed6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iio/adc/npcm_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static int npcm_adc_read_raw(struct iio_dev *indio_dev,
}
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
if (info->vref) {
if (!IS_ERR(info->vref)) {
vref_uv = regulator_get_voltage(info->vref);
*val = vref_uv / 1000;
} else {
Expand Down

0 comments on commit 4e63ed6

Please sign in to comment.