mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vas Zayarskiy <contact@vasily.cc>
To: linux@roeck-us.net, Aleksa Savic <savicaleksa83@gmail.com>,
	Jack Doan <me@jackdoan.com>, Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>
Cc: linux-hwmon@vger.kernel.org, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>
Subject: [PATCH v3 1/4] HID: generic: Respect specialized drivers match callbacks
Date: Tue, 15 Sep 2026 02:37:25 +0300	[thread overview]
Message-ID: <20260914233728.22725-2-contact@vasily.cc> (raw)
In-Reply-To: <20260914233728.22725-1-contact@vasily.cc>

A driver can reject an interface in its match callback even when its ID
table matches. hid-generic currently yields based on the ID table alone,
leaving such an interface without a driver.

Consult the callback after matching the ID table so hid-generic can keep
interfaces declined by specialized drivers. This allows the AMPINEL
hwmon driver to leave the separate keyboard interface to hid-generic.

The same callback check was proposed previously for Logitech devices:

Link: https://lkml.iu.edu/hypermail/linux/kernel/2212.0/06724.html

Assisted-by: LLM sparse
Signed-off-by: Vas Zayarskiy <contact@vasily.cc>
---
 drivers/hid/hid-generic.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-generic.c b/drivers/hid/hid-generic.c
index c2de91674..ebc38ae76 100644
--- a/drivers/hid/hid-generic.c
+++ b/drivers/hid/hid-generic.c
@@ -31,7 +31,13 @@ static int __check_hid_generic(struct device_driver *drv, void *data)
 	if (hdrv == &hid_generic)
 		return 0;
 
-	return hid_match_device(hdev, hdrv) != NULL;
+	if (!hid_match_device(hdev, hdrv))
+		return 0;
+
+	if (hdrv->match)
+		return hdrv->match(hdev, false);
+
+	return 1;
 }
 
 static bool hid_generic_match(struct hid_device *hdev,

  reply	other threads:[~2026-09-14 23:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 23:37 [PATCH v3 0/4] hwmon: AMPINEL support and shared fixes Vas Zayarskiy
2026-09-14 23:37 ` Vas Zayarskiy [this message]
2026-09-15  4:31   ` [PATCH v3 1/4] HID: generic: Respect specialized drivers match callbacks Guenter Roeck
2026-09-15  5:22     ` Vas Zayarskiy
2026-09-14 23:37 ` [PATCH v3 2/4] hwmon: (aquacomputer_d5next) Avoid truncating scaled sensor readings Vas Zayarskiy
2026-09-15  4:38   ` Guenter Roeck
2026-09-14 23:37 ` [PATCH v3 3/4] hwmon: (aquacomputer_d5next) Expire the initial sensor cache Vas Zayarskiy
2026-09-14 23:37 ` [PATCH v3 4/4] hwmon: (aquacomputer_d5next) Add AMPINEL support Vas Zayarskiy
2026-09-15  4:30   ` Guenter Roeck
2026-09-15  5:29     ` Vas Zayarskiy
2026-09-15 17:09       ` Guenter Roeck

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=20260914233728.22725-2-contact@vasily.cc \
    --to=contact@vasily.cc \
    --cc=bentiss@kernel.org \
    --cc=corbet@lwn.net \
    --cc=jikos@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=me@jackdoan.com \
    --cc=rdunlap@infradead.org \
    --cc=savicaleksa83@gmail.com \
    --cc=skhan@linuxfoundation.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

all inboxes | Powered by JetHome®