From patchwork Thu Sep 2 18:12:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Millbrandt X-Patchwork-Id: 150031 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o82IIMMs001156 for ; Thu, 2 Sep 2010 18:18:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753806Ab0IBSSW (ORCPT ); Thu, 2 Sep 2010 14:18:22 -0400 Received: from mail.dekaresearch.com ([208.65.175.196]:12869 "EHLO dekaexchange07.deka.local" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753152Ab0IBSSV convert rfc822-to-8bit (ORCPT ); Thu, 2 Sep 2010 14:18:21 -0400 Received: from localhost.localdomain (10.1.1.72) by dekaexchange07.deka.local (10.1.1.12) with Microsoft SMTP Server id 8.1.240.5; Thu, 2 Sep 2010 14:21:24 -0400 From: Eric Millbrandt To: Liam Girdwood , Mark Brown CC: linux-input@vger.kernel.org, Eric Millbrandt Subject: [PATCH] Input: wm97xx-core - add retries to wm97xx_read_aux_adc Date: Thu, 2 Sep 2010 14:12:06 -0400 Message-ID: <1283451126-26669-1-git-send-email-emillbrandt@dekaresearch.com> X-Mailer: git-send-email 1.6.3.1 MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 02 Sep 2010 18:18:23 +0000 (UTC) diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c index cbfef1e..b376cee 100644 --- a/drivers/input/touchscreen/wm97xx-core.c +++ b/drivers/input/touchscreen/wm97xx-core.c @@ -125,6 +125,8 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel) { int power_adc = 0, auxval; u16 power = 0; + int rc = 0; + int timeout = 0; /* get codec */ mutex_lock(&wm->codec_mutex); @@ -143,7 +145,10 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel) /* Turn polling mode on to read AUX ADC */ 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) wm97xx_reg_write(wm, AC97_EXTENDED_MID, power | 0x8000); @@ -152,8 +157,11 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel) wm->pen_probably_down = 0; + if (timeout >= 5) + wm->codec->dig_enable(wm, false); + mutex_unlock(&wm->codec_mutex); - return auxval & 0xfff; + return (rc == RC_VALID ? auxval & 0xfff : -EBUSY); } EXPORT_SYMBOL_GPL(wm97xx_read_aux_adc);