Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2927565rwb; Mon, 15 Aug 2022 14:13:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR4eW+S8yauen6ZVyc8dLezCQhY+CjyC8M9IygVjpKAajKHMK8Zk8pu7Gc1QkdyQpuon1WEE X-Received: by 2002:a05:6402:1004:b0:440:7244:e8a5 with SMTP id c4-20020a056402100400b004407244e8a5mr16245452edu.335.1660597981869; Mon, 15 Aug 2022 14:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597981; cv=none; d=google.com; s=arc-20160816; b=xUCbTV7FbRBiGqX1k1+R9+lo6RcJ26/pHdGEKAmE6HjVRzz4faUT+jj2v4yRWxW3zC kkWerNYChQkAtdw4MCSLyWS05mLqDSoLsmlS4GhF3qpwg3mPqdA3Z+pnm/+H2aMuWr77 BPA5Iqeqfy7QKg0Bl4VClBlu8cfAwu1UJXq86DVJdeUePUWk6U/dNw9nhPVJQDzsIP5T ZqEI4yhE/cwCnTx7nMfMVI464SXLyOJ/lCCzWJJYpb2a6nIKE1OGcZkxwi0yktRg78dh lwMx4v3RS4J5EqoZvqhEzRNz7MYy/MTHrhESSjnE1s/pKncy/LM6WNKYX+pmXCRzGRAK nBYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yVa5GOEIfY7yqNe7WIUSC6jiSrhvXKZosL2DEP/idRs=; b=WSwdI+xOaqOTeZvLPJ+qZnDiDRbCNACV7vW2r7JVKB1qV9k4dHbEXI99IroQinzHLH 7Z06xQpt0mqImWBo7TCnAuHhx3ogtcpNtL8qmCOmHduV/xtwinFVM/eKo2jxxmSKFtyr 8UTaGtk+YrIhoQgnPtMeC0BlEaZLT3Rq/lukC9z3lavRfUq/l7A5htP0gLXbh3fD1C6w 7ecYu723ChRVbcFlJikeV7yoqYMXlDdTjjJy9lSDZQCb/REX++Gt6BDPg9FHGdCmxyM7 2fbw8TZuxyehlyyYnz8MNxo3Ip03zf382H3HFA/LsPNm1nMzGwSSx8arZmMGBsAR4+AP Wn+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KCxe2JvP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o13-20020a509b0d000000b0043d983232acsi8128038edi.483.2022.08.15.14.12.35; Mon, 15 Aug 2022 14:13:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KCxe2JvP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243703AbiHOUIH (ORCPT + 99 others); Mon, 15 Aug 2022 16:08:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346304AbiHOUG0 (ORCPT ); Mon, 15 Aug 2022 16:06:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 935DA80F77; Mon, 15 Aug 2022 11:55:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 514B9611ED; Mon, 15 Aug 2022 18:55:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFF3FC433D6; Mon, 15 Aug 2022 18:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589705; bh=Midk8NCdapzF7mpuCT2GeB9SbLt2pycW50mobOPAZLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KCxe2JvPTYKbbRZ/tIO8nKi9DSao1464uaTPMdV+vfpigSCz5gtrRkVJN/2dZRc1N UXe+P6V8z5FRXtbm+hvu9OU/LgNZyXr0fnwX8l7FBFtLSWBcPJGKFpv7h4EIzlC237 +ZpDVjKsq02v3S+AmzlKziyQM7WhH6vza623h68E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ping Cheng , Jason Gerecke , Jiri Kosina Subject: [PATCH 5.18 0022/1095] HID: wacom: Dont register pad_input for touch switch Date: Mon, 15 Aug 2022 19:50:21 +0200 Message-Id: <20220815180430.271523309@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ping Cheng commit d6b675687a4ab4dba684716d97c8c6f81bf10905 upstream. Touch switch state is received through WACOM_PAD_FIELD. However, it is reported by touch_input. Don't register pad_input if no other pad events require the interface. Cc: stable@vger.kernel.org Signed-off-by: Ping Cheng Reviewed-by: Jason Gerecke Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/wacom_sys.c | 2 +- drivers/hid/wacom_wac.c | 43 +++++++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 19 deletions(-) --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -2121,7 +2121,7 @@ static int wacom_register_inputs(struct error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac); if (error) { - /* no pad in use on this interface */ + /* no pad events using this interface */ input_free_device(pad_input_dev); wacom_wac->pad_input = NULL; pad_input_dev = NULL; --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2017,7 +2017,6 @@ static void wacom_wac_pad_usage_mapping( wacom_wac->has_mute_touch_switch = true; usage->type = EV_SW; usage->code = SW_MUTE_DEVICE; - features->device_type |= WACOM_DEVICETYPE_PAD; break; case WACOM_HID_WD_TOUCHSTRIP: wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0); @@ -2097,6 +2096,30 @@ static void wacom_wac_pad_event(struct h wacom_wac->hid_data.inrange_state |= value; } + /* Process touch switch state first since it is reported through touch interface, + * which is indepentent of pad interface. In the case when there are no other pad + * events, the pad interface will not even be created. + */ + if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) || + (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) { + if (wacom_wac->shared->touch_input) { + bool *is_touch_on = &wacom_wac->shared->is_touch_on; + + if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value) + *is_touch_on = !(*is_touch_on); + else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF) + *is_touch_on = value; + + input_report_switch(wacom_wac->shared->touch_input, + SW_MUTE_DEVICE, !(*is_touch_on)); + input_sync(wacom_wac->shared->touch_input); + } + return; + } + + if (!input) + return; + switch (equivalent_usage) { case WACOM_HID_WD_TOUCHRING: /* @@ -2132,22 +2155,6 @@ static void wacom_wac_pad_event(struct h input_event(input, usage->type, usage->code, 0); break; - case WACOM_HID_WD_MUTE_DEVICE: - case WACOM_HID_WD_TOUCHONOFF: - if (wacom_wac->shared->touch_input) { - bool *is_touch_on = &wacom_wac->shared->is_touch_on; - - if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value) - *is_touch_on = !(*is_touch_on); - else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF) - *is_touch_on = value; - - input_report_switch(wacom_wac->shared->touch_input, - SW_MUTE_DEVICE, !(*is_touch_on)); - input_sync(wacom_wac->shared->touch_input); - } - break; - case WACOM_HID_WD_MODE_CHANGE: if (wacom_wac->is_direct_mode != value) { wacom_wac->is_direct_mode = value; @@ -2808,7 +2815,7 @@ void wacom_wac_event(struct hid_device * /* usage tests must precede field tests */ if (WACOM_BATTERY_USAGE(usage)) wacom_wac_battery_event(hdev, field, usage, value); - else if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) + else if (WACOM_PAD_FIELD(field)) wacom_wac_pad_event(hdev, field, usage, value); else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) wacom_wac_pen_event(hdev, field, usage, value);