Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2791749rdh; Wed, 27 Sep 2023 12:48:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEi233oiTTuJ4Y8ti9tC5tzVuYYn14foV3qLnutiDtJSxkIjTSi1/bXXdoFGhEhhKhzOBgN X-Received: by 2002:a17:902:c38d:b0:1c0:d5c6:748f with SMTP id g13-20020a170902c38d00b001c0d5c6748fmr2547174plg.67.1695844123611; Wed, 27 Sep 2023 12:48:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695844123; cv=none; d=google.com; s=arc-20160816; b=jRnyrf46c2XXpgPua38cToLSfLDIBm5qjCNPfmzCiBM+fHzP3KLrA6S/LzR4ARtPdz Kx2kSqd727DjPTjsXRKwf7y0LgMoq5A5+UOOp7HwUaI1WWAPecmh3hu8BKxJDyd3rl3y VjiVGIr3dIPnEuQQLNZKbeUBTh9gxS+VJuD3tz42aO7cfHAz937yTbCbwEhIhJpemO9B VQOu80ONYFKuXzS5suxRC2ODOS17PFo5IaVWiazBLrtgvXeNpuPq/jgvC3VL8qES/QJ3 XIKhktZ/C1mD7H6++1lXnsn1ishHxvC7dD6IFNePgNmDKByVATFXkzRS3icZJ7pP+NUE +mwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version :dkim-signature; bh=Gd38sDa5ZujK2sWcQBS9UuqvWuA9QvUGhRKdOCB3Qlc=; fh=ru11/NaC3dhIONNE6v2KMsZuHaFJ6l2RzEqTXTh+Dno=; b=GTRMv4HgLdu32qv98Yb7v/BaI22DIBOS5PBdQAfZwa9eFJEPImo+XAit6Dv4JeaHjT SIwlpzTldVN1yy6nHC1vSJWIcycC8j0EM/Q/3DIIz/sPOmAFw6kga/eP/dueQAVM6GUm LH/1YN11/uxyQpUfNG+b7dyMcAdEcVaNQa8RPImSHKltfvTZDvb7mQc8zlhv7ZUsnKnA v6xsEHx7dld5CNve/l3QWxKliKjtFTD63eWbLIJIWVDaagkfmZXvLqQp82WvZIHny1n9 u1tVirN02Ctms28RAp/dxTp4ucokkF6K1HK1j1LAri6NGYe0nKoXqSmaHgm8zNY4Kjm/ c1nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lentin.co.uk header.s=mythic-beasts-k1 header.b=d4udonc6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id d6-20020a170903230600b001c7345bc01csi168572plh.450.2023.09.27.12.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:48:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@lentin.co.uk header.s=mythic-beasts-k1 header.b=d4udonc6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3C3B080A0E02; Wed, 27 Sep 2023 01:20:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230364AbjI0IT6 (ORCPT + 99 others); Wed, 27 Sep 2023 04:19:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230302AbjI0ITg (ORCPT ); Wed, 27 Sep 2023 04:19:36 -0400 Received: from mx1.mythic-beasts.com (mx1.mythic-beasts.com [IPv6:2a00:1098:0:86:1000:0:2:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCF751AC; Wed, 27 Sep 2023 01:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lentin.co.uk; s=mythic-beasts-k1; h=Subject:To:From:Date; bh=Gd38sDa5ZujK2sWcQBS9UuqvWuA9QvUGhRKdOCB3Qlc=; b=d4udonc6aoZ/9t/Iz1SdVZmgTp 7BGuzFMpJIIEZijhyKricfGClyBavtvATbYdcLK+s4Oa4F86IlpEGDjhtexb6Fw8qCN/YFW1clMoz eo/0Yz/B9qagNXqMHIW/61722Mjg4n4xGfy5ergJK6mYwrWp6StlZ1iYQNM0eTHbY5hRySaabgcm/ 6swo+PymYHCXhrJ9UlDs44VHVqnehtQiguJj62Pr2mmMa7Fy8xgbcZTAVtaQnrJj9IEngy9QgkqGS 2vefchpCpAaOaytIdinlWQryy2z0gI1TlAcrHGPi8mhwk4o07knWI8D7dWQhZH/+G2arvk5IeX9+S ndaBsy3Q==; Received: by mailhub-cam-d.mythic-beasts.com with esmtpa (Exim 4.94.2) (envelope-from ) id 1qlPlS-00B0N1-7J; Wed, 27 Sep 2023 09:19:22 +0100 MIME-Version: 1.0 Date: Wed, 27 Sep 2023 09:19:04 +0100 From: Jamie Lentin To: Martin Kepplinger Cc: jikos@kernel.org, benjamin.tissoires@redhat.com, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: Re: [RFC PATCH 2/2] hid: lenovo: move type checks to lenovo_features_set_cptkbd() In-Reply-To: <20230925102302.13094-2-martink@posteo.de> References: <140b721bc345a846863a37ebf17c3174@lentin.co.uk> <20230925102302.13094-1-martink@posteo.de> <20230925102302.13094-2-martink@posteo.de> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: jm@lentin.co.uk Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 01:20:15 -0700 (PDT) On 2023-09-25 11:23, Martin Kepplinger wrote: > These custom commands will be sent to both the USB keyboard & mouse > devices but only the mouse will respond. Avoid sending known-useless > messages by always prepending the filter before sending them. > > Suggested-by: Jamie Lentin > Signed-off-by: Martin Kepplinger > --- > drivers/hid/hid-lenovo.c | 27 +++++++++------------------ > 1 file changed, 9 insertions(+), 18 deletions(-) > > diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c > index 29aa6d372bad..922f3e5462f4 100644 > --- a/drivers/hid/hid-lenovo.c > +++ b/drivers/hid/hid-lenovo.c > @@ -521,6 +521,14 @@ static void lenovo_features_set_cptkbd(struct > hid_device *hdev) > int ret; > struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); > > + /* All the custom action happens on the USBMOUSE device for USB */ > + if (((hdev->product == USB_DEVICE_ID_LENOVO_CUSBKBD) || > + (hdev->product == USB_DEVICE_ID_LENOVO_TPIIUSBKBD)) && > + hdev->type != HID_TYPE_USBMOUSE) { > + hid_dbg(hdev, "Ignoring keyboard half of device\n"); > + return; > + } > + > /* > * Tell the keyboard a driver understands it, and turn F7, F9, F11 > into > * regular keys > @@ -1122,14 +1130,6 @@ static int lenovo_probe_cptkbd(struct hid_device > *hdev) > int ret; > struct lenovo_drvdata *cptkbd_data; > > - /* All the custom action happens on the USBMOUSE device for USB */ > - if (((hdev->product == USB_DEVICE_ID_LENOVO_CUSBKBD) || > - (hdev->product == USB_DEVICE_ID_LENOVO_TPIIUSBKBD)) && > - hdev->type != HID_TYPE_USBMOUSE) { > - hid_dbg(hdev, "Ignoring keyboard half of device\n"); > - return 0; > - } > - I like the idea of doing it once then forgetting about it, but removing this will mean that the "keyboard half" will have it's own set of non-functional sysfs parameters I think? Currently:- # evtest . . . /dev/input/event10: ThinkPad Compact Bluetooth Keyboard with TrackPoint /dev/input/event11: Lenovo ThinkPad Compact USB Keyboard with TrackPoint /dev/input/event12: Lenovo ThinkPad Compact USB Keyboard with TrackPoint # ls -1 /sys/class/input/event*/device/device/fn_lock /sys/class/input/event10/device/device/fn_lock /sys/class/input/event12/device/device/fn_lock (note 11 is missing.) I think the easiest (but ugly) thing to do is to copy-paste this lump of code to the top of lenovo_reset_resume. Cheers, > cptkbd_data = devm_kzalloc(&hdev->dev, > sizeof(*cptkbd_data), > GFP_KERNEL); > @@ -1264,16 +1264,7 @@ static int lenovo_probe(struct hid_device *hdev, > #ifdef CONFIG_PM > static int lenovo_reset_resume(struct hid_device *hdev) > { > - switch (hdev->product) { > - case USB_DEVICE_ID_LENOVO_CUSBKBD: > - if (hdev->type == HID_TYPE_USBMOUSE) { > - lenovo_features_set_cptkbd(hdev); > - } > - > - break; > - default: > - break; > - } > + lenovo_features_set_cptkbd(hdev); > > return 0; > }