Commit eb54ddd4 authored by Eric Millbrandt's avatar Eric Millbrandt Committed by Dmitry Torokhov

Input: wm97xx-core - add retries to wm97xx_read_aux_adc

Add logic to wm97xx_read_aux_adc() to retry reading the adc if the
sample failed.  This could occur if the previous sample was still in
the return register or the sample timed-out.  Also avoid a pathologic
failure mode by disabling the digitizer and returning -EBUSY after 5
retries.
Signed-off-by: default avatarEric Millbrandt <emillbrandt@dekaresearch.com>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent d3622e6f
...@@ -125,6 +125,8 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel) ...@@ -125,6 +125,8 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel)
{ {
int power_adc = 0, auxval; int power_adc = 0, auxval;
u16 power = 0; u16 power = 0;
int rc = 0;
int timeout = 0;
/* get codec */ /* get codec */
mutex_lock(&wm->codec_mutex); mutex_lock(&wm->codec_mutex);
...@@ -143,7 +145,9 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel) ...@@ -143,7 +145,9 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel)
/* Turn polling mode on to read AUX ADC */ /* Turn polling mode on to read AUX ADC */
wm->pen_probably_down = 1; wm->pen_probably_down = 1;
wm->codec->poll_sample(wm, adcsel, &auxval);
while (rc != RC_VALID && timeout++ < 5)
rc = wm->codec->poll_sample(wm, adcsel, &auxval);
if (power_adc) if (power_adc)
wm97xx_reg_write(wm, AC97_EXTENDED_MID, power | 0x8000); wm97xx_reg_write(wm, AC97_EXTENDED_MID, power | 0x8000);
...@@ -152,8 +156,15 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel) ...@@ -152,8 +156,15 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel)
wm->pen_probably_down = 0; wm->pen_probably_down = 0;
if (timeout >= 5) {
dev_err(wm->dev,
"timeout reading auxadc %d, disabling digitiser\n",
adcsel);
wm->codec->dig_enable(wm, false);
}
mutex_unlock(&wm->codec_mutex); mutex_unlock(&wm->codec_mutex);
return auxval & 0xfff; return (rc == RC_VALID ? auxval & 0xfff : -EBUSY);
} }
EXPORT_SYMBOL_GPL(wm97xx_read_aux_adc); EXPORT_SYMBOL_GPL(wm97xx_read_aux_adc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment