diff mbox

[PATCHv4,1/4] mfd: da9052: fix manual ADC read after timed out read

Message ID 20170630143506.10541-2-sebastian.reichel@collabora.co.uk (mailing list archive)
State Superseded
Headers show

Commit Message

Sebastian Reichel June 30, 2017, 2:35 p.m. UTC
It is possible that under heavy system load, the counter in the completion
struct, used for waiting for end of AD conversion, gets incremented twice.
To make sure the driver recovers from this situation, the completion struct
should be reinitialized.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
 drivers/mfd/da9052-core.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Lee Jones July 17, 2017, 10:49 a.m. UTC | #1
On Fri, 30 Jun 2017, Sebastian Reichel wrote:

> It is possible that under heavy system load, the counter in the completion
> struct, used for waiting for end of AD conversion, gets incremented twice.
> To make sure the driver recovers from this situation, the completion struct
> should be reinitialized.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> ---
>  drivers/mfd/da9052-core.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c
> index a88c2065d8ab..977418ca9117 100644
> --- a/drivers/mfd/da9052-core.c
> +++ b/drivers/mfd/da9052-core.c
> @@ -386,6 +386,8 @@ int da9052_adc_manual_read(struct da9052 *da9052, unsigned char channel)
>  
>  	mutex_lock(&da9052->auxadc_lock);
>  
> +	reinit_completion(&da9052->done);
> +
>  	/* Channel gets activated on enabling the Conversion bit */
>  	mux_sel = chan_mux[channel] | DA9052_ADC_MAN_MAN_CONV;
>
diff mbox

Patch

diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c
index a88c2065d8ab..977418ca9117 100644
--- a/drivers/mfd/da9052-core.c
+++ b/drivers/mfd/da9052-core.c
@@ -386,6 +386,8 @@  int da9052_adc_manual_read(struct da9052 *da9052, unsigned char channel)
 
 	mutex_lock(&da9052->auxadc_lock);
 
+	reinit_completion(&da9052->done);
+
 	/* Channel gets activated on enabling the Conversion bit */
 	mux_sel = chan_mux[channel] | DA9052_ADC_MAN_MAN_CONV;