Linux Input/HID development
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>, linux-input@vger.kernel.org
Subject: [PATCH] HID: generic: Check other drivers match callback from __check_hid_generic
Date: Fri, 31 Jan 2020 13:46:15 +0100	[thread overview]
Message-ID: <20200131124615.27849-1-hdegoede@redhat.com> (raw)

__check_hid_generic is used to check if there is a driver, other then
the hid-generic driver, which wants to handle the hid-device, in which
case hid_generic_match() will return false so that the other driver can
bind.

But what if the other driver also has a match callback and that indicates
it does not want to handle the device? Then hid-generic should bind to it
and thus hid_generic_match() should NOT return false in that case.

This commit makes __check_hid_generic check if a matching driver has
a match callback and if it does makes its check this, so that
hid-generic will bind to devices which have a matching other driver,
but that other driver's match callback rejects the device.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
This patch was written while fixing the issues with hid-ite on the
Acer SW5-012, where we only want to bind to one interface. In that
specific case this change is not necessary because hid-multitouch will
pick the hid-device which hid-ite's match callback is rejecting.
---
 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 f9db991d3c5a..fe3ca7612750 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 1;
+
+	return hdrv->match(hdev, false);
 }
 
 static bool hid_generic_match(struct hid_device *hdev,
-- 
2.23.0


             reply	other threads:[~2020-01-31 12:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31 12:46 Hans de Goede [this message]
2020-01-31 13:39 ` [PATCH] HID: generic: Check other drivers match callback from __check_hid_generic Benjamin Tissoires
2020-01-31 13:48   ` Hans de Goede
2020-01-31 14:00     ` Benjamin Tissoires
2020-01-31 14:06       ` Hans de Goede
2020-01-31 14:13         ` Benjamin Tissoires

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=20200131124615.27849-1-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@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