From patchwork Thu Aug 18 01:57:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JJ Ding X-Patchwork-Id: 1075382 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7I1uVlk024102 for ; Thu, 18 Aug 2011 01:56:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754874Ab1HRBzW (ORCPT ); Wed, 17 Aug 2011 21:55:22 -0400 Received: from emcscan.emc.com.tw ([192.72.220.5]:4492 "EHLO emcscan.emc.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754859Ab1HRBzI (ORCPT ); Wed, 17 Aug 2011 21:55:08 -0400 Received: from unknown (HELO emc.com.tw) ([192.168.10.1]) by emcscan.emc.com.tw with ESMTP; 18 Aug 2011 09:55:07 +0800 Received: from localhost ([192.168.81.59]) by emc.com.tw (8.13.7+Sun/8.13.7) with ESMTP id p7I1t6dd008146; Thu, 18 Aug 2011 09:55:06 +0800 (CST) From: JJ Ding To: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Seth Forshee , Dmitry Torokhov , Aaron Huang , Tom Lin , Eric Piel , Daniel Kurtz , Chase Douglas , Henrik Rydberg , Alessandro Rubini , JJ Ding Subject: [PATCH 4/6] Input: elantech - work around EC buffer Date: Thu, 18 Aug 2011 09:57:07 +0800 Message-Id: <1313632629-23603-5-git-send-email-jj_ding@emc.com.tw> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1313632629-23603-1-git-send-email-jj_ding@emc.com.tw> References: <1313632629-23603-1-git-send-email-jj_ding@emc.com.tw> 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.6 (demeter2.kernel.org [140.211.167.43]); Thu, 18 Aug 2011 01:56:31 +0000 (UTC) With some EC chips, when we resync due to bad packets, those bad bytes would still remain in EC's buffer area. That makes us always get bad data back, no matter what. So shift packet for 1 byte when encounter bad packet, until we get rid of those bytes. Signed-off-by: JJ Ding Reviewed-by: Daniel Kurtz --- drivers/input/mouse/elantech.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 032181c..7b9b6e5 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -411,20 +411,25 @@ static psmouse_ret_t elantech_process_byte(struct psmouse *psmouse) switch (etd->hw_version) { case 1: if (etd->paritycheck && !elantech_check_parity_v1(psmouse)) - return PSMOUSE_BAD_DATA; + goto bad_packet; elantech_report_absolute_v1(psmouse); break; case 2: if (etd->paritycheck && !packet_simple_check_v2(psmouse)) - return PSMOUSE_BAD_DATA; + goto bad_packet; elantech_report_absolute_v2(psmouse); break; } return PSMOUSE_FULL_PACKET; + + bad_packet: + memmove(psmouse->packet, psmouse->packet + 1, psmouse->pktsize - 1); + psmouse->pktcnt--; + return PSMOUSE_GOOD_DATA; } /*