From patchwork Fri Oct 22 05:00:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 272771 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 o9M4vLiE021102 for ; Fri, 22 Oct 2010 05:00:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752626Ab0JVFAQ (ORCPT ); Fri, 22 Oct 2010 01:00:16 -0400 Received: from mail-yw0-f46.google.com ([209.85.213.46]:61239 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751065Ab0JVFAO (ORCPT ); Fri, 22 Oct 2010 01:00:14 -0400 Received: by ywk9 with SMTP id 9so349670ywk.19 for ; Thu, 21 Oct 2010 22:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=1zzjH52JfZgiyPFRqF0GXCWKMrVEIXo+I5hH3Gv1iAo=; b=vpYNRoln0varkzyfRwKOQWY0Xs3e52K+t0KI/jKO7JCCT+Ka9n8P+288gPLZixp44R lbzLyw74ukPzP8DSMjFhp2mkOFO71tl25iFxkZ/k3tmvof48fEwk3N99Ex1fF6NuH1XI 3arKND32K1RFXZRmK0TVwFXHy8TWQUUpEGLJQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=MNfR2aDXMfgE7FUIj6C1HWbBq6pUdXunSvywoO9tRx+LEu3iZm37kbmvuSUI2uA8LJ guNgC+UjQsEvaYI3T/3zaWnp7iL46U1E6k+ay17orqwi4Hf6xtgROZMg8Up6kE2sEAtc MzkuCXDd1LqrgtXaTy2TLTK+vkUVbrpfnMCsk= Received: by 10.100.17.4 with SMTP id 4mr1670380anq.119.1287723613550; Thu, 21 Oct 2010 22:00:13 -0700 (PDT) Received: from mailhub.coreip.homeip.net (c-24-6-153-206.hsd1.ca.comcast.net [24.6.153.206]) by mx.google.com with ESMTPS id 13sm2906954anq.30.2010.10.21.22.00.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 21 Oct 2010 22:00:12 -0700 (PDT) Date: Thu, 21 Oct 2010 22:00:07 -0700 From: Dmitry Torokhov To: michael.hennerich@analog.com Cc: linux-input@vger.kernel.org, device-drivers-devel@blackfin.uclinux.org, drivers@analog.com Subject: Re: [PATCH] Input: touchscreen: AD7879: prevent invalid finger data reports Message-ID: <20101022050007.GB10493@core.coreip.homeip.net> References: <1287408804-19789-1-git-send-email-michael.hennerich@analog.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1287408804-19789-1-git-send-email-michael.hennerich@analog.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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]); Fri, 22 Oct 2010 05:00:17 +0000 (UTC) diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c index ba6f0bd..bc3b518 100644 --- a/drivers/input/touchscreen/ad7879.c +++ b/drivers/input/touchscreen/ad7879.c @@ -129,6 +129,9 @@ struct ad7879 { u16 cmd_crtl1; u16 cmd_crtl2; u16 cmd_crtl3; + int x; + int y; + int Rt; }; static int ad7879_read(struct ad7879 *ts, u8 reg) @@ -175,13 +178,32 @@ static int ad7879_report(struct ad7879 *ts) Rt /= z1; Rt = (Rt + 2047) >> 12; - if (!timer_pending(&ts->timer)) + /* + * Sample found inconsistent, pressure is beyond + * the maximum. Don't report it to user space. + */ + if (Rt > ts->pressure_max) + return -EINVAL; + + /* + * Note that we delay reporting events by one sample. + * This is done to avoid reporting last sample of the + * touch sequence, which may be incomplete if finger + * leaves the surface before last reading is taken. + */ + if (timer_pending(&ts->timer)) { + /* Touch continues */ input_report_key(input_dev, BTN_TOUCH, 1); + input_report_abs(input_dev, ABS_X, ts->x); + input_report_abs(input_dev, ABS_Y, ts->y); + input_report_abs(input_dev, ABS_PRESSURE, ts->Rt); + input_sync(input_dev); + } + + ts->x = x; + ts->y = y; + ts->Rt = Rt; - input_report_abs(input_dev, ABS_X, x); - input_report_abs(input_dev, ABS_Y, y); - input_report_abs(input_dev, ABS_PRESSURE, Rt); - input_sync(input_dev); return 0; }