Skip to contentSkip to conversation

iio: adc: modify NPCM ADC read reference voltage

PATCH Applied Tomer Maimon 2 participants 2 messages Apr 7, 2019

Subsystems (2)
lore
Share & tools
lore

Tomer Maimon

author maintainer
#0 lore raw

PATCH 1/1 iio: adc: modify NPCM ADC read reference voltage

Checking if regulator is valid before reading
NPCM ADC regulator voltage to avoid system crash
in a case the regulator is not valid.

---
 drivers/iio/adc/npcm_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/npcm_adc.c +1 -1
index 9e25bbec9c70..193b3b81de4d 100644
@@ -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 {
Signature · 1 line
2.14.1
maintainer Applied
#1 lore raw
Quoted 5 lines · On Sun, 7 Apr 2019 11:19:28 +0300 Tomer Maimon <[email protected]> wrote:

Checking if regulator is valid before reading
NPCM ADC regulator voltage to avoid system crash
in a case the regulator is not valid.

Good catch.

Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

Quoted 17 lines
---
 drivers/iio/adc/npcm_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/npcm_adc.c +1 -1
index 9e25bbec9c70..193b3b81de4d 100644
@@ -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 {