Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2807805rwb; Mon, 15 Aug 2022 11:45:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR7aFyJSunNFIwg50GDuEy/dN3A3tjBzdlvsIqIPewvAdD9qJXmCiWuy5RTMPUgaVU+p0sHH X-Received: by 2002:a17:907:1b0e:b0:72f:9b43:b98c with SMTP id mp14-20020a1709071b0e00b0072f9b43b98cmr11374347ejc.710.1660589112090; Mon, 15 Aug 2022 11:45:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589112; cv=none; d=google.com; s=arc-20160816; b=XSWYPv8e2pwqEq/EO8m3UtV/ndBI3y7K5R5eIkeUmrVMGYbwCRXT7vgo45ahY8MFUD ChCqpra3srogk5KLsaIGAj/kEL6TvK1StNkSYSoxVcyOzSmCz4onhw37kgVKqWHMryb5 iaffDl3Cl50tcGcbf6IwaP2TYNnMEg0mvc48qUckDpU1aGqwG10ZWwbbcNQwRH5Yc4jK TWEbNSINNktYI09kp5RQAZxMt/8/l5if9sorZ9luMRuKmMkQ1HlYTTGUI0w9imjrF51q 5Sr/oxyv30wH+tH8DU9ADCsvKeFJ3HteLCSd+i5+GYTSkVpNRUZmui/bBRCsEsF2MgT9 JvSw== 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=I0kjh/OTxj0nagIlmJ0mG3WHPVloBO/S4+JsS3FzNTw=; b=sUpBq2aH3cui77FTg0EpWFECY9DvicLHf7PySWLZusuzYuhVByKuoigfbXSrlBrJFV 5LL+8pVoXN9YchreRcARIoRh594wFfd5Os0ehhZicdzmxKfreZAU6TDAXSSE11iZwely TzeaNGH9+tcRambjeKP/iRQwZyBokIwan9wPVkyt99GG4Vmxuafh02QUIfrPjiHrFAby Q31DGp+O5pkYirZCHgnmFWazt1m4yIDaocfGqVOmXhgt2hzUSTqGLZUHTtWi6mEvDSlO rARQ+yAKRT8ATLrBgp/yqbiOv5uEbXcoMHXbpWRv0BxBduy0Uo/zqhbSztYsq1T++MWt vGCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Nbg+UbkU; 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 fi22-20020a056402551600b004434be2f253si6096029edb.307.2022.08.15.11.44.46; Mon, 15 Aug 2022 11:45:12 -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=Nbg+UbkU; 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 S233317AbiHOSRB (ORCPT + 99 others); Mon, 15 Aug 2022 14:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232119AbiHOSQI (ORCPT ); Mon, 15 Aug 2022 14:16:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 689BA2AE17; Mon, 15 Aug 2022 11:14:46 -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 E09DE61255; Mon, 15 Aug 2022 18:14:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D33B0C433D7; Mon, 15 Aug 2022 18:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587285; bh=W5Ql+ZrwKUzjMRrQdWuGO+zGCPPjlFD1gX3qSuxMdK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nbg+UbkUPhRC3b8rAHmmETjLwgqiEu5AC6Il1LA7+NV2LPspLmFWSADI7X23zKei3 9/ROyVETys46UgCqcRJd6Tn9rdNrORpOm0Kx41ecXx8bmFbcKlhgydmaBs3OobD7q3 jAdRnmmVaJYZC7Yy2KlOMiRXKJqxRMwsjYz8/gkI= 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.15 019/779] HID: wacom: Dont register pad_input for touch switch Date: Mon, 15 Aug 2022 19:54:23 +0200 Message-Id: <20220815180338.016995948@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 @@ -2124,7 +2124,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);