From: Jiri Slaby <jirislaby@gmail.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
Jiri Kosina <jkosina@suse.cz>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Jiri Slaby <jirislaby@gmail.com>
Subject: [PATCH] HID: don't grab devices with no input
Date: Thu, 13 Nov 2008 22:10:00 +0100 [thread overview]
Message-ID: <1226610600-22899-1-git-send-email-jirislaby@gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0811131040160.2380-100000@iolanthe.rowland.org>
Alan Stern wrote:
> This suggests that a lot of the work in usbhid_start should be
> performed earlier, before calling hid_add_device. After all, why
> bother registering a USB device on the input bus if usbhid isn't going
> to be able to drive it?
None of the code can be moved to the usbhid probe function, because all
of it depends on the driver's (potential) report_fixup.
However I suggest moving this test to the probe which ensures performing
the test early enough.
Andi, could you test the attached patch?
--
Some devices have no input interrupt endpoint. These won't be handled
by usbhid, but currently they are not refused and reside on hid bus.
Perform this checking earlier so that we refuse to control such
a device early enough (and not pass it to the hid bus at all).
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
drivers/hid/usbhid/hid-core.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index f7e0d71..2c5cb10 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -845,12 +845,6 @@ static int usbhid_start(struct hid_device *hid)
}
}
- if (!usbhid->urbin) {
- err_hid("couldn't find an input interrupt endpoint");
- ret = -ENODEV;
- goto fail;
- }
-
init_waitqueue_head(&usbhid->wait);
INIT_WORK(&usbhid->reset_work, hid_reset);
setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid);
@@ -947,15 +941,26 @@ static struct hid_ll_driver usb_hid_driver = {
static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
+ struct usb_host_interface *interface = intf->cur_altsetting;
struct usb_device *dev = interface_to_usbdev(intf);
struct usbhid_device *usbhid;
struct hid_device *hid;
+ unsigned int n, has_in = 0;
size_t len;
int ret;
dbg_hid("HID probe called for ifnum %d\n",
intf->altsetting->desc.bInterfaceNumber);
+ for (n = 0; n < interface->desc.bNumEndpoints; n++)
+ if (usb_endpoint_dir_in(&interface->endpoint[n].desc))
+ has_in++;
+ if (!has_in) {
+ dev_err(&intf->dev, "couldn't find an input interrupt "
+ "endpoint");
+ return -ENODEV;
+ }
+
hid = hid_allocate_device();
if (IS_ERR(hid))
return PTR_ERR(hid);
--
1.6.0.3
next prev parent reply other threads:[~2008-11-13 21:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-11 0:31 USB hid blocks USB port in 2.6.28rc3 Andi Kleen
2008-11-11 0:45 ` Alan Stern
2008-11-11 8:41 ` Andi Kleen
2008-11-11 17:02 ` Alan Stern
2008-11-11 21:07 ` Andi Kleen
[not found] ` <20081111210705.GG3810-qrUzlfsMFqo/4alezvVtWx2eb7JE58TQ@public.gmane.org>
2008-11-12 14:53 ` Alan Stern
2008-11-15 23:58 ` Rafael J. Wysocki
2008-11-15 23:54 ` Jiri Kosina
2008-11-16 12:35 ` Rafael J. Wysocki
[not found] ` <alpine.LNX.1.10.0811160053580.19853-YCXOAqNspd+N3ZZ/Hiejyg@public.gmane.org>
2008-11-16 22:12 ` Andi Kleen
[not found] ` <20081111003117.GA10904-3rXA9MLqAseW/qJFnhkgxti2O/JbrIOy@public.gmane.org>
2008-11-12 14:31 ` Jiri Kosina
[not found] ` <alpine.LNX.1.10.0811121529240.32143-YCXOAqNspd+N3ZZ/Hiejyg@public.gmane.org>
2008-11-13 11:32 ` Andi Kleen
2008-11-13 12:30 ` Jiri Slaby
[not found] ` <491C1DFF.6000509-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-11-13 14:31 ` Andi Kleen
2008-11-13 15:54 ` Alan Stern
2008-11-13 21:10 ` Jiri Slaby [this message]
2008-11-13 21:37 ` [PATCH] HID: don't grab devices with no input Alan Stern
2008-11-13 22:05 ` Jiri Slaby
2008-11-13 22:09 ` [PATCH 1/1 v2] DRM: fix radeon suspend/resume oops Jiri Slaby
2008-11-13 22:11 ` Jiri Slaby
2008-11-13 22:10 ` [PATCH 1/1 v2] HID: don't grab devices with no input Jiri Slaby
2008-11-14 11:02 ` Jiri Kosina
2008-11-14 13:17 ` Andi Kleen
2008-11-14 13:09 ` Jiri Kosina
2008-11-13 22:22 ` [PATCH] " Andi Kleen
2008-11-13 22:14 ` Jiri Slaby
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=1226610600-22899-1-git-send-email-jirislaby@gmail.com \
--to=jirislaby@gmail.com \
--cc=andi@firstfloor.org \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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;
as well as URLs for NNTP newsgroup(s).