From 8c20990f433abaa441ffc65b68836a908ff62e5d Mon Sep 17 00:00:00 2001 From: Subbaraman Narayanamurthy Date: Tue, 19 Sep 2017 20:16:43 -0700 Subject: [PATCH] iio: qcom-rradc: Disable continuous mode when read fails Currently, when a channel is read in continuous mode and the read operation fails, RR_ADC would be left enabled in continuous mode. Disable the continuous mode in such cases so that the other read operations which doesn't need continuous mode can go through. Change-Id: I2bf257bd535e1e4a30e18b6257e584a5be96b69d Signed-off-by: Subbaraman Narayanamurthy Signed-off-by: Siddartha Mohanadoss --- drivers/iio/adc/qcom-rradc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/qcom-rradc.c b/drivers/iio/adc/qcom-rradc.c index 8b3c771acd78..b3aa73f1a5a1 100644 --- a/drivers/iio/adc/qcom-rradc.c +++ b/drivers/iio/adc/qcom-rradc.c @@ -793,7 +793,7 @@ static int rradc_check_status_ready_with_retry(struct rradc_chip *chip, static int rradc_read_channel_with_continuous_mode(struct rradc_chip *chip, struct rradc_chan_prop *prop, u8 *buf) { - int rc = 0; + int rc = 0, ret = 0; u16 status = 0; rc = rradc_enable_continuous_mode(chip); @@ -806,23 +806,25 @@ static int rradc_read_channel_with_continuous_mode(struct rradc_chip *chip, rc = rradc_read(chip, status, buf, 1); if (rc < 0) { pr_err("status read failed:%d\n", rc); - return rc; + ret = rc; + goto disable; } rc = rradc_check_status_ready_with_retry(chip, prop, buf, status); if (rc < 0) { pr_err("Status read failed:%d\n", rc); - return rc; + ret = rc; } +disable: rc = rradc_disable_continuous_mode(chip); if (rc < 0) { pr_err("Failed to switch to non continuous mode\n"); - return rc; + ret = rc; } - return rc; + return ret; } static int rradc_enable_batt_id_channel(struct rradc_chip *chip, bool enable) -- 2.11.0