From patchwork Sat Jan 9 01:15:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 7991551 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 815D49F6FA for ; Sat, 9 Jan 2016 01:16:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 949F3201C7 for ; Sat, 9 Jan 2016 01:15:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9DF66201C8 for ; Sat, 9 Jan 2016 01:15:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754301AbcAIBP5 (ORCPT ); Fri, 8 Jan 2016 20:15:57 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33006 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752593AbcAIBP5 (ORCPT ); Fri, 8 Jan 2016 20:15:57 -0500 Received: by mail-pf0-f196.google.com with SMTP id e65so1313925pfe.0 for ; Fri, 08 Jan 2016 17:15:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=gz85moODkXRfllCrhiIzocIAOY0FbXlf1ccqcDylzGY=; b=JX2qmChW7cHeZ6Y6rfoLJDQUoeL25Fki3x43Ih5oRSk5LMRwjSjQYSmvkxPqCjOhg/ ACj07poVBrJc3met3KOUuq5qAzRiQeSDpUcIBiuwxV+0wt54wglDo2g2/66d+KV58dU6 WGvN8uI/XDA2HkwGK8S6Xc2skgUBRqwnRFEj520acLAoRybBhNKYB2hAcYJwGEv3LjH3 dbqBYXqpLdqhcg0/Glmu0tmel/VyRlyAZYUUVWUZbQQP9CF4qkmdli1gLakoxHcLJRLQ fIIE4+fO3k9eB/IANYNLhzMTjoWnSUVxrWyA9v5EFTVR+8EcYseBn8HGyAxgRhBMSS5j zT4A== X-Received: by 10.98.9.75 with SMTP id e72mr8518177pfd.29.1452302155985; Fri, 08 Jan 2016 17:15:55 -0800 (PST) Received: from wacom-XPS-8500.corp.onewacom.com ([67.51.163.2]) by smtp.gmail.com with ESMTPSA id y86sm7351873pfa.26.2016.01.08.17.15.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jan 2016 17:15:55 -0800 (PST) From: Ping Cheng X-Google-Original-From: Ping Cheng To: linux-input@vger.kernel.org Cc: jkosina@suse.cz, killertofu@gmail.com, Ping Cheng Subject: [PATCH 2/4] HID: wacom - make sure wacom_intuos_inout only process in/out events Date: Fri, 8 Jan 2016 17:15:48 -0800 Message-Id: <1452302148-5561-1-git-send-email-pingc@wacom.com> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move general events related data validation to wacom_intuos_general. Signed-off-by: Ping Cheng Reviewed-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 51 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 6449547..8507028 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -576,12 +576,13 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) struct wacom_features *features = &wacom->features; unsigned char *data = wacom->data; struct input_dev *input = wacom->pen_input; - int idx = 0; - - /* tool number */ - if (features->type == INTUOS) - idx = data[1] & 0x01; + int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; + if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */ + ((data[1] & 0xfe) == 0x20) || /* in range */ + ((data[1] & 0xfe) == 0x80))) /* out prox */ + return 0; + /* Enter report */ if ((data[1] & 0xfc) == 0xc0) { /* serial number of the tool */ @@ -672,26 +673,6 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) return 1; } - /* - * don't report events for invalid data - */ - /* older I4 styli don't work with new Cintiqs */ - if ((!((wacom->id[idx] >> 20) & 0x01) && - (features->type == WACOM_21UX2)) || - /* Only large Intuos support Lense Cursor */ - (wacom->tool[idx] == BTN_TOOL_LENS && - (features->type == INTUOS3 || - features->type == INTUOS3S || - features->type == INTUOS4 || - features->type == INTUOS4S || - features->type == INTUOS5 || - features->type == INTUOS5S || - features->type == INTUOSPM || - features->type == INTUOSPS)) || - /* Cintiq doesn't send data when RDY bit isn't set */ - (features->type == CINTIQ && !(data[1] & 0x40))) - return 1; - wacom->shared->stylus_in_proximity = true; if (wacom->shared->touch_down) return 1; @@ -893,6 +874,26 @@ static int wacom_intuos_general(struct wacom_wac *wacom) return 1; } + /* + * don't report events for invalid data + */ + /* older I4 styli don't work with new Cintiqs */ + if ((!((wacom->id[idx] >> 20) & 0x01) && + (features->type == WACOM_21UX2)) || + /* Only large Intuos support Lense Cursor */ + (wacom->tool[idx] == BTN_TOOL_LENS && + (features->type == INTUOS3 || + features->type == INTUOS3S || + features->type == INTUOS4 || + features->type == INTUOS4S || + features->type == INTUOS5 || + features->type == INTUOS5S || + features->type == INTUOSPM || + features->type == INTUOSPS)) || + /* Cintiq doesn't send data when RDY bit isn't set */ + (features->type == CINTIQ && !(data[1] & 0x40))) + return 1; + x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1); y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1); distance = data[9] >> 2;