Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a69d401 authored by Jishnu Prakash's avatar Jishnu Prakash Committed by Gerrit - the friendly Code Review server
Browse files

iio: adc: Update error handling for ADC reading



Add error check to ensure that the ADC conversion API exits
immediately with error if invalid value is read from conversion
result registers.

Change-Id: I31d049b6abc6cbb9b79811fd9cbdfacfdb730ba2
Signed-off-by: default avatarJishnu Prakash <jprakash@codeaurora.org>
parent fd8f045d
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -541,14 +541,19 @@ static int adc_do_conversion(struct adc_chip *adc,
	if (ret < 0)
		goto unlock;

	if ((chan->type == IIO_VOLTAGE) || (chan->type == IIO_TEMP))
	if ((chan->type == IIO_VOLTAGE) || (chan->type == IIO_TEMP)) {
		ret = adc_read_voltage_data(adc, data_volt);
		if (ret)
			goto unlock;
	}
	else if (chan->type == IIO_POWER) {
		ret = adc_read_voltage_data(adc, data_volt);
		if (ret)
			goto unlock;

		ret = adc_read_current_data(adc, data_cur);
		if (ret)
			goto unlock;
	}

	ret = adc_post_configure_usb_in_read(adc, prop);