aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-11 12:56:05 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-11 12:56:05 -0400
commit5884c40668a928bba017eaf54e2eb3c01c8a98e6 (patch)
tree240bdf1b015f0bc2ce8c1811bd0b528c1ef386c2
parentee54d2d87a8158d14434c1a3274bd7f713105836 (diff)
parentcdcb44e87bedcf5070eece61f89f9373a3810031 (diff)
Merge branch 'upstream-fixes' of master.kernel.org:/pub/scm/linux/kernel/git/jikos/hid
* 'upstream-fixes' of master.kernel.org:/pub/scm/linux/kernel/git/jikos/hid: USB HID: hiddev - fix race between hiddev_send_event() and hiddev_release() HID: add hooks for getkeycode() and setkeycode() methods HID: switch to using input_dev->dev.parent USB HID: Logitech wheel 0x046d/0xc294 needs HID_QUIRK_NOGET quirk USB HID: usb_buffer_free() cleanup USB HID: report descriptor of Cypress USB barcode readers needs fixup Bluetooth HID: HIDP - don't initialize force feedback USB HID: update CONFIG_USB_HIDINPUT_POWERBOOK description HID: add input mappings for non-working keys on Logitech S510 remote
-rw-r--r--drivers/hid/hid-input.c101
-rw-r--r--drivers/hid/usbhid/Kconfig4
-rw-r--r--drivers/hid/usbhid/hid-core.c41
-rw-r--r--drivers/hid/usbhid/hid-lgff.c2
-rw-r--r--drivers/hid/usbhid/hid-plff.c2
-rw-r--r--drivers/hid/usbhid/hid-quirks.c7
-rw-r--r--drivers/hid/usbhid/hid-tmff.c2
-rw-r--r--drivers/hid/usbhid/hid-zpff.c2
-rw-r--r--drivers/hid/usbhid/hiddev.c14
-rw-r--r--drivers/hid/usbhid/usbkbd.c21
-rw-r--r--drivers/hid/usbhid/usbmouse.c9
-rw-r--r--include/linux/hid.h1
-rw-r--r--net/bluetooth/hidp/core.c4
13 files changed, 171 insertions, 39 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index a19b65ed3119..7f817897b178 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -240,11 +240,94 @@ static inline void hidinput_pb_setup(struct input_dev *input)
240} 240}
241#endif 241#endif
242 242
243static inline int match_scancode(int code, int scancode)
244{
245 if (scancode == 0)
246 return 1;
247 return ((code & (HID_USAGE_PAGE | HID_USAGE)) == scancode);
248}
249
250static inline int match_keycode(int code, int keycode)
251{
252 if (keycode == 0)
253 return 1;
254 return (code == keycode);
255}
256
257static struct hid_usage *hidinput_find_key(struct hid_device *hid,
258 int scancode, int keycode)
259{
260 int i, j, k;
261 struct hid_report *report;
262 struct hid_usage *usage;
263
264 for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) {
265 list_for_each_entry(report, &hid->report_enum[k].report_list, list) {
266 for (i = 0; i < report->maxfield; i++) {
267 for ( j = 0; j < report->field[i]->maxusage; j++) {
268 usage = report->field[i]->usage + j;
269 if (usage->type == EV_KEY &&
270 match_scancode(usage->hid, scancode) &&
271 match_keycode(usage->code, keycode))
272 return usage;
273 }
274 }
275 }
276 }
277 return NULL;
278}
279
280static int hidinput_getkeycode(struct input_dev *dev, int scancode,
281 int *keycode)
282{
283 struct hid_device *hid = dev->private;
284 struct hid_usage *usage;
285
286 usage = hidinput_find_key(hid, scancode, 0);
287 if (usage) {
288 *keycode = usage->code;
289 return 0;
290 }
291 return -EINVAL;
292}
293
294static int hidinput_setkeycode(struct input_dev *dev, int scancode,
295 int keycode)
296{
297 struct hid_device *hid = dev->private;
298 struct hid_usage *usage;
299 int old_keycode;
300
301 if (keycode < 0 || keycode > KEY_MAX)
302 return -EINVAL;
303
304 usage = hidinput_find_key(hid, scancode, 0);
305 if (usage) {
306 old_keycode = usage->code;
307 usage->code = keycode;
308
309 clear_bit(old_keycode, dev->keybit);
310 set_bit(usage->code, dev->keybit);
311#ifdef CONFIG_HID_DEBUG
312 printk (KERN_DEBUG "Assigned keycode %d to HID usage code %x\n", keycode, scancode);
313#endif
314 /* Set the keybit for the old keycode if the old keycode is used
315 * by another key */
316 if (hidinput_find_key (hid, 0, old_keycode))
317 set_bit(old_keycode, dev->keybit);
318
319 return 0;
320 }
321
322 return -EINVAL;
323}
324
325
243static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, 326static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field,
244 struct hid_usage *usage) 327 struct hid_usage *usage)
245{ 328{
246 struct input_dev *input = hidinput->input; 329 struct input_dev *input = hidinput->input;
247 struct hid_device *device = input->private; 330 struct hid_device *device = input_get_drvdata(input);
248 int max = 0, code; 331 int max = 0, code;
249 unsigned long *bit = NULL; 332 unsigned long *bit = NULL;
250 333
@@ -553,6 +636,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
553 case 0x1015: map_key_clear(KEY_RECORD); break; 636 case 0x1015: map_key_clear(KEY_RECORD); break;
554 case 0x1016: map_key_clear(KEY_PLAYER); break; 637 case 0x1016: map_key_clear(KEY_PLAYER); break;
555 case 0x1017: map_key_clear(KEY_EJECTCD); break; 638 case 0x1017: map_key_clear(KEY_EJECTCD); break;
639 case 0x1018: map_key_clear(KEY_MEDIA); break;
556 case 0x1019: map_key_clear(KEY_PROG1); break; 640 case 0x1019: map_key_clear(KEY_PROG1); break;
557 case 0x101a: map_key_clear(KEY_PROG2); break; 641 case 0x101a: map_key_clear(KEY_PROG2); break;
558 case 0x101b: map_key_clear(KEY_PROG3); break; 642 case 0x101b: map_key_clear(KEY_PROG3); break;
@@ -560,9 +644,12 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
560 case 0x1020: map_key_clear(KEY_ZOOMOUT); break; 644 case 0x1020: map_key_clear(KEY_ZOOMOUT); break;
561 case 0x1021: map_key_clear(KEY_ZOOMRESET); break; 645 case 0x1021: map_key_clear(KEY_ZOOMRESET); break;
562 case 0x1023: map_key_clear(KEY_CLOSE); break; 646 case 0x1023: map_key_clear(KEY_CLOSE); break;
647 case 0x1027: map_key_clear(KEY_MENU); break;
563 /* this one is marked as 'Rotate' */ 648 /* this one is marked as 'Rotate' */
564 case 0x1028: map_key_clear(KEY_ANGLE); break; 649 case 0x1028: map_key_clear(KEY_ANGLE); break;
565 case 0x1029: map_key_clear(KEY_SHUFFLE); break; 650 case 0x1029: map_key_clear(KEY_SHUFFLE); break;
651 case 0x102a: map_key_clear(KEY_BACK); break;
652 case 0x102b: map_key_clear(KEY_CYCLEWINDOWS); break;
566 case 0x1041: map_key_clear(KEY_BATTERY); break; 653 case 0x1041: map_key_clear(KEY_BATTERY); break;
567 case 0x1042: map_key_clear(KEY_WORDPROCESSOR); break; 654 case 0x1042: map_key_clear(KEY_WORDPROCESSOR); break;
568 case 0x1043: map_key_clear(KEY_SPREADSHEET); break; 655 case 0x1043: map_key_clear(KEY_SPREADSHEET); break;
@@ -855,13 +942,15 @@ EXPORT_SYMBOL_GPL(hidinput_find_field);
855 942
856static int hidinput_open(struct input_dev *dev) 943static int hidinput_open(struct input_dev *dev)
857{ 944{
858 struct hid_device *hid = dev->private; 945 struct hid_device *hid = input_get_drvdata(dev);
946
859 return hid->hid_open(hid); 947 return hid->hid_open(hid);
860} 948}
861 949
862static void hidinput_close(struct input_dev *dev) 950static void hidinput_close(struct input_dev *dev)
863{ 951{
864 struct hid_device *hid = dev->private; 952 struct hid_device *hid = input_get_drvdata(dev);
953
865 hid->hid_close(hid); 954 hid->hid_close(hid);
866} 955}
867 956
@@ -909,10 +998,12 @@ int hidinput_connect(struct hid_device *hid)
909 return -1; 998 return -1;
910 } 999 }
911 1000
912 input_dev->private = hid; 1001 input_set_drvdata(input_dev, hid);
913 input_dev->event = hid->hidinput_input_event; 1002 input_dev->event = hid->hidinput_input_event;
914 input_dev->open = hidinput_open; 1003 input_dev->open = hidinput_open;
915 input_dev->close = hidinput_close; 1004 input_dev->close = hidinput_close;
1005 input_dev->setkeycode = hidinput_setkeycode;
1006 input_dev->getkeycode = hidinput_getkeycode;
916 1007
917 input_dev->name = hid->name; 1008 input_dev->name = hid->name;
918 input_dev->phys = hid->phys; 1009 input_dev->phys = hid->phys;
@@ -921,7 +1012,7 @@ int hidinput_connect(struct hid_device *hid)
921 input_dev->id.vendor = hid->vendor; 1012 input_dev->id.vendor = hid->vendor;
922 input_dev->id.product = hid->product; 1013 input_dev->id.product = hid->product;
923 input_dev->id.version = hid->version; 1014 input_dev->id.version = hid->version;
924 input_dev->cdev.dev = hid->dev; 1015 input_dev->dev.parent = hid->dev;
925 hidinput->input = input_dev; 1016 hidinput->input = input_dev;
926 list_add_tail(&hidinput->list, &hid->inputs); 1017 list_add_tail(&hidinput->list, &hid->inputs);
927 } 1018 }
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig
index 7c87bdc538bc..1b4b572f899b 100644
--- a/drivers/hid/usbhid/Kconfig
+++ b/drivers/hid/usbhid/Kconfig
@@ -25,12 +25,12 @@ comment "Input core support is needed for USB HID input layer or HIDBP support"
25 depends on USB_HID && INPUT=n 25 depends on USB_HID && INPUT=n
26 26
27config USB_HIDINPUT_POWERBOOK 27config USB_HIDINPUT_POWERBOOK
28 bool "Enable support for iBook/PowerBook special keys" 28 bool "Enable support for iBook/PowerBook/MacBook/MacBookPro special keys"
29 default n 29 default n
30 depends on USB_HID 30 depends on USB_HID
31 help 31 help
32 Say Y here if you want support for the special keys (Fn, Numlock) on 32 Say Y here if you want support for the special keys (Fn, Numlock) on
33 Apple iBooks and PowerBooks. 33 Apple iBooks, PowerBooks, MacBooks and MacBook Pros.
34 34
35 If unsure, say N. 35 If unsure, say N.
36 36
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 91d610358d57..d91b9dac6dff 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -446,7 +446,7 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
446 446
447static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 447static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
448{ 448{
449 struct hid_device *hid = dev->private; 449 struct hid_device *hid = input_get_drvdata(dev);
450 struct hid_field *field; 450 struct hid_field *field;
451 int offset; 451 int offset;
452 452
@@ -626,14 +626,10 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
626{ 626{
627 struct usbhid_device *usbhid = hid->driver_data; 627 struct usbhid_device *usbhid = hid->driver_data;
628 628
629 if (usbhid->inbuf) 629 usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma);
630 usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma); 630 usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma);
631 if (usbhid->outbuf) 631 usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma);
632 usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma); 632 usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma);
633 if (usbhid->cr)
634 usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma);
635 if (usbhid->ctrlbuf)
636 usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma);
637} 633}
638 634
639/* 635/*
@@ -692,6 +688,30 @@ static void hid_fixup_logitech_descriptor(unsigned char *rdesc, int rsize)
692 } 688 }
693} 689}
694 690
691/*
692 * Some USB barcode readers from cypress have usage min and usage max in
693 * the wrong order
694 */
695static void hid_fixup_cypress_descriptor(unsigned char *rdesc, int rsize)
696{
697 short fixed = 0;
698 int i;
699
700 for (i = 0; i < rsize - 4; i++) {
701 if (rdesc[i] == 0x29 && rdesc [i+2] == 0x19) {
702 unsigned char tmp;
703
704 rdesc[i] = 0x19; rdesc[i+2] = 0x29;
705 tmp = rdesc[i+3];
706 rdesc[i+3] = rdesc[i+1];
707 rdesc[i+1] = tmp;
708 }
709 }
710
711 if (fixed)
712 info("Fixing up Cypress report descriptor");
713}
714
695static struct hid_device *usb_hid_configure(struct usb_interface *intf) 715static struct hid_device *usb_hid_configure(struct usb_interface *intf)
696{ 716{
697 struct usb_host_interface *interface = intf->cur_altsetting; 717 struct usb_host_interface *interface = intf->cur_altsetting;
@@ -758,6 +778,9 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
758 if (quirks & HID_QUIRK_LOGITECH_DESCRIPTOR) 778 if (quirks & HID_QUIRK_LOGITECH_DESCRIPTOR)
759 hid_fixup_logitech_descriptor(rdesc, rsize); 779 hid_fixup_logitech_descriptor(rdesc, rsize);
760 780
781 if (quirks & HID_QUIRK_SWAPPED_MIN_MAX)
782 hid_fixup_cypress_descriptor(rdesc, rsize);
783
761#ifdef CONFIG_HID_DEBUG 784#ifdef CONFIG_HID_DEBUG
762 printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n); 785 printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n);
763 for (n = 0; n < rsize; n++) 786 for (n = 0; n < rsize; n++)
diff --git a/drivers/hid/usbhid/hid-lgff.c b/drivers/hid/usbhid/hid-lgff.c
index 92d2553f17b6..c5cd4107d6af 100644
--- a/drivers/hid/usbhid/hid-lgff.c
+++ b/drivers/hid/usbhid/hid-lgff.c
@@ -60,7 +60,7 @@ static const struct dev_type devices[] = {
60 60
61static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect) 61static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect)
62{ 62{
63 struct hid_device *hid = dev->private; 63 struct hid_device *hid = input_get_drvdata(dev);
64 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 64 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
65 struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 65 struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
66 int x, y; 66 int x, y;
diff --git a/drivers/hid/usbhid/hid-plff.c b/drivers/hid/usbhid/hid-plff.c
index 76d2e6e14db4..d6a8f2b49bd2 100644
--- a/drivers/hid/usbhid/hid-plff.c
+++ b/drivers/hid/usbhid/hid-plff.c
@@ -37,7 +37,7 @@ struct plff_device {
37static int hid_plff_play(struct input_dev *dev, void *data, 37static int hid_plff_play(struct input_dev *dev, void *data,
38 struct ff_effect *effect) 38 struct ff_effect *effect)
39{ 39{
40 struct hid_device *hid = dev->private; 40 struct hid_device *hid = input_get_drvdata(dev);
41 struct plff_device *plff = data; 41 struct plff_device *plff = data;
42 int left, right; 42 int left, right;
43 43
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 17a87555e32f..f6c4145dc202 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -92,6 +92,8 @@
92#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 92#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001
93#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 93#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500
94#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 94#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417
95#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61
96#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64
95 97
96#define USB_VENDOR_ID_DELL 0x413c 98#define USB_VENDOR_ID_DELL 0x413c
97#define USB_DEVICE_ID_DELL_W7658 0x2005 99#define USB_DEVICE_ID_DELL_W7658 0x2005
@@ -193,6 +195,7 @@
193 195
194#define USB_VENDOR_ID_LOGITECH 0x046d 196#define USB_VENDOR_ID_LOGITECH 0x046d
195#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101 197#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101
198#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294
196#define USB_DEVICE_ID_S510_RECEIVER 0xc50c 199#define USB_DEVICE_ID_S510_RECEIVER 0xc50c
197#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 200#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517
198#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513 201#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513
@@ -422,6 +425,7 @@ static const struct hid_blacklist {
422 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, 425 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET },
423 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, 426 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET },
424 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, 427 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
428 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL, HID_QUIRK_NOGET },
425 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, 429 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
426 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, 430 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
427 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 431 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
@@ -445,6 +449,9 @@ static const struct hid_blacklist {
445 449
446 { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS }, 450 { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS },
447 451
452 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1, HID_QUIRK_SWAPPED_MIN_MAX },
453 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2, HID_QUIRK_SWAPPED_MIN_MAX },
454
448 { 0, 0 } 455 { 0, 0 }
449}; 456};
450 457
diff --git a/drivers/hid/usbhid/hid-tmff.c b/drivers/hid/usbhid/hid-tmff.c
index ab67331620d0..ab5ba6ef891c 100644
--- a/drivers/hid/usbhid/hid-tmff.c
+++ b/drivers/hid/usbhid/hid-tmff.c
@@ -59,7 +59,7 @@ static inline int hid_tmff_scale(unsigned int in, int minimum, int maximum)
59 59
60static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *effect) 60static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *effect)
61{ 61{
62 struct hid_device *hid = dev->private; 62 struct hid_device *hid = input_get_drvdata(dev);
63 struct tmff_device *tmff = data; 63 struct tmff_device *tmff = data;
64 int left, right; /* Rumbling */ 64 int left, right; /* Rumbling */
65 65
diff --git a/drivers/hid/usbhid/hid-zpff.c b/drivers/hid/usbhid/hid-zpff.c
index 7bd8238ca212..a7fbffcdaf36 100644
--- a/drivers/hid/usbhid/hid-zpff.c
+++ b/drivers/hid/usbhid/hid-zpff.c
@@ -37,7 +37,7 @@ struct zpff_device {
37static int hid_zpff_play(struct input_dev *dev, void *data, 37static int hid_zpff_play(struct input_dev *dev, void *data,
38 struct ff_effect *effect) 38 struct ff_effect *effect)
39{ 39{
40 struct hid_device *hid = dev->private; 40 struct hid_device *hid = input_get_drvdata(dev);
41 struct zpff_device *zpff = data; 41 struct zpff_device *zpff = data;
42 int left, right; 42 int left, right;
43 43
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index a8b3d66cd498..488d61bdbf2c 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -51,6 +51,7 @@ struct hiddev {
51 wait_queue_head_t wait; 51 wait_queue_head_t wait;
52 struct hid_device *hid; 52 struct hid_device *hid;
53 struct list_head list; 53 struct list_head list;
54 spinlock_t list_lock;
54}; 55};
55 56
56struct hiddev_list { 57struct hiddev_list {
@@ -161,7 +162,9 @@ static void hiddev_send_event(struct hid_device *hid,
161{ 162{
162 struct hiddev *hiddev = hid->hiddev; 163 struct hiddev *hiddev = hid->hiddev;
163 struct hiddev_list *list; 164 struct hiddev_list *list;
165 unsigned long flags;
164 166
167 spin_lock_irqsave(&hiddev->list_lock, flags);
165 list_for_each_entry(list, &hiddev->list, node) { 168 list_for_each_entry(list, &hiddev->list, node) {
166 if (uref->field_index != HID_FIELD_INDEX_NONE || 169 if (uref->field_index != HID_FIELD_INDEX_NONE ||
167 (list->flags & HIDDEV_FLAG_REPORT) != 0) { 170 (list->flags & HIDDEV_FLAG_REPORT) != 0) {
@@ -171,6 +174,7 @@ static void hiddev_send_event(struct hid_device *hid,
171 kill_fasync(&list->fasync, SIGIO, POLL_IN); 174 kill_fasync(&list->fasync, SIGIO, POLL_IN);
172 } 175 }
173 } 176 }
177 spin_unlock_irqrestore(&hiddev->list_lock, flags);
174 178
175 wake_up_interruptible(&hiddev->wait); 179 wake_up_interruptible(&hiddev->wait);
176} 180}
@@ -235,9 +239,13 @@ static int hiddev_fasync(int fd, struct file *file, int on)
235static int hiddev_release(struct inode * inode, struct file * file) 239static int hiddev_release(struct inode * inode, struct file * file)
236{ 240{
237 struct hiddev_list *list = file->private_data; 241 struct hiddev_list *list = file->private_data;
242 unsigned long flags;
238 243
239 hiddev_fasync(-1, file, 0); 244 hiddev_fasync(-1, file, 0);
245
246 spin_lock_irqsave(&list->hiddev->list_lock, flags);
240 list_del(&list->node); 247 list_del(&list->node);
248 spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
241 249
242 if (!--list->hiddev->open) { 250 if (!--list->hiddev->open) {
243 if (list->hiddev->exist) 251 if (list->hiddev->exist)
@@ -257,6 +265,7 @@ static int hiddev_release(struct inode * inode, struct file * file)
257static int hiddev_open(struct inode *inode, struct file *file) 265static int hiddev_open(struct inode *inode, struct file *file)
258{ 266{
259 struct hiddev_list *list; 267 struct hiddev_list *list;
268 unsigned long flags;
260 269
261 int i = iminor(inode) - HIDDEV_MINOR_BASE; 270 int i = iminor(inode) - HIDDEV_MINOR_BASE;
262 271
@@ -267,7 +276,11 @@ static int hiddev_open(struct inode *inode, struct file *file)
267 return -ENOMEM; 276 return -ENOMEM;
268 277
269 list->hiddev = hiddev_table[i]; 278 list->hiddev = hiddev_table[i];
279
280 spin_lock_irqsave(&list->hiddev->list_lock, flags);
270 list_add_tail(&list->node, &hiddev_table[i]->list); 281 list_add_tail(&list->node, &hiddev_table[i]->list);
282 spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
283
271 file->private_data = list; 284 file->private_data = list;
272 285
273 if (!list->hiddev->open++) 286 if (!list->hiddev->open++)
@@ -773,6 +786,7 @@ int hiddev_connect(struct hid_device *hid)
773 786
774 init_waitqueue_head(&hiddev->wait); 787 init_waitqueue_head(&hiddev->wait);
775 INIT_LIST_HEAD(&hiddev->list); 788 INIT_LIST_HEAD(&hiddev->list);
789 spin_lock_init(&hiddev->list_lock);
776 hiddev->hid = hid; 790 hiddev->hid = hid;
777 hiddev->exist = 1; 791 hiddev->exist = 1;
778 792
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
index 65aa12e8d7b3..130978780713 100644
--- a/drivers/hid/usbhid/usbkbd.c
+++ b/drivers/hid/usbhid/usbkbd.c
@@ -133,12 +133,11 @@ resubmit:
133static int usb_kbd_event(struct input_dev *dev, unsigned int type, 133static int usb_kbd_event(struct input_dev *dev, unsigned int type,
134 unsigned int code, int value) 134 unsigned int code, int value)
135{ 135{
136 struct usb_kbd *kbd = dev->private; 136 struct usb_kbd *kbd = input_get_drvdata(dev);
137 137
138 if (type != EV_LED) 138 if (type != EV_LED)
139 return -1; 139 return -1;
140 140
141
142 kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) | 141 kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) |
143 (!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) | 142 (!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) |
144 (!!test_bit(LED_NUML, dev->led)); 143 (!!test_bit(LED_NUML, dev->led));
@@ -175,7 +174,7 @@ static void usb_kbd_led(struct urb *urb)
175 174
176static int usb_kbd_open(struct input_dev *dev) 175static int usb_kbd_open(struct input_dev *dev)
177{ 176{
178 struct usb_kbd *kbd = dev->private; 177 struct usb_kbd *kbd = input_get_drvdata(dev);
179 178
180 kbd->irq->dev = kbd->usbdev; 179 kbd->irq->dev = kbd->usbdev;
181 if (usb_submit_urb(kbd->irq, GFP_KERNEL)) 180 if (usb_submit_urb(kbd->irq, GFP_KERNEL))
@@ -186,7 +185,7 @@ static int usb_kbd_open(struct input_dev *dev)
186 185
187static void usb_kbd_close(struct input_dev *dev) 186static void usb_kbd_close(struct input_dev *dev)
188{ 187{
189 struct usb_kbd *kbd = dev->private; 188 struct usb_kbd *kbd = input_get_drvdata(dev);
190 189
191 usb_kill_urb(kbd->irq); 190 usb_kill_urb(kbd->irq);
192} 191}
@@ -211,12 +210,9 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd)
211{ 210{
212 usb_free_urb(kbd->irq); 211 usb_free_urb(kbd->irq);
213 usb_free_urb(kbd->led); 212 usb_free_urb(kbd->led);
214 if (kbd->new) 213 usb_buffer_free(dev, 8, kbd->new, kbd->new_dma);
215 usb_buffer_free(dev, 8, kbd->new, kbd->new_dma); 214 usb_buffer_free(dev, sizeof(struct usb_ctrlrequest), kbd->cr, kbd->cr_dma);
216 if (kbd->cr) 215 usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma);
217 usb_buffer_free(dev, sizeof(struct usb_ctrlrequest), kbd->cr, kbd->cr_dma);
218 if (kbd->leds)
219 usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma);
220} 216}
221 217
222static int usb_kbd_probe(struct usb_interface *iface, 218static int usb_kbd_probe(struct usb_interface *iface,
@@ -274,8 +270,9 @@ static int usb_kbd_probe(struct usb_interface *iface,
274 input_dev->name = kbd->name; 270 input_dev->name = kbd->name;
275 input_dev->phys = kbd->phys; 271 input_dev->phys = kbd->phys;
276 usb_to_input_id(dev, &input_dev->id); 272 usb_to_input_id(dev, &input_dev->id);
277 input_dev->cdev.dev = &iface->dev; 273 input_dev->dev.parent = &iface->dev;
278 input_dev->private = kbd; 274
275 input_set_drvdata(input_dev, kbd);
279 276
280 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); 277 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP);
281 input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); 278 input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA);
diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c
index 573776d865e1..5345c73bcf62 100644
--- a/drivers/hid/usbhid/usbmouse.c
+++ b/drivers/hid/usbhid/usbmouse.c
@@ -96,7 +96,7 @@ resubmit:
96 96
97static int usb_mouse_open(struct input_dev *dev) 97static int usb_mouse_open(struct input_dev *dev)
98{ 98{
99 struct usb_mouse *mouse = dev->private; 99 struct usb_mouse *mouse = input_get_drvdata(dev);
100 100
101 mouse->irq->dev = mouse->usbdev; 101 mouse->irq->dev = mouse->usbdev;
102 if (usb_submit_urb(mouse->irq, GFP_KERNEL)) 102 if (usb_submit_urb(mouse->irq, GFP_KERNEL))
@@ -107,7 +107,7 @@ static int usb_mouse_open(struct input_dev *dev)
107 107
108static void usb_mouse_close(struct input_dev *dev) 108static void usb_mouse_close(struct input_dev *dev)
109{ 109{
110 struct usb_mouse *mouse = dev->private; 110 struct usb_mouse *mouse = input_get_drvdata(dev);
111 111
112 usb_kill_urb(mouse->irq); 112 usb_kill_urb(mouse->irq);
113} 113}
@@ -171,7 +171,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
171 input_dev->name = mouse->name; 171 input_dev->name = mouse->name;
172 input_dev->phys = mouse->phys; 172 input_dev->phys = mouse->phys;
173 usb_to_input_id(dev, &input_dev->id); 173 usb_to_input_id(dev, &input_dev->id);
174 input_dev->cdev.dev = &intf->dev; 174 input_dev->dev.parent = &intf->dev;
175 175
176 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 176 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
177 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 177 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
@@ -179,7 +179,8 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
179 input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); 179 input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA);
180 input_dev->relbit[0] |= BIT(REL_WHEEL); 180 input_dev->relbit[0] |= BIT(REL_WHEEL);
181 181
182 input_dev->private = mouse; 182 input_set_drvdata(input_dev, mouse);
183
183 input_dev->open = usb_mouse_open; 184 input_dev->open = usb_mouse_open;
184 input_dev->close = usb_mouse_close; 185 input_dev->close = usb_mouse_close;
185 186
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 37076b116ed0..827ee748fd4c 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -275,6 +275,7 @@ struct hid_item {
275#define HID_QUIRK_LOGITECH_DESCRIPTOR 0x00100000 275#define HID_QUIRK_LOGITECH_DESCRIPTOR 0x00100000
276#define HID_QUIRK_DUPLICATE_USAGES 0x00200000 276#define HID_QUIRK_DUPLICATE_USAGES 0x00200000
277#define HID_QUIRK_RESET_LEDS 0x00400000 277#define HID_QUIRK_RESET_LEDS 0x00400000
278#define HID_QUIRK_SWAPPED_MIN_MAX 0x00800000
278 279
279/* 280/*
280 * This is the global environment of the parser. This information is 281 * This is the global environment of the parser. This information is
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 0ea40ab4dbae..ceadfcf457c1 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -737,10 +737,8 @@ static inline void hidp_setup_hid(struct hidp_session *session, struct hidp_conn
737 list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list) 737 list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list)
738 hidp_send_report(session, report); 738 hidp_send_report(session, report);
739 739
740 if (hidinput_connect(hid) == 0) { 740 if (hidinput_connect(hid) == 0)
741 hid->claimed |= HID_CLAIMED_INPUT; 741 hid->claimed |= HID_CLAIMED_INPUT;
742 hid_ff_init(hid);
743 }
744} 742}
745 743
746int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock) 744int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock)