From patchwork Mon Jul 19 20:55:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 480204 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 720D0C07E9B for ; Mon, 19 Jul 2021 23:38:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59D68610F7 for ; Mon, 19 Jul 2021 23:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352812AbhGSW5U (ORCPT ); Mon, 19 Jul 2021 18:57:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345648AbhGSUPR (ORCPT ); Mon, 19 Jul 2021 16:15:17 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB2CBC061766 for ; Mon, 19 Jul 2021 13:54:18 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id p14-20020a17090ad30eb02901731c776526so493863pju.4 for ; Mon, 19 Jul 2021 13:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W22iJGxX2OAA41FydcLwVMM8jH6XnncPKRGPCWl0jvU=; b=Hx33IV2E49AjhtHem0Eyw3eyNYOkuPPWOh5OCMObrQqygCD1Yi0ZugQivJ5nmkBVCh dEIlAybrI362KO6hw8ZxmuM1uuQc2otXw+HjCyuAIMLVPihcjMNEOZkckxKQ4jFZLlSF N+qxKR7py6+Glppro5TIJcsV6l9jDX3NM/qbTjJ+gYlpDCR3RQDk52CdU7eMEJd+XfrS PRmTb3NOq5bQU1VHZjSlxYB7piXAu8F6ZBks+rRqFHy1EaokYW3bxMhCEzRINZ2XGFqH mO3mmoswId5kAoyiOnArt9LVQ4s968b8aObacGftjKP8Y5esV1vEMmZfdB5QiNDdoTVv xUew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W22iJGxX2OAA41FydcLwVMM8jH6XnncPKRGPCWl0jvU=; b=JPIIRn+arlJgVSJXqUfRoEP0QFnW6W56k2Vz3yt0xibrWs9gCXD8yMxyVSg5zHVBmU 95BQV6RM23zM6xCGrngFzTMmlVCheDSb5Xz/zNYfm4+0gUSRkTdnYbnYhbMBtJnnMePz 97CXLynibMc3ZWrL9+m/T4loIAQbjEGvjZFAp25E80PhUpaJFu1Pomj8vMjb5gx1T3MF 6j6L6v82LUKd7V7m6g5+P8hVWh5jVQ+w2b6aEv90kKrSf+3eC23Z9ffK8pF/Um0ao/KG BvO+3/m9I6aGNcx8NfP3U4tQxr/ftPAex0LC5xycVz34/OdnjISUwQVeHXTQh9AZu3Yu 8DNQ== X-Gm-Message-State: AOAM533IEPz8IYseNG8r5JXO6/2GRAGwIvQReCUuJTlEzW0k/9yXvFID PBI4t2jqcsx4YOnO5gPwkEYHeb7IBMvMXA== X-Google-Smtp-Source: ABdhPJzcqSkC5RgUKGym1xqQDScCSgp4M9mOk0x1bctVsRXV7N3t7+Ew9+7mwYjzNhW3ZodsGmyJYQ== X-Received: by 2002:a17:90a:7f02:: with SMTP id k2mr26152369pjl.134.1626728144007; Mon, 19 Jul 2021 13:55:44 -0700 (PDT) Received: from horus.lan (71-34-86-28.ptld.qwest.net. [71.34.86.28]) by smtp.gmail.com with ESMTPSA id y82sm21451233pfb.121.2021.07.19.13.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 13:55:43 -0700 (PDT) From: Jason Gerecke X-Google-Original-From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Cc: Ping Cheng , Ping Cheng , Jason Gerecke Subject: [PATCH 2/6] HID: wacom: set initial hardware touch switch state to 'off' Date: Mon, 19 Jul 2021 13:55:29 -0700 Message-Id: <20210719205533.2189804-2-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719205533.2189804-1-jason.gerecke@wacom.com> References: <20210719205533.2189804-1-jason.gerecke@wacom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Ping Cheng Wacom touch devices have two types of touch switches: softkey touch toggle and hardware touch switch. For softkey toggle, we assume touch is on by default in the driver. However the hardware touch switch is controlled by end users. We don't know if it's on or off before getting the status event. This patch sets touch off for devices with a hardware switch until we get the status. This is a bit safer for users who leave the switch "off" and don't want any accidental touches. The tradeoff is a slight delay between device connection and touch becoming enabled for users who leave the switch "on". Signed-off-by: Ping Cheng Reviewed-by: Jason Gerecke Tested-by: Jason Gerecke --- drivers/hid/wacom_sys.c | 8 +++++++- drivers/hid/wacom_wac.c | 12 ++++++++---- drivers/hid/wacom_wac.h | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 57bfa0ae9836..713a2504092f 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -2287,7 +2287,13 @@ static void wacom_set_shared_values(struct wacom_wac *wacom_wac) if (wacom_wac->has_mute_touch_switch) { wacom_wac->shared->has_mute_touch_switch = true; - wacom_wac->shared->is_touch_on = true; + /* Hardware touch switch may be off. Wait until + * we know the switch state to decide is_touch_on. + * Softkey state should be initialized to "on" to + * match historic default. + */ + if (wacom_wac->is_soft_touch_switch) + wacom_wac->shared->is_touch_on = true; } if (wacom_wac->shared->has_mute_touch_switch && diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 496a000ef862..b87fbd2a81a6 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1987,14 +1987,17 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, features->numbered_buttons++; features->device_type |= WACOM_DEVICETYPE_PAD; break; - case WACOM_HID_WD_TOUCHONOFF: case WACOM_HID_WD_MUTE_DEVICE: + /* softkey touch switch */ + wacom_wac->is_soft_touch_switch = true; + fallthrough; + case WACOM_HID_WD_TOUCHONOFF: /* - * This usage, which is used to mute touch events, comes - * from the pad packet, but is reported on the touch + * These two usages, which are used to mute touch events, come + * from the pad packet, but are reported on the touch * interface. Because the touch interface may not have * been created yet, we cannot call wacom_map_usage(). In - * order to process this usage when we receive it, we set + * order to process the usages when we receive them, we set * the usage type and code directly. */ wacom_wac->has_mute_touch_switch = true; @@ -3832,6 +3835,7 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, input_dev->evbit[0] |= BIT_MASK(EV_SW); __set_bit(SW_MUTE_DEVICE, input_dev->swbit); wacom_wac->has_mute_touch_switch = true; + wacom_wac->is_soft_touch_switch = true; } fallthrough; diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 8f16654eca09..4e9eb0c1eff6 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -352,6 +352,7 @@ struct wacom_wac { int mode_value; struct hid_data hid_data; bool has_mute_touch_switch; + bool is_soft_touch_switch; bool has_mode_change; bool is_direct_mode; bool is_invalid_bt_frame; From patchwork Mon Jul 19 20:55:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 480202 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6398C12002 for ; Mon, 19 Jul 2021 23:39:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEF68610D2 for ; Mon, 19 Jul 2021 23:39:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242799AbhGSW6V (ORCPT ); Mon, 19 Jul 2021 18:58:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346834AbhGSUPS (ORCPT ); Mon, 19 Jul 2021 16:15:18 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B53EEC0613DD for ; Mon, 19 Jul 2021 13:54:22 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id 37so20472616pgq.0 for ; Mon, 19 Jul 2021 13:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gJu/GAnviYn3d7aO05yfXl9ZcEPV7S5uHS4BiGszN/k=; b=mzhPHFt3uwMtCvNFhbVfw4e2/KCVOMecAptKAsHsFdbKhmif8lcIDwsrtesvoX2QfS /OjdWXyCr+VPv+udKjGDViVPjBK/7RHqE5N9SwBTUHLt1K91MD6b/qAHhz2ILB2JqfLN pJuOL1XQgsIo1pCsoedB2XpIG6EsJVJxeHdWDX7gLZARV/OH0dM7+4i04ylRcpxyTFsZ gWU4oRuir1bk/OiZe69znOdOn+eNjLZ4aJwpwBBk8HNsLj/yvjxgNCYfVC28yU55WAtJ iv0xHpkvPCEKI7i9cBCWgtCwr2yLcu7pLaAw+Uj5OrSR9Zjc8odu2jFIUFl53AqQb1rR Fgrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gJu/GAnviYn3d7aO05yfXl9ZcEPV7S5uHS4BiGszN/k=; b=bZUFdoo9xxZ9m2VPtBbGW1QBaJPuJDLxTMHw+Ty0B9kBlAgwmGIGAwUljJpGLor31z D+2uNLvB8P03Vq4zAl2/7d+FogRyCcuAXq3onvylm4ax+6/taQO12rm7mWtkWZiOC3Fh ZR+WsmMkDO5iXHPXBsutovYhEFs8gxYicin/kaKXb6etpi6+hrbqP2Mto7FlT7h80S7U ioQIfDj1Fl2WGm5XfkyeXPxJuxj7wPhFAdsis5hamOar/SMqAkEvQe4I9ISYsNctZiy7 +W9cNdvfSi64nyW8+PesOt6Y3fkkz8GadmkH5CrPQobyPh2QuM+UTlfdgZd7pR4+9Dxm /UcQ== X-Gm-Message-State: AOAM530QRutFUsRF2Y60M2llTKV0ohOLhRYb8ItssWl6LllZXlU3eqhP m6mf78vO7F6OWxhu2209+naE56wAp69dNg== X-Google-Smtp-Source: ABdhPJxGhV+hnorFKnG01wS2frQWXBnJUFAkj/zXIPHjnAJ8fWMIP0MOSJahb0li9JbVJDK3vrifWQ== X-Received: by 2002:a62:7c16:0:b029:329:8d4c:d12d with SMTP id x22-20020a627c160000b02903298d4cd12dmr27929794pfc.47.1626728147499; Mon, 19 Jul 2021 13:55:47 -0700 (PDT) Received: from horus.lan (71-34-86-28.ptld.qwest.net. [71.34.86.28]) by smtp.gmail.com with ESMTPSA id y82sm21451233pfb.121.2021.07.19.13.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 13:55:47 -0700 (PDT) From: Jason Gerecke X-Google-Original-From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Cc: Ping Cheng , Jason Gerecke , Ping Cheng Subject: [PATCH 5/6] HID: wacom: Avoid sending empty sync events Date: Mon, 19 Jul 2021 13:55:32 -0700 Message-Id: <20210719205533.2189804-5-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719205533.2189804-1-jason.gerecke@wacom.com> References: <20210719205533.2189804-1-jason.gerecke@wacom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Empty sync events clutter up logs and are a waste of CPU cycles. We can avoid sending mt_sync events if touch is disabled or a specific slot is unused. We can avoid sending full sync events if no events were generated. Signed-off-by: Ping Cheng Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index ce9e8e9b48b6..3f992c9dca4d 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2551,8 +2551,17 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, int slot; slot = input_mt_get_slot_by_key(input, hid_data->id); - if (slot < 0) + if (slot < 0) { return; + } else { + struct input_mt_slot *ps = &input->mt->slots[slot]; + int mt_id = input_mt_get_value(ps, ABS_MT_TRACKING_ID); + + if (!prox && mt_id < 0) { + // No data to send for this slot; short-circuit + return; + } + } input_mt_slot(input, slot); input_mt_report_slot_state(input, MT_TOOL_FINGER, prox); @@ -2696,6 +2705,10 @@ static void wacom_wac_finger_report(struct hid_device *hdev, struct input_dev *input = wacom_wac->touch_input; unsigned touch_max = wacom_wac->features.touch_max; + /* if there was nothing to process, don't send an empty sync */ + if (wacom_wac->hid_data.num_expected == 0) + return; + /* If more packets of data are expected, give us a chance to * process them rather than immediately syncing a partial * update. From patchwork Mon Jul 19 20:55:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 480203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AED44C07E95 for ; Mon, 19 Jul 2021 23:39:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90818610D2 for ; Mon, 19 Jul 2021 23:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344988AbhGSW6D (ORCPT ); Mon, 19 Jul 2021 18:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346541AbhGSUPS (ORCPT ); Mon, 19 Jul 2021 16:15:18 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0803C0613DE for ; Mon, 19 Jul 2021 13:54:23 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id y4so17641331pfi.9 for ; Mon, 19 Jul 2021 13:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hj7k29MxTKJQR8WxrFkV2bIJPSosFcmcW1WgKY1tqjI=; b=SeMUAORWeR37L9hAKVh04ZZtqfngg0+FwYygl+wElRodajScCu48l87eeIOilPPUzg qe/N24+GDpKj0r9DUofAmTPRGyTmV3vI0b1yDg/aquLuDy6WljRK8pNjuU3i+EmvQGbo dwT/hAOBbLXXhza/wPn8z5VERDKhXv4shMTsM7J2lE/5LAKffKeFJCz81pU+TSiqWAyo ojibVU3YX9haf9L9ENRhYb6Bq6jL5/fGbg/jm+fTm/SI3UGVPls+TLcUnfbaRfeUiEh+ +FvlJKrBH/zlWD/B7Gl2wjL5GCJ8/DmzduPTefzHfMD3Jdy6ZODQgqYgIw4nG/KtvlXO jEtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hj7k29MxTKJQR8WxrFkV2bIJPSosFcmcW1WgKY1tqjI=; b=Cr9xmjuU7VhtXhBAtLUFgy3Yhyd1QQN2tlHdNWL2bzF17nyWNDJfCMFyEoAbw0pjqD GI+8S91Tro3PLP0YESW6NttAOYXucgDxoLxUXbLSgoBU0RZiZw8rcKR4SpNJVBY8sOa3 jZXJoHVgE1rnOqr7PgZDAo1cYriuCmMr8L4RSpSbOWZVaMJfUVqRv25Em4nxMgmQns+A 2q7SPrepQsjn9po9MhDpSMBrO9njMQLqWDS2WCcOmgHYcz08zZUJwCxT0LUK0+GQq6O4 4CFC0gKJXh7alXCzQeqkNAldtIVdq6MIoNDVKVXdxdbP+XBeXxkWW7ZZuRQ7cH+9/sOD UmiA== X-Gm-Message-State: AOAM532eyn2tMK2gH8w6SSMmi5P4tGZpSt6YM538DVj3vzECTYbTdhEy 9TCFLMkfVzKe7D8DZFe9FFwLqvllcJo0gA== X-Google-Smtp-Source: ABdhPJzI5K7MJEeOptvvTRX5nNSsmmgRMKf39vJOy8NgrSgFMc9N2jE32sDX9309FlcnfTDKDxz3Jw== X-Received: by 2002:aa7:93ac:0:b029:32e:4fce:bde1 with SMTP id x12-20020aa793ac0000b029032e4fcebde1mr28158579pff.54.1626728148628; Mon, 19 Jul 2021 13:55:48 -0700 (PDT) Received: from horus.lan (71-34-86-28.ptld.qwest.net. [71.34.86.28]) by smtp.gmail.com with ESMTPSA id y82sm21451233pfb.121.2021.07.19.13.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 13:55:48 -0700 (PDT) From: Jason Gerecke X-Google-Original-From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Cc: Ping Cheng , Jason Gerecke Subject: [PATCH 6/6] HID: wacom: Refactor touch input mute checks into a common function Date: Mon, 19 Jul 2021 13:55:33 -0700 Message-Id: <20210719205533.2189804-6-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719205533.2189804-1-jason.gerecke@wacom.com> References: <20210719205533.2189804-1-jason.gerecke@wacom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We perform this same set of tests to see if touch input is muted in several places. We might as well replace these independent copies with an inline function. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 3f992c9dca4d..fd51769d0994 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -824,6 +824,13 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) return 0; } +static inline bool touch_is_muted(struct wacom_wac *wacom_wac) +{ + return wacom_wac->probe_complete && + wacom_wac->shared->has_mute_touch_switch && + !wacom_wac->shared->is_touch_on; +} + static inline bool report_touch_events(struct wacom_wac *wacom) { return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1); @@ -1525,11 +1532,8 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom) int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET; int y_offset = 2; - if (wacom->shared->has_mute_touch_switch && - !wacom->shared->is_touch_on) { - if (!wacom->shared->touch_down) - return 0; - } + if (touch_is_muted(wacom) && !wacom->shared->touch_down) + return 0; if (wacom->features.type == WACOM_27QHDT) { current_num_contacts = data[63]; @@ -2536,8 +2540,7 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, bool prox = hid_data->tipswitch && report_touch_events(wacom_wac); - if (wacom_wac->shared->has_mute_touch_switch && - !wacom_wac->shared->is_touch_on) { + if (touch_is_muted(wacom_wac)) { if (!wacom_wac->shared->touch_down) return; prox = false; @@ -2593,10 +2596,7 @@ static void wacom_wac_finger_event(struct hid_device *hdev, unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); struct wacom_features *features = &wacom->wacom_wac.features; - /* don't process touch events when touch is off */ - if (wacom_wac->probe_complete && - !wacom_wac->shared->is_touch_on && - !wacom_wac->shared->touch_down) + if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down) return; if (wacom_wac->is_invalid_bt_frame) @@ -2648,10 +2648,7 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev, struct hid_data* hid_data = &wacom_wac->hid_data; int i; - /* don't process touch events when touch is off */ - if (wacom_wac->probe_complete && - !wacom_wac->shared->is_touch_on && - !wacom_wac->shared->touch_down) + if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down) return; wacom_wac->is_invalid_bt_frame = false;