[PATCH] iio: adc: mt6360: Handle error in cleanup path correctly
Haotian Zhang
vulab at iscas.ac.cn
Sun Sep 28 19:53:58 PDT 2025
The return value of a regmap_raw_write() in the cleanup path was
being ignored.
Fix this by checking the return value and propagating the error.
Fixes: 1f4877218f7e ("iio: adc: mt6360: Add ADC driver for MT6360")
Signed-off-by: Haotian Zhang <vulab at iscas.ac.cn>
---
drivers/iio/adc/mt6360-adc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c
index 69b3569c90e5..97c4af8a93fc 100644
--- a/drivers/iio/adc/mt6360-adc.c
+++ b/drivers/iio/adc/mt6360-adc.c
@@ -70,6 +70,7 @@ static int mt6360_adc_read_channel(struct mt6360_adc_data *mad, int channel, int
ktime_t predict_end_t, timeout;
unsigned int pre_wait_time;
int ret;
+ int cleanup_ret;
mutex_lock(&mad->adc_lock);
@@ -130,11 +131,15 @@ static int mt6360_adc_read_channel(struct mt6360_adc_data *mad, int channel, int
out_adc_conv:
/* Only keep ADC enable */
adc_enable = cpu_to_be16(MT6360_ADCEN_MASK);
- regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, &adc_enable, sizeof(adc_enable));
+ cleanup_ret = regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG,
+ &adc_enable, sizeof(adc_enable));
+ if (ret >= 0)
+ ret = cleanup_ret;
mad->last_off_timestamps[channel] = ktime_get();
/* Config prefer channel to NO_PREFER */
regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK,
MT6360_NO_PREFER << MT6360_PREFERCH_SHFT);
+
out_adc_lock:
mutex_unlock(&mad->adc_lock);
--
2.50.1.windows.1
More information about the linux-arm-kernel
mailing list