From patchwork Mon Nov 30 03:38:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Hutterer X-Patchwork-Id: 7720921 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A1B0EBEEE1 for ; Mon, 30 Nov 2015 03:50:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB216204EA for ; Mon, 30 Nov 2015 03:50:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0C50204EB for ; Mon, 30 Nov 2015 03:50:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752167AbbK3Dui (ORCPT ); Sun, 29 Nov 2015 22:50:38 -0500 Received: from leo.clearchain.com ([199.73.29.74]:22020 "EHLO mail.clearchain.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751840AbbK3Dui (ORCPT ); Sun, 29 Nov 2015 22:50:38 -0500 X-Greylist: delayed 698 seconds by postgrey-1.27 at vger.kernel.org; Sun, 29 Nov 2015 22:50:36 EST Received: from jelly.bne.redhat.com. (localhost [127.0.0.1]) by mail.clearchain.com (8.15.1/8.15.1) with ESMTP id tAU3ctPx084985; Mon, 30 Nov 2015 14:09:14 +1030 (CST) (envelope-from peter.hutterer@who-t.net) X-Authentication-Warning: leo.clearchain.com: Host localhost [127.0.0.1] claimed to be jelly.bne.redhat.com. From: Peter Hutterer To: linux-input@vger.kernel.org Cc: Peter Hutterer , Dmitry Torokhov , Benjamin Tissoires , Ping Cheng , Jason Gerecke Subject: [PATCH 3/5] Input: wacom_w8001 - handle touch error case correctly Date: Mon, 30 Nov 2015 13:38:14 +1000 Message-Id: <1448854696-32625-3-git-send-email-peter.hutterer@who-t.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1448854696-32625-1-git-send-email-peter.hutterer@who-t.net> References: <1448854696-32625-1-git-send-email-peter.hutterer@who-t.net> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (mail.clearchain.com [127.0.0.1]); Mon, 30 Nov 2015 14:09:18 +1030 (CST) 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 If a device failed at the pen setup and gets a zero reply from the touch device, we need to return an error. Otherwise we have a device with nothing but a name and the EV_KEY and EV_ABS bits. Signed-off-by: Peter Hutterer Acked-by: Benjamin Tissoires --- drivers/input/touchscreen/wacom_w8001.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index 222006e..cdebf8e 100644 --- a/drivers/input/touchscreen/wacom_w8001.c +++ b/drivers/input/touchscreen/wacom_w8001.c @@ -385,7 +385,7 @@ static int w8001_setup(struct w8001 *w8001) struct input_dev *dev = w8001->dev; struct w8001_coord coord; struct w8001_touch_query touch; - int error; + int error, err_pen, err_touch; error = w8001_command(w8001, W8001_CMD_STOP, false); if (error) @@ -400,8 +400,8 @@ static int w8001_setup(struct w8001 *w8001) __set_bit(INPUT_PROP_DIRECT, dev->propbit); /* penabled? */ - error = w8001_command(w8001, W8001_CMD_QUERY, true); - if (!error) { + err_pen = w8001_command(w8001, W8001_CMD_QUERY, true); + if (!err_pen) { __set_bit(BTN_TOUCH, dev->keybit); __set_bit(BTN_TOOL_PEN, dev->keybit); __set_bit(BTN_TOOL_RUBBER, dev->keybit); @@ -426,13 +426,15 @@ static int w8001_setup(struct w8001 *w8001) } /* Touch enabled? */ - error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true); + err_touch = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true); /* * Some non-touch devices may reply to the touch query. But their * second byte is empty, which indicates touch is not supported. */ - if (!error && w8001->response[1]) { + if (!err_touch && w8001->response[1]) { + err_touch = 1; + __set_bit(BTN_TOUCH, dev->keybit); __set_bit(BTN_TOOL_FINGER, dev->keybit); @@ -491,7 +493,7 @@ static int w8001_setup(struct w8001 *w8001) strlcat(w8001->name, " Touchscreen", sizeof(w8001->name)); - return 0; + return !err_pen || !err_touch; } /*