From patchwork Tue May 11 08:18:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 98632 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4B8IuqX015676 for ; Tue, 11 May 2010 08:19:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756774Ab0EKITF (ORCPT ); Tue, 11 May 2010 04:19:05 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:42276 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751895Ab0EKITC (ORCPT ); Tue, 11 May 2010 04:19:02 -0400 Received: by mail-pv0-f174.google.com with SMTP id 32so410917pvb.19 for ; Tue, 11 May 2010 01:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:subject:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-type:content-transfer-encoding; bh=MTjjgiSO93iCU8fbTz83oob0twWzhTl0n6WpnQKO/0Q=; b=Ld22zlKbbdPKs2aTzxcqU0H18EluCwtZr6o1+XMYKXBNHFD13zAAufpH0ACKQBnYqj elUmAwaaK5ICUgJcFwIgc8XjqWUlmlnB0bDXvIEu8opEnTC0mJXNr5KDVfzOmnA5aGcY LQW8jdwNt5eloYGs3ZsCNlEERXarEl+jDWMpc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:subject:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; b=A7brZ77SKbulbcfmJuWw3OsltvAt5DERrqkUgGafYdMHjwJ9PU0OFOkDEBfIwH6lLq HOaLpu5tr0ji114CevzkfU6f6PdBAb7VvyNce5vYioG1Fj8xrZ0ojyeaTx6Gwu7Cc8sU d6HYnjsRQaxxPjaoYw01DOvb72cIO1KLU8F0Q= Received: by 10.141.187.25 with SMTP id o25mr3422370rvp.71.1273565942049; Tue, 11 May 2010 01:19:02 -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 c16sm2618775rvn.2.2010.05.11.01.19.00 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 11 May 2010 01:19:01 -0700 (PDT) From: Dmitry Torokhov Subject: [PATCH 3/3] Input: elantech - signature... To: linux-input@vger.kernel.org Cc: Florian Ragwitz , =?utf-8?b?w4lyaWM=?= Piel , Arjan Opmeer Date: Tue, 11 May 2010 01:18:59 -0700 Message-ID: <20100511081859.10546.11991.stgit@localhost.localdomain> In-Reply-To: <20100511081848.10546.95545.stgit@localhost.localdomain> References: <20100511081848.10546.95545.stgit@localhost.localdomain> User-Agent: StGIT/0.14.3 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 (demeter.kernel.org [140.211.167.41]); Tue, 11 May 2010 08:19:06 +0000 (UTC) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 232556a..b18862b 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -575,6 +575,24 @@ static struct attribute_group elantech_attr_group = { .attrs = elantech_attrs, }; +static bool elantech_is_signature_valid(const unsigned char *param) +{ + static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10 }; + int i; + + if (param[0] == 0) + return false; + + if (param[1] == 0) + return true; + + for (i = 0; i < ARRAY_SIZE(rates); i++) + if (param[2] == rates[i]) + return false; + + return true; +} + /* * Use magic knock to detect Elantech touchpad */ @@ -617,7 +635,7 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties) pr_debug("Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n", param[0], param[1], param[2]); - if (param[0] == 0 || param[1] != 0) { + if (!elantech_is_signature_valid(param)) { if (!force_elantech) { pr_debug("Probably not a real Elantech touchpad. Aborting.\n"); return -1;