Received: by 2002:a05:6a10:6754:0:0:0:0 with SMTP id w20csp5385385pxu; Wed, 4 Nov 2020 12:39:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1pgOYGcmN/6OL0qVwtfWH2/JK3gLcvniUpBCG9m9cZOfJ3RK+EPxTM35yzYOrqKm80zna X-Received: by 2002:aa7:d514:: with SMTP id y20mr24188881edq.384.1604522352421; Wed, 04 Nov 2020 12:39:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604522352; cv=none; d=google.com; s=arc-20160816; b=iyDXogGC6mvhELaGnmX3CjzDQbpbrOR/S7BtWMlCJ7kcwp4E0ulN3rcSzzwl/kwWtg Qn6Ftg8YHOrkjQVs6wKc99zRfNX9scy/Turu+xFr7pLaw25patuUTEXJwLfuiQG6xBp8 ORKl5Xp2lV32FRMgRKADumzs3D9u0PFvN2vOGHZ8vzX29nMFNvFUa94cBAtpRFy/kY8M zEVNc6x935EDiAFfVPeEBVFuzO1pjBmbJiVr2PMyLWfdKUZJNcY+b8n62425kuK02nKg RdK+U0tYraPhDcR1dsy4k6aY+8jaEOLv555ICUcYPwh8OidaUNnLAaMkBG6anyBf2DXd Y6fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=FU2PFDmbBUcvE2oswSnuij5+Y3ZOTdLbZw9GyoU7AWo=; b=Aw4581aoMy1HT8SjllarJRH54Cj5aY6BnI0JFFPRRq1cK9LW7vsGorOPuOx0zHjf6/ DFr7H9jzfdfIGJl9O44h8x7LrBDd8WeGI5U1f6brM1K6a/npR6xGhb2Hc/WjTeoVwcjG eBzQ3xifbELQvc1YUf05TUPN975/GFGyuE+8pZqlTSCrCsEyPuQmDVhpEtfTGB2KBgWR s3M1oRh+SLSE1oTwZdMt03X+plKcb4pJUCpzwRC9ucFdpCitpTnwy9+a1Y5dRI2pyRL1 ABsIVKJOvxHB8LBK5cwCgc0U06UpWMP1bIOURfFevs0dErcAp65Iog4bBz0KecIfnOIV qslg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m6si2091800ejb.721.2020.11.04.12.38.50; Wed, 04 Nov 2020 12:39:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731194AbgKDTGb (ORCPT + 99 others); Wed, 4 Nov 2020 14:06:31 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:48130 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgKDTGb (ORCPT ); Wed, 4 Nov 2020 14:06:31 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 817261C0B7C; Wed, 4 Nov 2020 20:06:27 +0100 (CET) Date: Wed, 4 Nov 2020 20:06:27 +0100 From: Pavel Machek To: "Gerecke, Jason" Cc: Greg Kroah-Hartman , Jason Gerecke , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , "Cheng, Ping" , Jiri Kosina Subject: Re: [PATCH 4.19 146/191] HID: wacom: Avoid entering wacom_wac_pen_report for pad / battery Message-ID: <20201104190627.GA1850@duo.ucw.cz> References: <20201103203232.656475008@linuxfoundation.org> <20201103203246.442871831@linuxfoundation.org> <20201104075221.GA4338@amd> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sdtB3X0nJg68CQEu" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > > > To correct this, we restore a version of the `WACOM_PAD_FIELD` check > > > in `wacom_wac_collection()` and return early. This effectively preven= ts > > > pad / battery collections from being reported until the very end of t= he > > > report as originally intended. > >=20 > > Okay... but code is either wrong or very confusing: > >=20 > > > +++ b/drivers/hid/wacom_wac.c > > > @@ -2729,7 +2729,9 @@ static int wacom_wac_collection(struct h > > > if (report->type !=3D HID_INPUT_REPORT) > > > return -1; > > > =20 > > > - if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) > > > + if (WACOM_PAD_FIELD(field)) > > > + return 0; > > > + else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) > > > wacom_wac_pen_report(hdev, report); > >=20 > > wacom_wac_pen_report() can never be called, because WACOM_PEN_FIELD() > > can not be true here; if it was we'd return in the line above. >=20 > For reference, here's the definition for WACOM_PAD_FIELD() and WACOM_PEN_= FIELD(): >=20 > > #define WACOM_PAD_FIELD(f) (((f)->physical =3D=3D HID_DG_TABLETFUNCTION= KEY) || \ > > ((f)->physical =3D=3D WACOM_HID_WD_DIGITIZERFNKEYS) || \ > > ((f)->physical =3D=3D WACOM_HID_WD_DIGITIZERINFO)) > >=20 > > #define WACOM_PEN_FIELD(f) (((f)->logical =3D=3D HID_DG_STYLUS) || \ > > ((f)->physical =3D=3D HID_DG_STYLUS) || \ > > ((f)->physical =3D=3D HID_DG_PEN) || \ > > ((f)->application =3D=3D HID_DG_PEN) || \ > > ((f)->application =3D=3D HID_DG_DIGITIZER) || \ > > ((f)->application =3D=3D WACOM_HID_WD_PEN) || \ > > ((f)->application =3D=3D WACOM_HID_WD_DIGITIZER) || \ > > ((f)->application =3D=3D WACOM_HID_G9_PEN) || \ > > ((f)->application =3D=3D WACOM_HID_G11_PEN)) >=20 > WACOM_PAD_FIELD() evaluates to `true` for pad data *not* pen data because= pen data is not inside any of the 3 physical collections its looks for. >=20 > WACOM_PEN_FIELD() evaluates to `true` for pad data *and* pen data because= both types of data are inside of the Digitizer application collection. > > Without the WACOM_PAD_FIELD() check in place at the very beginning, both = pad and pen data would trigger a call to wacom_wac_pen_report(). This is un= desired: only pen data should result in that function being called. Adding = the check causes the function to return early for pad data while pen data f= alls into the "else if" and is processed as before. Pad data is only report= ed once the entire report has been valuated by making a call to wacom_wac_p= ad_report() at the very end of wacom_wac_report(). > Yep, you are right. I failed to notice the difference between _PAD_ and _PEN_ macros, and so the code did not make sense. Sorry for the noise. Best regards, Pavel =09 --=20 http://www.livejournal.com/~pavelmachek --sdtB3X0nJg68CQEu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCX6L7swAKCRAw5/Bqldv6 8nc0AKCjCKJtNXaXeOhS+GtePsSmvUZ8agCfS9Jlqtj60H2oEsUkg+Ve9EOlJJA= =v1xk -----END PGP SIGNATURE----- --sdtB3X0nJg68CQEu--