From: Martin Kepplinger <martink@posteo.de>
To: jikos@kernel.org, benjamin.tissoires@redhat.com, jm@lentin.co.uk,
linux-kernel@vger.kernel.org
Cc: linux-input@vger.kernel.org, Martin Kepplinger <martink@posteo.de>
Subject: [RFC PATCH 2/2] hid: lenovo: move type checks to lenovo_features_set_cptkbd()
Date: Mon, 25 Sep 2023 10:23:02 +0000 [thread overview]
Message-ID: <20230925102302.13094-2-martink@posteo.de> (raw)
In-Reply-To: <20230925102302.13094-1-martink@posteo.de>
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 <jm@lentin.co.uk>
Signed-off-by: Martin Kepplinger <martink@posteo.de>
---
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;
- }
-
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;
}
--
2.39.2
next prev parent reply other threads:[~2023-09-25 10:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-21 9:21 [PATCH] HID: lenovo: Fix middle-button behaviour for system suspend Martin Kepplinger
2023-09-24 8:11 ` Jamie Lentin
2023-09-25 10:23 ` [RFC PATCH 1/2] hid: lenovo: Resend all settings on reset_resume for compact keyboards Martin Kepplinger
2023-09-25 10:23 ` Martin Kepplinger [this message]
2023-09-27 8:19 ` [RFC PATCH 2/2] hid: lenovo: move type checks to lenovo_features_set_cptkbd() Jamie Lentin
2023-09-27 11:20 ` Martin Kepplinger
2023-09-28 21:06 ` Jamie Lentin
2023-09-30 9:26 ` Martin Kepplinger
2023-09-30 9:58 ` Jamie Lentin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230925102302.13094-2-martink@posteo.de \
--to=martink@posteo.de \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=jm@lentin.co.uk \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox