iio: stmpe-adc: Reinit completion struct on begin conversion
authorPhilippe Schenker <philippe.schenker@toradex.com>
Tue, 7 May 2019 14:36:12 +0000 (16:36 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 11 May 2019 10:00:11 +0000 (11:00 +0100)
In some cases, the wait_completion got interrupted. This caused the
error-handling to mutex_unlock the function. The before turned on
interrupt then got called anyway. In the ISR then completion() was
called causing wrong adc-values returned in a following adc-readout.

Reinitialise completion struct to make sure the counter is zero
when beginning a new adc-conversion.

Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/stmpe-adc.c

index da6cab88af53e54293c038ca6cbb0693d3d141f8..5940bb8085b247d96d48bad05be1e4c68e41f70d 100644 (file)
@@ -65,6 +65,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info,
 
        mutex_lock(&info->lock);
 
+       reinit_completion(&info->completion);
+
        info->channel = (u8)chan->channel;
 
        if (info->channel > STMPE_ADC_LAST_NR) {
@@ -103,6 +105,8 @@ static int stmpe_read_temp(struct stmpe_adc *info,
 
        mutex_lock(&info->lock);
 
+       reinit_completion(&info->completion);
+
        info->channel = (u8)chan->channel;
 
        if (info->channel != STMPE_TEMP_CHANNEL) {