diff options
Diffstat (limited to 'drivers/hid/usbhid')
-rw-r--r-- | drivers/hid/usbhid/hid-core.c | 85 | ||||
-rw-r--r-- | drivers/hid/usbhid/hid-quirks.c | 1 | ||||
-rw-r--r-- | drivers/hid/usbhid/hiddev.c | 19 | ||||
-rw-r--r-- | drivers/hid/usbhid/usbkbd.c | 1 |
4 files changed, 84 insertions, 22 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 56d06cd8075b..ca3751fd4473 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -807,16 +807,36 @@ static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t co | |||
807 | struct usb_host_interface *interface = intf->cur_altsetting; | 807 | struct usb_host_interface *interface = intf->cur_altsetting; |
808 | int ret; | 808 | int ret; |
809 | 809 | ||
810 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 810 | if (usbhid->urbout) { |
811 | HID_REQ_SET_REPORT, | 811 | int actual_length; |
812 | USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | 812 | int skipped_report_id = 0; |
813 | ((report_type + 1) << 8) | *buf, | 813 | if (buf[0] == 0x0) { |
814 | interface->desc.bInterfaceNumber, buf + 1, count - 1, | 814 | /* Don't send the Report ID */ |
815 | USB_CTRL_SET_TIMEOUT); | 815 | buf++; |
816 | 816 | count--; | |
817 | /* count also the report id */ | 817 | skipped_report_id = 1; |
818 | if (ret > 0) | 818 | } |
819 | ret++; | 819 | ret = usb_interrupt_msg(dev, usbhid->urbout->pipe, |
820 | buf, count, &actual_length, | ||
821 | USB_CTRL_SET_TIMEOUT); | ||
822 | /* return the number of bytes transferred */ | ||
823 | if (ret == 0) { | ||
824 | ret = actual_length; | ||
825 | /* count also the report id */ | ||
826 | if (skipped_report_id) | ||
827 | ret++; | ||
828 | } | ||
829 | } else { | ||
830 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
831 | HID_REQ_SET_REPORT, | ||
832 | USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
833 | ((report_type + 1) << 8) | *buf, | ||
834 | interface->desc.bInterfaceNumber, buf + 1, count - 1, | ||
835 | USB_CTRL_SET_TIMEOUT); | ||
836 | /* count also the report id */ | ||
837 | if (ret > 0) | ||
838 | ret++; | ||
839 | } | ||
820 | 840 | ||
821 | return ret; | 841 | return ret; |
822 | } | 842 | } |
@@ -999,13 +1019,6 @@ static int usbhid_start(struct hid_device *hid) | |||
999 | } | 1019 | } |
1000 | } | 1020 | } |
1001 | 1021 | ||
1002 | init_waitqueue_head(&usbhid->wait); | ||
1003 | INIT_WORK(&usbhid->reset_work, hid_reset); | ||
1004 | INIT_WORK(&usbhid->restart_work, __usbhid_restart_queues); | ||
1005 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); | ||
1006 | |||
1007 | spin_lock_init(&usbhid->lock); | ||
1008 | |||
1009 | usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); | 1022 | usbhid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); |
1010 | if (!usbhid->urbctrl) { | 1023 | if (!usbhid->urbctrl) { |
1011 | ret = -ENOMEM; | 1024 | ret = -ENOMEM; |
@@ -1026,12 +1039,15 @@ static int usbhid_start(struct hid_device *hid) | |||
1026 | /* Some keyboards don't work until their LEDs have been set. | 1039 | /* Some keyboards don't work until their LEDs have been set. |
1027 | * Since BIOSes do set the LEDs, it must be safe for any device | 1040 | * Since BIOSes do set the LEDs, it must be safe for any device |
1028 | * that supports the keyboard boot protocol. | 1041 | * that supports the keyboard boot protocol. |
1042 | * In addition, enable remote wakeup by default for all keyboard | ||
1043 | * devices supporting the boot protocol. | ||
1029 | */ | 1044 | */ |
1030 | if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT && | 1045 | if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT && |
1031 | interface->desc.bInterfaceProtocol == | 1046 | interface->desc.bInterfaceProtocol == |
1032 | USB_INTERFACE_PROTOCOL_KEYBOARD) | 1047 | USB_INTERFACE_PROTOCOL_KEYBOARD) { |
1033 | usbhid_set_leds(hid); | 1048 | usbhid_set_leds(hid); |
1034 | 1049 | device_set_wakeup_enable(&dev->dev, 1); | |
1050 | } | ||
1035 | return 0; | 1051 | return 0; |
1036 | 1052 | ||
1037 | fail: | 1053 | fail: |
@@ -1140,6 +1156,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * | |||
1140 | hid->vendor = le16_to_cpu(dev->descriptor.idVendor); | 1156 | hid->vendor = le16_to_cpu(dev->descriptor.idVendor); |
1141 | hid->product = le16_to_cpu(dev->descriptor.idProduct); | 1157 | hid->product = le16_to_cpu(dev->descriptor.idProduct); |
1142 | hid->name[0] = 0; | 1158 | hid->name[0] = 0; |
1159 | hid->quirks = usbhid_lookup_quirk(hid->vendor, hid->product); | ||
1143 | if (intf->cur_altsetting->desc.bInterfaceProtocol == | 1160 | if (intf->cur_altsetting->desc.bInterfaceProtocol == |
1144 | USB_INTERFACE_PROTOCOL_MOUSE) | 1161 | USB_INTERFACE_PROTOCOL_MOUSE) |
1145 | hid->type = HID_TYPE_USBMOUSE; | 1162 | hid->type = HID_TYPE_USBMOUSE; |
@@ -1179,6 +1196,12 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * | |||
1179 | usbhid->intf = intf; | 1196 | usbhid->intf = intf; |
1180 | usbhid->ifnum = interface->desc.bInterfaceNumber; | 1197 | usbhid->ifnum = interface->desc.bInterfaceNumber; |
1181 | 1198 | ||
1199 | init_waitqueue_head(&usbhid->wait); | ||
1200 | INIT_WORK(&usbhid->reset_work, hid_reset); | ||
1201 | INIT_WORK(&usbhid->restart_work, __usbhid_restart_queues); | ||
1202 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); | ||
1203 | spin_lock_init(&usbhid->lock); | ||
1204 | |||
1182 | ret = hid_add_device(hid); | 1205 | ret = hid_add_device(hid); |
1183 | if (ret) { | 1206 | if (ret) { |
1184 | if (ret != -ENODEV) | 1207 | if (ret != -ENODEV) |
@@ -1290,6 +1313,11 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message) | |||
1290 | { | 1313 | { |
1291 | set_bit(HID_REPORTED_IDLE, &usbhid->iofl); | 1314 | set_bit(HID_REPORTED_IDLE, &usbhid->iofl); |
1292 | spin_unlock_irq(&usbhid->lock); | 1315 | spin_unlock_irq(&usbhid->lock); |
1316 | if (hid->driver && hid->driver->suspend) { | ||
1317 | status = hid->driver->suspend(hid, message); | ||
1318 | if (status < 0) | ||
1319 | return status; | ||
1320 | } | ||
1293 | } else { | 1321 | } else { |
1294 | usbhid_mark_busy(usbhid); | 1322 | usbhid_mark_busy(usbhid); |
1295 | spin_unlock_irq(&usbhid->lock); | 1323 | spin_unlock_irq(&usbhid->lock); |
@@ -1297,6 +1325,11 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message) | |||
1297 | } | 1325 | } |
1298 | 1326 | ||
1299 | } else { | 1327 | } else { |
1328 | if (hid->driver && hid->driver->suspend) { | ||
1329 | status = hid->driver->suspend(hid, message); | ||
1330 | if (status < 0) | ||
1331 | return status; | ||
1332 | } | ||
1300 | spin_lock_irq(&usbhid->lock); | 1333 | spin_lock_irq(&usbhid->lock); |
1301 | set_bit(HID_REPORTED_IDLE, &usbhid->iofl); | 1334 | set_bit(HID_REPORTED_IDLE, &usbhid->iofl); |
1302 | spin_unlock_irq(&usbhid->lock); | 1335 | spin_unlock_irq(&usbhid->lock); |
@@ -1351,6 +1384,11 @@ static int hid_resume(struct usb_interface *intf) | |||
1351 | hid_io_error(hid); | 1384 | hid_io_error(hid); |
1352 | usbhid_restart_queues(usbhid); | 1385 | usbhid_restart_queues(usbhid); |
1353 | 1386 | ||
1387 | if (status >= 0 && hid->driver && hid->driver->resume) { | ||
1388 | int ret = hid->driver->resume(hid); | ||
1389 | if (ret < 0) | ||
1390 | status = ret; | ||
1391 | } | ||
1354 | dev_dbg(&intf->dev, "resume status %d\n", status); | 1392 | dev_dbg(&intf->dev, "resume status %d\n", status); |
1355 | return 0; | 1393 | return 0; |
1356 | } | 1394 | } |
@@ -1359,9 +1397,16 @@ static int hid_reset_resume(struct usb_interface *intf) | |||
1359 | { | 1397 | { |
1360 | struct hid_device *hid = usb_get_intfdata(intf); | 1398 | struct hid_device *hid = usb_get_intfdata(intf); |
1361 | struct usbhid_device *usbhid = hid->driver_data; | 1399 | struct usbhid_device *usbhid = hid->driver_data; |
1400 | int status; | ||
1362 | 1401 | ||
1363 | clear_bit(HID_REPORTED_IDLE, &usbhid->iofl); | 1402 | clear_bit(HID_REPORTED_IDLE, &usbhid->iofl); |
1364 | return hid_post_reset(intf); | 1403 | status = hid_post_reset(intf); |
1404 | if (status >= 0 && hid->driver && hid->driver->reset_resume) { | ||
1405 | int ret = hid->driver->reset_resume(hid); | ||
1406 | if (ret < 0) | ||
1407 | status = ret; | ||
1408 | } | ||
1409 | return status; | ||
1365 | } | 1410 | } |
1366 | 1411 | ||
1367 | #endif /* CONFIG_PM */ | 1412 | #endif /* CONFIG_PM */ |
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 1152f9b5fd44..5ff8d327f33a 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c | |||
@@ -33,6 +33,7 @@ static const struct hid_blacklist { | |||
33 | { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, | 33 | { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, |
34 | { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, | 34 | { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, |
35 | { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, | 35 | { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, |
36 | { USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH, HID_QUIRK_MULTI_INPUT }, | ||
36 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 37 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
37 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 38 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
38 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 39 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index 433602aed468..c24d2fa3e3b6 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c | |||
@@ -267,6 +267,7 @@ static int hiddev_open(struct inode *inode, struct file *file) | |||
267 | struct hiddev_list *list; | 267 | struct hiddev_list *list; |
268 | int res, i; | 268 | int res, i; |
269 | 269 | ||
270 | /* See comment in hiddev_connect() for BKL explanation */ | ||
270 | lock_kernel(); | 271 | lock_kernel(); |
271 | i = iminor(inode) - HIDDEV_MINOR_BASE; | 272 | i = iminor(inode) - HIDDEV_MINOR_BASE; |
272 | 273 | ||
@@ -894,8 +895,22 @@ int hiddev_connect(struct hid_device *hid, unsigned int force) | |||
894 | hiddev->hid = hid; | 895 | hiddev->hid = hid; |
895 | hiddev->exist = 1; | 896 | hiddev->exist = 1; |
896 | 897 | ||
897 | /* when lock_kernel() usage is fixed in usb_open(), | 898 | /* |
898 | * we could also fix it here */ | 899 | * BKL here is used to avoid race after usb_register_dev(). |
900 | * Once the device node has been created, open() could happen on it. | ||
901 | * The code below will then fail, as hiddev_table hasn't been | ||
902 | * updated. | ||
903 | * | ||
904 | * The obvious fix -- introducing mutex to guard hiddev_table[] | ||
905 | * doesn't work, as usb_open() and usb_register_dev() both take | ||
906 | * minor_rwsem, thus we'll have ABBA deadlock. | ||
907 | * | ||
908 | * Before BKL pushdown, usb_open() had been acquiring it in right | ||
909 | * order, so _open() was safe to use it to protect from this race. | ||
910 | * Now the order is different, but AB-BA deadlock still doesn't occur | ||
911 | * as BKL is dropped on schedule() (i.e. while sleeping on | ||
912 | * minor_rwsem). Fugly. | ||
913 | */ | ||
899 | lock_kernel(); | 914 | lock_kernel(); |
900 | retval = usb_register_dev(usbhid->intf, &hiddev_class); | 915 | retval = usb_register_dev(usbhid->intf, &hiddev_class); |
901 | if (retval) { | 916 | if (retval) { |
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c index f843443ba5c3..b2fd0b00de92 100644 --- a/drivers/hid/usbhid/usbkbd.c +++ b/drivers/hid/usbhid/usbkbd.c | |||
@@ -313,6 +313,7 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
313 | goto fail2; | 313 | goto fail2; |
314 | 314 | ||
315 | usb_set_intfdata(iface, kbd); | 315 | usb_set_intfdata(iface, kbd); |
316 | device_set_wakeup_enable(&dev->dev, 1); | ||
316 | return 0; | 317 | return 0; |
317 | 318 | ||
318 | fail2: | 319 | fail2: |