aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/Kconfig19
-rw-r--r--drivers/hid/Makefile1
-rw-r--r--drivers/hid/hid-3m-pct.c31
-rw-r--r--drivers/hid/hid-cherry.c1
-rw-r--r--drivers/hid/hid-core.c56
-rw-r--r--drivers/hid/hid-ids.h13
-rw-r--r--drivers/hid/hid-lg.c9
-rw-r--r--drivers/hid/hid-magicmouse.c5
-rw-r--r--drivers/hid/hid-ntrig.c72
-rw-r--r--drivers/hid/hid-samsung.c95
-rw-r--r--drivers/hid/hid-sony.c2
-rw-r--r--drivers/hid/hid-topseed.c38
-rw-r--r--drivers/hid/hid-wacom.c230
-rw-r--r--drivers/hid/hid-zydacron.c237
-rw-r--r--drivers/hid/hidraw.c50
-rw-r--r--drivers/hid/usbhid/hid-core.c61
-rw-r--r--drivers/hid/usbhid/hid-quirks.c1
-rw-r--r--drivers/hid/usbhid/hiddev.c19
-rw-r--r--drivers/hid/usbhid/usbkbd.c1
19 files changed, 768 insertions, 173 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 71d4c0703629..ac8e12d00c0f 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -273,7 +273,7 @@ config HID_SAMSUNG
273 depends on USB_HID 273 depends on USB_HID
274 default !EMBEDDED 274 default !EMBEDDED
275 ---help--- 275 ---help---
276 Support for Samsung InfraRed remote control. 276 Support for Samsung InfraRed remote control or keyboards.
277 277
278config HID_SONY 278config HID_SONY
279 tristate "Sony" if EMBEDDED 279 tristate "Sony" if EMBEDDED
@@ -332,7 +332,7 @@ config HID_TOPSEED
332 depends on USB_HID 332 depends on USB_HID
333 default !EMBEDDED 333 default !EMBEDDED
334 ---help--- 334 ---help---
335 Say Y if you have a TopSeed Cyberlink remote control. 335 Say Y if you have a TopSeed Cyberlink or BTC Emprex remote control.
336 336
337config HID_THRUSTMASTER 337config HID_THRUSTMASTER
338 tristate "ThrustMaster devices support" if EMBEDDED 338 tristate "ThrustMaster devices support" if EMBEDDED
@@ -357,6 +357,14 @@ config HID_WACOM
357 ---help--- 357 ---help---
358 Support for Wacom Graphire Bluetooth tablet. 358 Support for Wacom Graphire Bluetooth tablet.
359 359
360config HID_WACOM_POWER_SUPPLY
361 bool "Wacom Bluetooth devices power supply status support"
362 depends on HID_WACOM
363 select POWER_SUPPLY
364 ---help---
365 Say Y here if you want to enable power supply status monitoring for
366 Wacom Bluetooth devices.
367
360config HID_ZEROPLUS 368config HID_ZEROPLUS
361 tristate "Zeroplus based game controller support" if EMBEDDED 369 tristate "Zeroplus based game controller support" if EMBEDDED
362 depends on USB_HID 370 depends on USB_HID
@@ -372,6 +380,13 @@ config ZEROPLUS_FF
372 Say Y here if you have a Zeroplus based game controller and want 380 Say Y here if you have a Zeroplus based game controller and want
373 to have force feedback support for it. 381 to have force feedback support for it.
374 382
383config HID_ZYDACRON
384 tristate "Zydacron remote control support" if EMBEDDED
385 depends on USB_HID
386 default !EMBEDDED
387 ---help---
388 Support for Zydacron remote control.
389
375endmenu 390endmenu
376 391
377endif # HID_SUPPORT 392endif # HID_SUPPORT
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 0b2618f092ca..d1f1b448977d 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -54,6 +54,7 @@ obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o
54obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o 54obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o
55obj-$(CONFIG_HID_TWINHAN) += hid-twinhan.o 55obj-$(CONFIG_HID_TWINHAN) += hid-twinhan.o
56obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o 56obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o
57obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o
57obj-$(CONFIG_HID_WACOM) += hid-wacom.o 58obj-$(CONFIG_HID_WACOM) += hid-wacom.o
58 59
59obj-$(CONFIG_USB_HID) += usbhid/ 60obj-$(CONFIG_USB_HID) += usbhid/
diff --git a/drivers/hid/hid-3m-pct.c b/drivers/hid/hid-3m-pct.c
index c31e0be8ccea..2a0d56b7a02b 100644
--- a/drivers/hid/hid-3m-pct.c
+++ b/drivers/hid/hid-3m-pct.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * HID driver for 3M PCT multitouch panels 2 * HID driver for 3M PCT multitouch panels
3 * 3 *
4 * Copyright (c) 2009 Stephane Chatty <chatty@enac.fr> 4 * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr>
5 * 5 *
6 */ 6 */
7 7
@@ -25,7 +25,7 @@ MODULE_LICENSE("GPL");
25#include "hid-ids.h" 25#include "hid-ids.h"
26 26
27struct mmm_finger { 27struct mmm_finger {
28 __s32 x, y; 28 __s32 x, y, w, h;
29 __u8 rank; 29 __u8 rank;
30 bool touch, valid; 30 bool touch, valid;
31}; 31};
@@ -82,7 +82,18 @@ static int mmm_input_mapping(struct hid_device *hdev, struct hid_input *hi,
82 /* touchscreen emulation */ 82 /* touchscreen emulation */
83 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); 83 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
84 return 1; 84 return 1;
85 case HID_DG_WIDTH:
86 hid_map_usage(hi, usage, bit, max,
87 EV_ABS, ABS_MT_TOUCH_MAJOR);
88 return 1;
89 case HID_DG_HEIGHT:
90 hid_map_usage(hi, usage, bit, max,
91 EV_ABS, ABS_MT_TOUCH_MINOR);
92 input_set_abs_params(hi->input, ABS_MT_ORIENTATION,
93 1, 1, 0, 0);
94 return 1;
85 case HID_DG_CONTACTID: 95 case HID_DG_CONTACTID:
96 field->logical_maximum = 59;
86 hid_map_usage(hi, usage, bit, max, 97 hid_map_usage(hi, usage, bit, max,
87 EV_ABS, ABS_MT_TRACKING_ID); 98 EV_ABS, ABS_MT_TRACKING_ID);
88 return 1; 99 return 1;
@@ -128,9 +139,15 @@ static void mmm_filter_event(struct mmm_data *md, struct input_dev *input)
128 /* this finger is just placeholder data, ignore */ 139 /* this finger is just placeholder data, ignore */
129 } else if (f->touch) { 140 } else if (f->touch) {
130 /* this finger is on the screen */ 141 /* this finger is on the screen */
142 int wide = (f->w > f->h);
131 input_event(input, EV_ABS, ABS_MT_TRACKING_ID, i); 143 input_event(input, EV_ABS, ABS_MT_TRACKING_ID, i);
132 input_event(input, EV_ABS, ABS_MT_POSITION_X, f->x); 144 input_event(input, EV_ABS, ABS_MT_POSITION_X, f->x);
133 input_event(input, EV_ABS, ABS_MT_POSITION_Y, f->y); 145 input_event(input, EV_ABS, ABS_MT_POSITION_Y, f->y);
146 input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide);
147 input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR,
148 wide ? f->w : f->h);
149 input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR,
150 wide ? f->h : f->w);
134 input_mt_sync(input); 151 input_mt_sync(input);
135 /* 152 /*
136 * touchscreen emulation: maintain the age rank 153 * touchscreen emulation: maintain the age rank
@@ -197,6 +214,14 @@ static int mmm_event(struct hid_device *hid, struct hid_field *field,
197 case HID_DG_CONFIDENCE: 214 case HID_DG_CONFIDENCE:
198 md->valid = value; 215 md->valid = value;
199 break; 216 break;
217 case HID_DG_WIDTH:
218 if (md->valid)
219 md->f[md->curid].w = value;
220 break;
221 case HID_DG_HEIGHT:
222 if (md->valid)
223 md->f[md->curid].h = value;
224 break;
200 case HID_DG_CONTACTID: 225 case HID_DG_CONTACTID:
201 if (md->valid) { 226 if (md->valid) {
202 md->curid = value; 227 md->curid = value;
@@ -255,6 +280,7 @@ static void mmm_remove(struct hid_device *hdev)
255 280
256static const struct hid_device_id mmm_devices[] = { 281static const struct hid_device_id mmm_devices[] = {
257 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, 282 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) },
283 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) },
258 { } 284 { }
259}; 285};
260MODULE_DEVICE_TABLE(hid, mmm_devices); 286MODULE_DEVICE_TABLE(hid, mmm_devices);
@@ -287,5 +313,4 @@ static void __exit mmm_exit(void)
287 313
288module_init(mmm_init); 314module_init(mmm_init);
289module_exit(mmm_exit); 315module_exit(mmm_exit);
290MODULE_LICENSE("GPL");
291 316
diff --git a/drivers/hid/hid-cherry.c b/drivers/hid/hid-cherry.c
index 7e597d7f770f..24663a8717b1 100644
--- a/drivers/hid/hid-cherry.c
+++ b/drivers/hid/hid-cherry.c
@@ -59,6 +59,7 @@ static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
59 59
60static const struct hid_device_id ch_devices[] = { 60static const struct hid_device_id ch_devices[] = {
61 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 61 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
62 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) },
62 { } 63 { }
63}; 64};
64MODULE_DEVICE_TABLE(hid, ch_devices); 65MODULE_DEVICE_TABLE(hid, ch_devices);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 2e2aa759d230..33cac4890ca4 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -653,10 +653,9 @@ int hid_parse_report(struct hid_device *device, __u8 *start,
653 if (device->driver->report_fixup) 653 if (device->driver->report_fixup)
654 device->driver->report_fixup(device, start, size); 654 device->driver->report_fixup(device, start, size);
655 655
656 device->rdesc = kmalloc(size, GFP_KERNEL); 656 device->rdesc = kmemdup(start, size, GFP_KERNEL);
657 if (device->rdesc == NULL) 657 if (device->rdesc == NULL)
658 return -ENOMEM; 658 return -ENOMEM;
659 memcpy(device->rdesc, start, size);
660 device->rsize = size; 659 device->rsize = size;
661 660
662 parser = vmalloc(sizeof(struct hid_parser)); 661 parser = vmalloc(sizeof(struct hid_parser));
@@ -940,13 +939,8 @@ static void hid_output_field(struct hid_field *field, __u8 *data)
940 unsigned count = field->report_count; 939 unsigned count = field->report_count;
941 unsigned offset = field->report_offset; 940 unsigned offset = field->report_offset;
942 unsigned size = field->report_size; 941 unsigned size = field->report_size;
943 unsigned bitsused = offset + count * size;
944 unsigned n; 942 unsigned n;
945 943
946 /* make sure the unused bits in the last byte are zeros */
947 if (count > 0 && size > 0 && (bitsused % 8) != 0)
948 data[(bitsused-1)/8] &= (1 << (bitsused % 8)) - 1;
949
950 for (n = 0; n < count; n++) { 944 for (n = 0; n < count; n++) {
951 if (field->logical_minimum < 0) /* signed values */ 945 if (field->logical_minimum < 0) /* signed values */
952 implement(data, offset + n * size, size, s32ton(field->value[n], size)); 946 implement(data, offset + n * size, size, s32ton(field->value[n], size));
@@ -966,6 +960,7 @@ void hid_output_report(struct hid_report *report, __u8 *data)
966 if (report->id > 0) 960 if (report->id > 0)
967 *data++ = report->id; 961 *data++ = report->id;
968 962
963 memset(data, 0, ((report->size - 1) >> 3) + 1);
969 for (n = 0; n < report->maxfield; n++) 964 for (n = 0; n < report->maxfield; n++)
970 hid_output_field(report->field[n], data); 965 hid_output_field(report->field[n], data);
971} 966}
@@ -1043,13 +1038,8 @@ void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
1043 1038
1044 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) 1039 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
1045 hid->hiddev_report_event(hid, report); 1040 hid->hiddev_report_event(hid, report);
1046 if (hid->claimed & HID_CLAIMED_HIDRAW) { 1041 if (hid->claimed & HID_CLAIMED_HIDRAW)
1047 /* numbered reports need to be passed with the report num */ 1042 hidraw_report_event(hid, data, size);
1048 if (report_enum->numbered)
1049 hidraw_report_event(hid, data - 1, size + 1);
1050 else
1051 hidraw_report_event(hid, data, size);
1052 }
1053 1043
1054 for (a = 0; a < report->maxfield; a++) 1044 for (a = 0; a < report->maxfield; a++)
1055 hid_input_field(hid, report->field[a], cdata, interrupt); 1045 hid_input_field(hid, report->field[a], cdata, interrupt);
@@ -1091,35 +1081,28 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
1091 1081
1092 buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC); 1082 buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
1093 1083
1094 if (!buf) { 1084 if (!buf)
1095 report = hid_get_report(report_enum, data);
1096 goto nomem; 1085 goto nomem;
1097 }
1098
1099 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
1100 "\nreport (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un");
1101 hid_debug_event(hid, buf);
1102
1103 report = hid_get_report(report_enum, data);
1104 if (!report) {
1105 kfree(buf);
1106 return -1;
1107 }
1108 1086
1109 /* dump the report */ 1087 /* dump the report */
1110 snprintf(buf, HID_DEBUG_BUFSIZE - 1, 1088 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
1111 "report %d (size %u) = ", report->id, size); 1089 "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un");
1112 hid_debug_event(hid, buf); 1090 hid_debug_event(hid, buf);
1091
1113 for (i = 0; i < size; i++) { 1092 for (i = 0; i < size; i++) {
1114 snprintf(buf, HID_DEBUG_BUFSIZE - 1, 1093 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
1115 " %02x", data[i]); 1094 " %02x", data[i]);
1116 hid_debug_event(hid, buf); 1095 hid_debug_event(hid, buf);
1117 } 1096 }
1118 hid_debug_event(hid, "\n"); 1097 hid_debug_event(hid, "\n");
1119
1120 kfree(buf); 1098 kfree(buf);
1121 1099
1122nomem: 1100nomem:
1101 report = hid_get_report(report_enum, data);
1102
1103 if (!report)
1104 return -1;
1105
1123 if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { 1106 if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) {
1124 ret = hdrv->raw_event(hid, report, data, size); 1107 ret = hdrv->raw_event(hid, report, data, size);
1125 if (ret != 0) 1108 if (ret != 0)
@@ -1172,6 +1155,8 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
1172 unsigned int i; 1155 unsigned int i;
1173 int len; 1156 int len;
1174 1157
1158 if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE)
1159 connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV);
1175 if (hdev->bus != BUS_USB) 1160 if (hdev->bus != BUS_USB)
1176 connect_mask &= ~HID_CONNECT_HIDDEV; 1161 connect_mask &= ~HID_CONNECT_HIDDEV;
1177 if (hid_hiddev(hdev)) 1162 if (hid_hiddev(hdev))
@@ -1251,6 +1236,7 @@ EXPORT_SYMBOL_GPL(hid_disconnect);
1251/* a list of devices for which there is a specialized driver on HID bus */ 1236/* a list of devices for which there is a specialized driver on HID bus */
1252static const struct hid_device_id hid_blacklist[] = { 1237static const struct hid_device_id hid_blacklist[] = {
1253 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, 1238 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) },
1239 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) },
1254 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 1240 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
1255 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1241 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
1256 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, 1242 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) },
@@ -1295,7 +1281,9 @@ static const struct hid_device_id hid_blacklist[] = {
1295 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1281 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1296 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1282 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1297 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1283 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
1284 { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) },
1298 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 1285 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
1286 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) },
1299 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1287 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
1300 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 1288 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
1301 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, 1289 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) },
@@ -1347,6 +1335,7 @@ static const struct hid_device_id hid_blacklist[] = {
1347 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, 1335 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
1348 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, 1336 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) },
1349 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1337 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
1338 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
1350 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1339 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1351 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1340 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1352 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1341 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
@@ -1363,8 +1352,10 @@ static const struct hid_device_id hid_blacklist[] = {
1363 { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, 1352 { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) },
1364 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, 1353 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) },
1365 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, 1354 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
1355 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) },
1366 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, 1356 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
1367 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, 1357 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
1358 { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
1368 1359
1369 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, 1360 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) },
1370 { } 1361 { }
@@ -1761,7 +1752,7 @@ int hid_add_device(struct hid_device *hdev)
1761 1752
1762 /* we need to kill them here, otherwise they will stay allocated to 1753 /* we need to kill them here, otherwise they will stay allocated to
1763 * wait for coming driver */ 1754 * wait for coming driver */
1764 if (hid_ignore(hdev)) 1755 if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) && hid_ignore(hdev))
1765 return -ENODEV; 1756 return -ENODEV;
1766 1757
1767 /* XXX hack, any other cleaner solution after the driver core 1758 /* XXX hack, any other cleaner solution after the driver core
@@ -1769,11 +1760,12 @@ int hid_add_device(struct hid_device *hdev)
1769 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, 1760 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
1770 hdev->vendor, hdev->product, atomic_inc_return(&id)); 1761 hdev->vendor, hdev->product, atomic_inc_return(&id));
1771 1762
1763 hid_debug_register(hdev, dev_name(&hdev->dev));
1772 ret = device_add(&hdev->dev); 1764 ret = device_add(&hdev->dev);
1773 if (!ret) 1765 if (!ret)
1774 hdev->status |= HID_STAT_ADDED; 1766 hdev->status |= HID_STAT_ADDED;
1775 1767 else
1776 hid_debug_register(hdev, dev_name(&hdev->dev)); 1768 hid_debug_unregister(hdev);
1777 1769
1778 return ret; 1770 return ret;
1779} 1771}
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 797e06470356..d55b81d2d16e 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -20,6 +20,7 @@
20 20
21#define USB_VENDOR_ID_3M 0x0596 21#define USB_VENDOR_ID_3M 0x0596
22#define USB_DEVICE_ID_3M1968 0x0500 22#define USB_DEVICE_ID_3M1968 0x0500
23#define USB_DEVICE_ID_3M2256 0x0502
23 24
24#define USB_VENDOR_ID_A4TECH 0x09da 25#define USB_VENDOR_ID_A4TECH 0x09da
25#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 26#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006
@@ -123,6 +124,9 @@
123#define USB_VENDOR_ID_BERKSHIRE 0x0c98 124#define USB_VENDOR_ID_BERKSHIRE 0x0c98
124#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 125#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140
125 126
127#define USB_VENDOR_ID_BTC 0x046e
128#define USB_DEVICE_ID_BTC_EMPREX_REMOTE 0x5578
129
126#define USB_VENDOR_ID_CH 0x068e 130#define USB_VENDOR_ID_CH 0x068e
127#define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2 131#define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2
128#define USB_DEVICE_ID_CH_COMBATSTICK 0x00f4 132#define USB_DEVICE_ID_CH_COMBATSTICK 0x00f4
@@ -131,6 +135,7 @@
131 135
132#define USB_VENDOR_ID_CHERRY 0x046a 136#define USB_VENDOR_ID_CHERRY 0x046a
133#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 137#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
138#define USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR 0x0027
134 139
135#define USB_VENDOR_ID_CHIC 0x05fe 140#define USB_VENDOR_ID_CHIC 0x05fe
136#define USB_DEVICE_ID_CHIC_GAMEPAD 0x0014 141#define USB_DEVICE_ID_CHIC_GAMEPAD 0x0014
@@ -170,6 +175,9 @@
170 175
171#define USB_VENDOR_ID_DRAGONRISE 0x0079 176#define USB_VENDOR_ID_DRAGONRISE 0x0079
172 177
178#define USB_VENDOR_ID_EGALAX 0x0EEF
179#define USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER 0x0001
180
173#define USB_VENDOR_ID_ELO 0x04E7 181#define USB_VENDOR_ID_ELO 0x04E7
174#define USB_DEVICE_ID_ELO_TS2700 0x0020 182#define USB_DEVICE_ID_ELO_TS2700 0x0020
175 183
@@ -408,6 +416,7 @@
408 416
409#define USB_VENDOR_ID_SAMSUNG 0x0419 417#define USB_VENDOR_ID_SAMSUNG 0x0419
410#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001 418#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001
419#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600
411 420
412#define USB_VENDOR_ID_SONY 0x054c 421#define USB_VENDOR_ID_SONY 0x054c
413#define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b 422#define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b
@@ -456,6 +465,7 @@
456 465
457#define USB_VENDOR_ID_WACOM 0x056a 466#define USB_VENDOR_ID_WACOM 0x056a
458#define USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH 0x81 467#define USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH 0x81
468#define USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH 0xbd
459 469
460#define USB_VENDOR_ID_WISEGROUP 0x0925 470#define USB_VENDOR_ID_WISEGROUP 0x0925
461#define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005 471#define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005
@@ -474,6 +484,9 @@
474 484
475#define USB_VENDOR_ID_ZEROPLUS 0x0c12 485#define USB_VENDOR_ID_ZEROPLUS 0x0c12
476 486
487#define USB_VENDOR_ID_ZYDACRON 0x13EC
488#define USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL 0x0006
489
477#define USB_VENDOR_ID_KYE 0x0458 490#define USB_VENDOR_ID_KYE 0x0458
478#define USB_DEVICE_ID_KYE_ERGO_525V 0x0087 491#define USB_DEVICE_ID_KYE_ERGO_525V 0x0087
479#define USB_DEVICE_ID_KYE_GPEN_560 0x5003 492#define USB_DEVICE_ID_KYE_GPEN_560 0x5003
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index 3677c9037a11..f6433d8050a9 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -126,6 +126,9 @@ static int lg_wireless_mapping(struct hid_input *hi, struct hid_usage *usage,
126 case 0x1004: lg_map_key_clear(KEY_VIDEO); break; 126 case 0x1004: lg_map_key_clear(KEY_VIDEO); break;
127 case 0x1005: lg_map_key_clear(KEY_AUDIO); break; 127 case 0x1005: lg_map_key_clear(KEY_AUDIO); break;
128 case 0x100a: lg_map_key_clear(KEY_DOCUMENTS); break; 128 case 0x100a: lg_map_key_clear(KEY_DOCUMENTS); break;
129 /* The following two entries are Playlist 1 and 2 on the MX3200 */
130 case 0x100f: lg_map_key_clear(KEY_FN_1); break;
131 case 0x1010: lg_map_key_clear(KEY_FN_2); break;
129 case 0x1011: lg_map_key_clear(KEY_PREVIOUSSONG); break; 132 case 0x1011: lg_map_key_clear(KEY_PREVIOUSSONG); break;
130 case 0x1012: lg_map_key_clear(KEY_NEXTSONG); break; 133 case 0x1012: lg_map_key_clear(KEY_NEXTSONG); break;
131 case 0x1013: lg_map_key_clear(KEY_CAMERA); break; 134 case 0x1013: lg_map_key_clear(KEY_CAMERA); break;
@@ -137,6 +140,7 @@ static int lg_wireless_mapping(struct hid_input *hi, struct hid_usage *usage,
137 case 0x1019: lg_map_key_clear(KEY_PROG1); break; 140 case 0x1019: lg_map_key_clear(KEY_PROG1); break;
138 case 0x101a: lg_map_key_clear(KEY_PROG2); break; 141 case 0x101a: lg_map_key_clear(KEY_PROG2); break;
139 case 0x101b: lg_map_key_clear(KEY_PROG3); break; 142 case 0x101b: lg_map_key_clear(KEY_PROG3); break;
143 case 0x101c: lg_map_key_clear(KEY_CYCLEWINDOWS); break;
140 case 0x101f: lg_map_key_clear(KEY_ZOOMIN); break; 144 case 0x101f: lg_map_key_clear(KEY_ZOOMIN); break;
141 case 0x1020: lg_map_key_clear(KEY_ZOOMOUT); break; 145 case 0x1020: lg_map_key_clear(KEY_ZOOMOUT); break;
142 case 0x1021: lg_map_key_clear(KEY_ZOOMRESET); break; 146 case 0x1021: lg_map_key_clear(KEY_ZOOMRESET); break;
@@ -147,6 +151,11 @@ static int lg_wireless_mapping(struct hid_input *hi, struct hid_usage *usage,
147 case 0x1029: lg_map_key_clear(KEY_SHUFFLE); break; 151 case 0x1029: lg_map_key_clear(KEY_SHUFFLE); break;
148 case 0x102a: lg_map_key_clear(KEY_BACK); break; 152 case 0x102a: lg_map_key_clear(KEY_BACK); break;
149 case 0x102b: lg_map_key_clear(KEY_CYCLEWINDOWS); break; 153 case 0x102b: lg_map_key_clear(KEY_CYCLEWINDOWS); break;
154 case 0x102d: lg_map_key_clear(KEY_WWW); break;
155 /* The following two are 'Start/answer call' and 'End/reject call'
156 on the MX3200 */
157 case 0x1031: lg_map_key_clear(KEY_OK); break;
158 case 0x1032: lg_map_key_clear(KEY_CANCEL); break;
150 case 0x1041: lg_map_key_clear(KEY_BATTERY); break; 159 case 0x1041: lg_map_key_clear(KEY_BATTERY); break;
151 case 0x1042: lg_map_key_clear(KEY_WORDPROCESSOR); break; 160 case 0x1042: lg_map_key_clear(KEY_WORDPROCESSOR); break;
152 case 0x1043: lg_map_key_clear(KEY_SPREADSHEET); break; 161 case 0x1043: lg_map_key_clear(KEY_SPREADSHEET); break;
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 0d471fc2ab82..f10d56a15f21 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -354,12 +354,15 @@ static int magicmouse_probe(struct hid_device *hdev,
354 goto err_free; 354 goto err_free;
355 } 355 }
356 356
357 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT); 357 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
358 if (ret) { 358 if (ret) {
359 dev_err(&hdev->dev, "magicmouse hw start failed\n"); 359 dev_err(&hdev->dev, "magicmouse hw start failed\n");
360 goto err_free; 360 goto err_free;
361 } 361 }
362 362
363 /* we are handling the input ourselves */
364 hidinput_disconnect(hdev);
365
363 report = hid_register_report(hdev, HID_INPUT_REPORT, TOUCH_REPORT_ID); 366 report = hid_register_report(hdev, HID_INPUT_REPORT, TOUCH_REPORT_ID);
364 if (!report) { 367 if (!report) {
365 dev_err(&hdev->dev, "unable to register touch report\n"); 368 dev_err(&hdev->dev, "unable to register touch report\n");
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index 9b24fc510712..4777bbfa1cc2 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * HID driver for N-Trig touchscreens 2 * HID driver for N-Trig touchscreens
3 * 3 *
4 * Copyright (c) 2008 Rafi Rubin 4 * Copyright (c) 2008-2010 Rafi Rubin
5 * Copyright (c) 2009 Stephane Chatty 5 * Copyright (c) 2009-2010 Stephane Chatty
6 * 6 *
7 */ 7 */
8 8
@@ -15,6 +15,8 @@
15 15
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/hid.h> 17#include <linux/hid.h>
18#include <linux/usb.h>
19#include "usbhid/usbhid.h"
18#include <linux/module.h> 20#include <linux/module.h>
19#include <linux/slab.h> 21#include <linux/slab.h>
20 22
@@ -22,17 +24,16 @@
22 24
23#define NTRIG_DUPLICATE_USAGES 0x001 25#define NTRIG_DUPLICATE_USAGES 0x001
24 26
25#define nt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
26 EV_KEY, (c))
27
28struct ntrig_data { 27struct ntrig_data {
29 /* Incoming raw values for a single contact */ 28 /* Incoming raw values for a single contact */
30 __u16 x, y, w, h; 29 __u16 x, y, w, h;
31 __u16 id; 30 __u16 id;
32 __u8 confidence; 31
32 bool tipswitch;
33 bool confidence;
34 bool first_contact_touch;
33 35
34 bool reading_mt; 36 bool reading_mt;
35 __u8 first_contact_confidence;
36 37
37 __u8 mt_footer[4]; 38 __u8 mt_footer[4];
38 __u8 mt_foot_count; 39 __u8 mt_foot_count;
@@ -139,9 +140,10 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
139 case 0xff000001: 140 case 0xff000001:
140 /* Tag indicating the start of a multitouch group */ 141 /* Tag indicating the start of a multitouch group */
141 nd->reading_mt = 1; 142 nd->reading_mt = 1;
142 nd->first_contact_confidence = 0; 143 nd->first_contact_touch = 0;
143 break; 144 break;
144 case HID_DG_TIPSWITCH: 145 case HID_DG_TIPSWITCH:
146 nd->tipswitch = value;
145 /* Prevent emission of touch until validated */ 147 /* Prevent emission of touch until validated */
146 return 1; 148 return 1;
147 case HID_DG_CONFIDENCE: 149 case HID_DG_CONFIDENCE:
@@ -169,8 +171,14 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
169 * to emit a normal (X, Y) position 171 * to emit a normal (X, Y) position
170 */ 172 */
171 if (!nd->reading_mt) { 173 if (!nd->reading_mt) {
174 /*
175 * TipSwitch indicates the presence of a
176 * finger in single touch mode.
177 */
178 input_report_key(input, BTN_TOUCH,
179 nd->tipswitch);
172 input_report_key(input, BTN_TOOL_DOUBLETAP, 180 input_report_key(input, BTN_TOOL_DOUBLETAP,
173 (nd->confidence != 0)); 181 nd->tipswitch);
174 input_event(input, EV_ABS, ABS_X, nd->x); 182 input_event(input, EV_ABS, ABS_X, nd->x);
175 input_event(input, EV_ABS, ABS_Y, nd->y); 183 input_event(input, EV_ABS, ABS_Y, nd->y);
176 } 184 }
@@ -209,7 +217,13 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
209 217
210 /* emit a normal (X, Y) for the first point only */ 218 /* emit a normal (X, Y) for the first point only */
211 if (nd->id == 0) { 219 if (nd->id == 0) {
212 nd->first_contact_confidence = nd->confidence; 220 /*
221 * TipSwitch is superfluous in multitouch
222 * mode. The footer events tell us
223 * if there is a finger on the screen or
224 * not.
225 */
226 nd->first_contact_touch = nd->confidence;
213 input_event(input, EV_ABS, ABS_X, nd->x); 227 input_event(input, EV_ABS, ABS_X, nd->x);
214 input_event(input, EV_ABS, ABS_Y, nd->y); 228 input_event(input, EV_ABS, ABS_Y, nd->y);
215 } 229 }
@@ -239,30 +253,11 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
239 253
240 nd->reading_mt = 0; 254 nd->reading_mt = 0;
241 255
242 if (nd->first_contact_confidence) { 256 if (nd->first_contact_touch) {
243 switch (value) { 257 input_report_key(input, BTN_TOOL_DOUBLETAP, 1);
244 case 0: /* for single touch devices */
245 case 1:
246 input_report_key(input,
247 BTN_TOOL_DOUBLETAP, 1);
248 break;
249 case 2:
250 input_report_key(input,
251 BTN_TOOL_TRIPLETAP, 1);
252 break;
253 case 3:
254 default:
255 input_report_key(input,
256 BTN_TOOL_QUADTAP, 1);
257 }
258 input_report_key(input, BTN_TOUCH, 1); 258 input_report_key(input, BTN_TOUCH, 1);
259 } else { 259 } else {
260 input_report_key(input, 260 input_report_key(input, BTN_TOOL_DOUBLETAP, 0);
261 BTN_TOOL_DOUBLETAP, 0);
262 input_report_key(input,
263 BTN_TOOL_TRIPLETAP, 0);
264 input_report_key(input,
265 BTN_TOOL_QUADTAP, 0);
266 input_report_key(input, BTN_TOUCH, 0); 261 input_report_key(input, BTN_TOUCH, 0);
267 } 262 }
268 break; 263 break;
@@ -286,6 +281,7 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
286 struct ntrig_data *nd; 281 struct ntrig_data *nd;
287 struct hid_input *hidinput; 282 struct hid_input *hidinput;
288 struct input_dev *input; 283 struct input_dev *input;
284 struct hid_report *report;
289 285
290 if (id->driver_data) 286 if (id->driver_data)
291 hdev->quirks |= HID_QUIRK_MULTI_INPUT; 287 hdev->quirks |= HID_QUIRK_MULTI_INPUT;
@@ -327,13 +323,7 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
327 __clear_bit(BTN_TOOL_PEN, input->keybit); 323 __clear_bit(BTN_TOOL_PEN, input->keybit);
328 __clear_bit(BTN_TOOL_FINGER, input->keybit); 324 __clear_bit(BTN_TOOL_FINGER, input->keybit);
329 __clear_bit(BTN_0, input->keybit); 325 __clear_bit(BTN_0, input->keybit);
330 /*
331 * A little something special to enable
332 * two and three finger taps.
333 */
334 __set_bit(BTN_TOOL_DOUBLETAP, input->keybit); 326 __set_bit(BTN_TOOL_DOUBLETAP, input->keybit);
335 __set_bit(BTN_TOOL_TRIPLETAP, input->keybit);
336 __set_bit(BTN_TOOL_QUADTAP, input->keybit);
337 /* 327 /*
338 * The physical touchscreen (single touch) 328 * The physical touchscreen (single touch)
339 * input has a value for physical, whereas 329 * input has a value for physical, whereas
@@ -349,6 +339,12 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
349 } 339 }
350 } 340 }
351 341
342 /* This is needed for devices with more recent firmware versions */
343 report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0x0a];
344 if (report)
345 usbhid_submit_report(hdev, report, USB_DIR_OUT);
346
347
352 return 0; 348 return 0;
353err_free: 349err_free:
354 kfree(nd); 350 kfree(nd);
diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c
index 510dd1340597..bda0fd60c98d 100644
--- a/drivers/hid/hid-samsung.c
+++ b/drivers/hid/hid-samsung.c
@@ -7,6 +7,18 @@
7 * Copyright (c) 2006-2007 Jiri Kosina 7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2007 Paul Walmsley 8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby 9 * Copyright (c) 2008 Jiri Slaby
10 * Copyright (c) 2010 Don Prince <dhprince.devel@yahoo.co.uk>
11 *
12 *
13 * This driver supports several HID devices:
14 *
15 * [0419:0001] Samsung IrDA remote controller (reports as Cypress USB Mouse).
16 * various hid report fixups for different variants.
17 *
18 * [0419:0600] Creative Desktop Wireless 6000 keyboard/mouse combo
19 * several key mappings used from the consumer usage page
20 * deviate from the USB HUT 1.12 standard.
21 *
10 */ 22 */
11 23
12/* 24/*
@@ -17,14 +29,13 @@
17 */ 29 */
18 30
19#include <linux/device.h> 31#include <linux/device.h>
32#include <linux/usb.h>
20#include <linux/hid.h> 33#include <linux/hid.h>
21#include <linux/module.h> 34#include <linux/module.h>
22 35
23#include "hid-ids.h" 36#include "hid-ids.h"
24 37
25/* 38/*
26 * Samsung IrDA remote controller (reports as Cypress USB Mouse).
27 *
28 * There are several variants for 0419:0001: 39 * There are several variants for 0419:0001:
29 * 40 *
30 * 1. 184 byte report descriptor 41 * 1. 184 byte report descriptor
@@ -43,21 +54,21 @@
43 * 4. 171 byte report descriptor 54 * 4. 171 byte report descriptor
44 * Report #3 has an array field with logical range 0..1 instead of 1..3. 55 * Report #3 has an array field with logical range 0..1 instead of 1..3.
45 */ 56 */
46static inline void samsung_dev_trace(struct hid_device *hdev, 57static inline void samsung_irda_dev_trace(struct hid_device *hdev,
47 unsigned int rsize) 58 unsigned int rsize)
48{ 59{
49 dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report " 60 dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report "
50 "descriptor\n", rsize); 61 "descriptor\n", rsize);
51} 62}
52 63
53static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc, 64static void samsung_irda_report_fixup(struct hid_device *hdev, __u8 *rdesc,
54 unsigned int rsize) 65 unsigned int rsize)
55{ 66{
56 if (rsize == 184 && rdesc[175] == 0x25 && rdesc[176] == 0x40 && 67 if (rsize == 184 && rdesc[175] == 0x25 && rdesc[176] == 0x40 &&
57 rdesc[177] == 0x75 && rdesc[178] == 0x30 && 68 rdesc[177] == 0x75 && rdesc[178] == 0x30 &&
58 rdesc[179] == 0x95 && rdesc[180] == 0x01 && 69 rdesc[179] == 0x95 && rdesc[180] == 0x01 &&
59 rdesc[182] == 0x40) { 70 rdesc[182] == 0x40) {
60 samsung_dev_trace(hdev, 184); 71 samsung_irda_dev_trace(hdev, 184);
61 rdesc[176] = 0xff; 72 rdesc[176] = 0xff;
62 rdesc[178] = 0x08; 73 rdesc[178] = 0x08;
63 rdesc[180] = 0x06; 74 rdesc[180] = 0x06;
@@ -65,24 +76,80 @@ static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
65 } else 76 } else
66 if (rsize == 203 && rdesc[192] == 0x15 && rdesc[193] == 0x0 && 77 if (rsize == 203 && rdesc[192] == 0x15 && rdesc[193] == 0x0 &&
67 rdesc[194] == 0x25 && rdesc[195] == 0x12) { 78 rdesc[194] == 0x25 && rdesc[195] == 0x12) {
68 samsung_dev_trace(hdev, 203); 79 samsung_irda_dev_trace(hdev, 203);
69 rdesc[193] = 0x1; 80 rdesc[193] = 0x1;
70 rdesc[195] = 0xf; 81 rdesc[195] = 0xf;
71 } else 82 } else
72 if (rsize == 135 && rdesc[124] == 0x15 && rdesc[125] == 0x0 && 83 if (rsize == 135 && rdesc[124] == 0x15 && rdesc[125] == 0x0 &&
73 rdesc[126] == 0x25 && rdesc[127] == 0x11) { 84 rdesc[126] == 0x25 && rdesc[127] == 0x11) {
74 samsung_dev_trace(hdev, 135); 85 samsung_irda_dev_trace(hdev, 135);
75 rdesc[125] = 0x1; 86 rdesc[125] = 0x1;
76 rdesc[127] = 0xe; 87 rdesc[127] = 0xe;
77 } else 88 } else
78 if (rsize == 171 && rdesc[160] == 0x15 && rdesc[161] == 0x0 && 89 if (rsize == 171 && rdesc[160] == 0x15 && rdesc[161] == 0x0 &&
79 rdesc[162] == 0x25 && rdesc[163] == 0x01) { 90 rdesc[162] == 0x25 && rdesc[163] == 0x01) {
80 samsung_dev_trace(hdev, 171); 91 samsung_irda_dev_trace(hdev, 171);
81 rdesc[161] = 0x1; 92 rdesc[161] = 0x1;
82 rdesc[163] = 0x3; 93 rdesc[163] = 0x3;
83 } 94 }
84} 95}
85 96
97#define samsung_kbd_mouse_map_key_clear(c) \
98 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, (c))
99
100static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
101 struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
102 unsigned long **bit, int *max)
103{
104 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
105 unsigned short ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
106
107 if (1 != ifnum || HID_UP_CONSUMER != (usage->hid & HID_USAGE_PAGE))
108 return 0;
109
110 dbg_hid("samsung wireless keyboard/mouse input mapping event [0x%x]\n",
111 usage->hid & HID_USAGE);
112
113 switch (usage->hid & HID_USAGE) {
114 /* report 2 */
115 case 0x183: samsung_kbd_mouse_map_key_clear(KEY_MEDIA); break;
116 case 0x195: samsung_kbd_mouse_map_key_clear(KEY_EMAIL); break;
117 case 0x196: samsung_kbd_mouse_map_key_clear(KEY_CALC); break;
118 case 0x197: samsung_kbd_mouse_map_key_clear(KEY_COMPUTER); break;
119 case 0x22b: samsung_kbd_mouse_map_key_clear(KEY_SEARCH); break;
120 case 0x22c: samsung_kbd_mouse_map_key_clear(KEY_WWW); break;
121 case 0x22d: samsung_kbd_mouse_map_key_clear(KEY_BACK); break;
122 case 0x22e: samsung_kbd_mouse_map_key_clear(KEY_FORWARD); break;
123 case 0x22f: samsung_kbd_mouse_map_key_clear(KEY_FAVORITES); break;
124 case 0x230: samsung_kbd_mouse_map_key_clear(KEY_REFRESH); break;
125 case 0x231: samsung_kbd_mouse_map_key_clear(KEY_STOP); break;
126 default:
127 return 0;
128 }
129
130 return 1;
131}
132
133static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
134 unsigned int rsize)
135{
136 if (USB_DEVICE_ID_SAMSUNG_IR_REMOTE == hdev->product)
137 samsung_irda_report_fixup(hdev, rdesc, rsize);
138}
139
140static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi,
141 struct hid_field *field, struct hid_usage *usage,
142 unsigned long **bit, int *max)
143{
144 int ret = 0;
145
146 if (USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE == hdev->product)
147 ret = samsung_kbd_mouse_input_mapping(hdev,
148 hi, field, usage, bit, max);
149
150 return ret;
151}
152
86static int samsung_probe(struct hid_device *hdev, 153static int samsung_probe(struct hid_device *hdev,
87 const struct hid_device_id *id) 154 const struct hid_device_id *id)
88{ 155{
@@ -95,10 +162,12 @@ static int samsung_probe(struct hid_device *hdev,
95 goto err_free; 162 goto err_free;
96 } 163 }
97 164
98 if (hdev->rsize == 184) { 165 if (USB_DEVICE_ID_SAMSUNG_IR_REMOTE == hdev->product) {
99 /* disable hidinput, force hiddev */ 166 if (hdev->rsize == 184) {
100 cmask = (cmask & ~HID_CONNECT_HIDINPUT) | 167 /* disable hidinput, force hiddev */
101 HID_CONNECT_HIDDEV_FORCE; 168 cmask = (cmask & ~HID_CONNECT_HIDINPUT) |
169 HID_CONNECT_HIDDEV_FORCE;
170 }
102 } 171 }
103 172
104 ret = hid_hw_start(hdev, cmask); 173 ret = hid_hw_start(hdev, cmask);
@@ -114,6 +183,7 @@ err_free:
114 183
115static const struct hid_device_id samsung_devices[] = { 184static const struct hid_device_id samsung_devices[] = {
116 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 185 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
186 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
117 { } 187 { }
118}; 188};
119MODULE_DEVICE_TABLE(hid, samsung_devices); 189MODULE_DEVICE_TABLE(hid, samsung_devices);
@@ -122,6 +192,7 @@ static struct hid_driver samsung_driver = {
122 .name = "samsung", 192 .name = "samsung",
123 .id_table = samsung_devices, 193 .id_table = samsung_devices,
124 .report_fixup = samsung_report_fixup, 194 .report_fixup = samsung_report_fixup,
195 .input_mapping = samsung_input_mapping,
125 .probe = samsung_probe, 196 .probe = samsung_probe,
126}; 197};
127 198
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 7502a4b2fa86..402d5574b574 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -76,7 +76,7 @@ static int sony_set_operational_usb(struct hid_device *hdev)
76 76
77static int sony_set_operational_bt(struct hid_device *hdev) 77static int sony_set_operational_bt(struct hid_device *hdev)
78{ 78{
79 unsigned char buf[] = { 0x53, 0xf4, 0x42, 0x03, 0x00, 0x00 }; 79 unsigned char buf[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 };
80 return hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT); 80 return hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
81} 81}
82 82
diff --git a/drivers/hid/hid-topseed.c b/drivers/hid/hid-topseed.c
index 6925eda1081a..2eebdcc57bcf 100644
--- a/drivers/hid/hid-topseed.c
+++ b/drivers/hid/hid-topseed.c
@@ -3,6 +3,9 @@
3 * 3 *
4 * Copyright (c) 2008 Lev Babiev 4 * Copyright (c) 2008 Lev Babiev
5 * based on hid-cherry driver 5 * based on hid-cherry driver
6 *
7 * Modified to also support BTC "Emprex 3009URF III Vista MCE Remote" by
8 * Wayne Thomas 2010.
6 */ 9 */
7 10
8/* 11/*
@@ -24,23 +27,29 @@ static int ts_input_mapping(struct hid_device *hdev, struct hid_input *hi,
24 struct hid_field *field, struct hid_usage *usage, 27 struct hid_field *field, struct hid_usage *usage,
25 unsigned long **bit, int *max) 28 unsigned long **bit, int *max)
26{ 29{
27 if ((usage->hid & HID_USAGE_PAGE) != 0x0ffbc0000) 30 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR)
28 return 0; 31 return 0;
29 32
30 switch (usage->hid & HID_USAGE) { 33 switch (usage->hid & HID_USAGE) {
31 case 0x00d: ts_map_key_clear(KEY_HOME); break; 34 case 0x00d: ts_map_key_clear(KEY_MEDIA); break;
32 case 0x024: ts_map_key_clear(KEY_MENU); break; 35 case 0x024: ts_map_key_clear(KEY_MENU); break;
33 case 0x025: ts_map_key_clear(KEY_TV); break; 36 case 0x025: ts_map_key_clear(KEY_TV); break;
34 case 0x048: ts_map_key_clear(KEY_RED); break; 37 case 0x031: ts_map_key_clear(KEY_AUDIO); break;
35 case 0x047: ts_map_key_clear(KEY_GREEN); break; 38 case 0x032: ts_map_key_clear(KEY_TEXT); break;
36 case 0x049: ts_map_key_clear(KEY_YELLOW); break; 39 case 0x033: ts_map_key_clear(KEY_CHANNEL); break;
37 case 0x04a: ts_map_key_clear(KEY_BLUE); break; 40 case 0x047: ts_map_key_clear(KEY_MP3); break;
38 case 0x04b: ts_map_key_clear(KEY_ANGLE); break; 41 case 0x048: ts_map_key_clear(KEY_TV2); break;
39 case 0x04c: ts_map_key_clear(KEY_LANGUAGE); break; 42 case 0x049: ts_map_key_clear(KEY_CAMERA); break;
40 case 0x04d: ts_map_key_clear(KEY_SUBTITLE); break; 43 case 0x04a: ts_map_key_clear(KEY_VIDEO); break;
41 case 0x031: ts_map_key_clear(KEY_AUDIO); break; 44 case 0x04b: ts_map_key_clear(KEY_ANGLE); break;
42 case 0x032: ts_map_key_clear(KEY_TEXT); break; 45 case 0x04c: ts_map_key_clear(KEY_LANGUAGE); break;
43 case 0x033: ts_map_key_clear(KEY_CHANNEL); break; 46 case 0x04d: ts_map_key_clear(KEY_SUBTITLE); break;
47 case 0x050: ts_map_key_clear(KEY_RADIO); break;
48 case 0x05a: ts_map_key_clear(KEY_TEXT); break;
49 case 0x05b: ts_map_key_clear(KEY_RED); break;
50 case 0x05c: ts_map_key_clear(KEY_GREEN); break;
51 case 0x05d: ts_map_key_clear(KEY_YELLOW); break;
52 case 0x05e: ts_map_key_clear(KEY_BLUE); break;
44 default: 53 default:
45 return 0; 54 return 0;
46 } 55 }
@@ -50,6 +59,7 @@ static int ts_input_mapping(struct hid_device *hdev, struct hid_input *hi,
50 59
51static const struct hid_device_id ts_devices[] = { 60static const struct hid_device_id ts_devices[] = {
52 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, 61 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
62 { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) },
53 { } 63 { }
54}; 64};
55MODULE_DEVICE_TABLE(hid, ts_devices); 65MODULE_DEVICE_TABLE(hid, ts_devices);
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index f7700cf49721..1e051f1171e4 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -22,14 +22,159 @@
22#include <linux/hid.h> 22#include <linux/hid.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
26#include <linux/power_supply.h>
27#endif
25 28
26#include "hid-ids.h" 29#include "hid-ids.h"
27 30
28struct wacom_data { 31struct wacom_data {
29 __u16 tool; 32 __u16 tool;
30 unsigned char butstate; 33 unsigned char butstate;
34 unsigned char high_speed;
35#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
36 int battery_capacity;
37 struct power_supply battery;
38 struct power_supply ac;
39#endif
31}; 40};
32 41
42#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
43/*percent of battery capacity, 0 means AC online*/
44static unsigned short batcap[8] = { 1, 15, 25, 35, 50, 70, 100, 0 };
45
46static enum power_supply_property wacom_battery_props[] = {
47 POWER_SUPPLY_PROP_PRESENT,
48 POWER_SUPPLY_PROP_CAPACITY
49};
50
51static enum power_supply_property wacom_ac_props[] = {
52 POWER_SUPPLY_PROP_PRESENT,
53 POWER_SUPPLY_PROP_ONLINE
54};
55
56static int wacom_battery_get_property(struct power_supply *psy,
57 enum power_supply_property psp,
58 union power_supply_propval *val)
59{
60 struct wacom_data *wdata = container_of(psy,
61 struct wacom_data, battery);
62 int power_state = batcap[wdata->battery_capacity];
63 int ret = 0;
64
65 switch (psp) {
66 case POWER_SUPPLY_PROP_PRESENT:
67 val->intval = 1;
68 break;
69 case POWER_SUPPLY_PROP_CAPACITY:
70 /* show 100% battery capacity when charging */
71 if (power_state == 0)
72 val->intval = 100;
73 else
74 val->intval = power_state;
75 break;
76 default:
77 ret = -EINVAL;
78 break;
79 }
80 return ret;
81}
82
83static int wacom_ac_get_property(struct power_supply *psy,
84 enum power_supply_property psp,
85 union power_supply_propval *val)
86{
87 struct wacom_data *wdata = container_of(psy, struct wacom_data, ac);
88 int power_state = batcap[wdata->battery_capacity];
89 int ret = 0;
90
91 switch (psp) {
92 case POWER_SUPPLY_PROP_PRESENT:
93 /* fall through */
94 case POWER_SUPPLY_PROP_ONLINE:
95 if (power_state == 0)
96 val->intval = 1;
97 else
98 val->intval = 0;
99 break;
100 default:
101 ret = -EINVAL;
102 break;
103 }
104 return ret;
105}
106#endif
107
108static void wacom_poke(struct hid_device *hdev, u8 speed)
109{
110 struct wacom_data *wdata = hid_get_drvdata(hdev);
111 int limit, ret;
112 char rep_data[2];
113
114 rep_data[0] = 0x03 ; rep_data[1] = 0x00;
115 limit = 3;
116 do {
117 ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
118 HID_FEATURE_REPORT);
119 } while (ret < 0 && limit-- > 0);
120
121 if (ret >= 0) {
122 if (speed == 0)
123 rep_data[0] = 0x05;
124 else
125 rep_data[0] = 0x06;
126
127 rep_data[1] = 0x00;
128 limit = 3;
129 do {
130 ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
131 HID_FEATURE_REPORT);
132 } while (ret < 0 && limit-- > 0);
133
134 if (ret >= 0) {
135 wdata->high_speed = speed;
136 return;
137 }
138 }
139
140 /*
141 * Note that if the raw queries fail, it's not a hard failure and it
142 * is safe to continue
143 */
144 dev_warn(&hdev->dev, "failed to poke device, command %d, err %d\n",
145 rep_data[0], ret);
146 return;
147}
148
149static ssize_t wacom_show_speed(struct device *dev,
150 struct device_attribute
151 *attr, char *buf)
152{
153 struct wacom_data *wdata = dev_get_drvdata(dev);
154
155 return snprintf(buf, PAGE_SIZE, "%i\n", wdata->high_speed);
156}
157
158static ssize_t wacom_store_speed(struct device *dev,
159 struct device_attribute *attr,
160 const char *buf, size_t count)
161{
162 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
163 int new_speed;
164
165 if (sscanf(buf, "%1d", &new_speed ) != 1)
166 return -EINVAL;
167
168 if (new_speed == 0 || new_speed == 1) {
169 wacom_poke(hdev, new_speed);
170 return strnlen(buf, PAGE_SIZE);
171 } else
172 return -EINVAL;
173}
174
175static DEVICE_ATTR(speed, S_IRUGO | S_IWUGO,
176 wacom_show_speed, wacom_store_speed);
177
33static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, 178static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
34 u8 *raw_data, int size) 179 u8 *raw_data, int size)
35{ 180{
@@ -148,6 +293,12 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
148 input_sync(input); 293 input_sync(input);
149 } 294 }
150 295
296#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
297 /* Store current battery capacity */
298 rw = (data[7] >> 2 & 0x07);
299 if (rw != wdata->battery_capacity)
300 wdata->battery_capacity = rw;
301#endif
151 return 1; 302 return 1;
152} 303}
153 304
@@ -157,9 +308,7 @@ static int wacom_probe(struct hid_device *hdev,
157 struct hid_input *hidinput; 308 struct hid_input *hidinput;
158 struct input_dev *input; 309 struct input_dev *input;
159 struct wacom_data *wdata; 310 struct wacom_data *wdata;
160 char rep_data[2];
161 int ret; 311 int ret;
162 int limit;
163 312
164 wdata = kzalloc(sizeof(*wdata), GFP_KERNEL); 313 wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);
165 if (wdata == NULL) { 314 if (wdata == NULL) {
@@ -182,31 +331,53 @@ static int wacom_probe(struct hid_device *hdev,
182 goto err_free; 331 goto err_free;
183 } 332 }
184 333
185 /* 334 ret = device_create_file(&hdev->dev, &dev_attr_speed);
186 * Note that if the raw queries fail, it's not a hard failure and it 335 if (ret)
187 * is safe to continue 336 dev_warn(&hdev->dev,
188 */ 337 "can't create sysfs speed attribute err: %d\n", ret);
189 338
190 /* Set Wacom mode2 */ 339 /* Set Wacom mode 2 with high reporting speed */
191 rep_data[0] = 0x03; rep_data[1] = 0x00; 340 wacom_poke(hdev, 1);
192 limit = 3;
193 do {
194 ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
195 HID_FEATURE_REPORT);
196 } while (ret < 0 && limit-- > 0);
197 if (ret < 0)
198 dev_warn(&hdev->dev, "failed to poke device #1, %d\n", ret);
199 341
200 /* 0x06 - high reporting speed, 0x05 - low speed */ 342#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
201 rep_data[0] = 0x06; rep_data[1] = 0x00; 343 wdata->battery.properties = wacom_battery_props;
202 limit = 3; 344 wdata->battery.num_properties = ARRAY_SIZE(wacom_battery_props);
203 do { 345 wdata->battery.get_property = wacom_battery_get_property;
204 ret = hdev->hid_output_raw_report(hdev, rep_data, 2, 346 wdata->battery.name = "wacom_battery";
205 HID_FEATURE_REPORT); 347 wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY;
206 } while (ret < 0 && limit-- > 0); 348 wdata->battery.use_for_apm = 0;
207 if (ret < 0)
208 dev_warn(&hdev->dev, "failed to poke device #2, %d\n", ret);
209 349
350 ret = power_supply_register(&hdev->dev, &wdata->battery);
351 if (ret) {
352 dev_warn(&hdev->dev,
353 "can't create sysfs battery attribute, err: %d\n", ret);
354 /*
355 * battery attribute is not critical for the tablet, but if it
356 * failed then there is no need to create ac attribute
357 */
358 goto move_on;
359 }
360
361 wdata->ac.properties = wacom_ac_props;
362 wdata->ac.num_properties = ARRAY_SIZE(wacom_ac_props);
363 wdata->ac.get_property = wacom_ac_get_property;
364 wdata->ac.name = "wacom_ac";
365 wdata->ac.type = POWER_SUPPLY_TYPE_MAINS;
366 wdata->ac.use_for_apm = 0;
367
368 ret = power_supply_register(&hdev->dev, &wdata->ac);
369 if (ret) {
370 dev_warn(&hdev->dev,
371 "can't create ac battery attribute, err: %d\n", ret);
372 /*
373 * ac attribute is not critical for the tablet, but if it
374 * failed then we don't want to battery attribute to exist
375 */
376 power_supply_unregister(&wdata->battery);
377 }
378
379move_on:
380#endif
210 hidinput = list_entry(hdev->inputs.next, struct hid_input, list); 381 hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
211 input = hidinput->input; 382 input = hidinput->input;
212 383
@@ -251,13 +422,21 @@ err_free:
251 422
252static void wacom_remove(struct hid_device *hdev) 423static void wacom_remove(struct hid_device *hdev)
253{ 424{
425#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
426 struct wacom_data *wdata = hid_get_drvdata(hdev);
427#endif
254 hid_hw_stop(hdev); 428 hid_hw_stop(hdev);
429
430#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
431 power_supply_unregister(&wdata->battery);
432 power_supply_unregister(&wdata->ac);
433#endif
255 kfree(hid_get_drvdata(hdev)); 434 kfree(hid_get_drvdata(hdev));
256} 435}
257 436
258static const struct hid_device_id wacom_devices[] = { 437static const struct hid_device_id wacom_devices[] = {
259 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, 438 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
260 439 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) },
261 { } 440 { }
262}; 441};
263MODULE_DEVICE_TABLE(hid, wacom_devices); 442MODULE_DEVICE_TABLE(hid, wacom_devices);
@@ -277,7 +456,6 @@ static int __init wacom_init(void)
277 ret = hid_register_driver(&wacom_driver); 456 ret = hid_register_driver(&wacom_driver);
278 if (ret) 457 if (ret)
279 printk(KERN_ERR "can't register wacom driver\n"); 458 printk(KERN_ERR "can't register wacom driver\n");
280 printk(KERN_ERR "wacom driver registered\n");
281 return ret; 459 return ret;
282} 460}
283 461
diff --git a/drivers/hid/hid-zydacron.c b/drivers/hid/hid-zydacron.c
new file mode 100644
index 000000000000..9e8d35a203e4
--- /dev/null
+++ b/drivers/hid/hid-zydacron.c
@@ -0,0 +1,237 @@
1/*
2* HID driver for zydacron remote control
3*
4* Copyright (c) 2010 Don Prince <dhprince.devel@yahoo.co.uk>
5*/
6
7/*
8* This program is free software; you can redistribute it and/or modify it
9* under the terms of the GNU General Public License as published by the Free
10* Software Foundation; either version 2 of the License, or (at your option)
11* any later version.
12*/
13
14#include <linux/device.h>
15#include <linux/hid.h>
16#include <linux/module.h>
17
18#include "hid-ids.h"
19
20struct zc_device {
21 struct input_dev *input_ep81;
22 unsigned short last_key[4];
23};
24
25
26/*
27* Zydacron remote control has an invalid HID report descriptor,
28* that needs fixing before we can parse it.
29*/
30static void zc_report_fixup(struct hid_device *hdev, __u8 *rdesc,
31 unsigned int rsize)
32{
33 if (rsize >= 253 &&
34 rdesc[0x96] == 0xbc && rdesc[0x97] == 0xff &&
35 rdesc[0xca] == 0xbc && rdesc[0xcb] == 0xff &&
36 rdesc[0xe1] == 0xbc && rdesc[0xe2] == 0xff) {
37 dev_info(&hdev->dev,
38 "fixing up zydacron remote control report "
39 "descriptor\n");
40 rdesc[0x96] = rdesc[0xca] = rdesc[0xe1] = 0x0c;
41 rdesc[0x97] = rdesc[0xcb] = rdesc[0xe2] = 0x00;
42 }
43}
44
45#define zc_map_key_clear(c) \
46 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, (c))
47
48static int zc_input_mapping(struct hid_device *hdev, struct hid_input *hi,
49 struct hid_field *field, struct hid_usage *usage,
50 unsigned long **bit, int *max)
51{
52 int i;
53 struct zc_device *zc = hid_get_drvdata(hdev);
54 zc->input_ep81 = hi->input;
55
56 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
57 return 0;
58
59 dbg_hid("zynacron input mapping event [0x%x]\n",
60 usage->hid & HID_USAGE);
61
62 switch (usage->hid & HID_USAGE) {
63 /* report 2 */
64 case 0x10:
65 zc_map_key_clear(KEY_MODE);
66 break;
67 case 0x30:
68 zc_map_key_clear(KEY_SCREEN);
69 break;
70 case 0x70:
71 zc_map_key_clear(KEY_INFO);
72 break;
73 /* report 3 */
74 case 0x04:
75 zc_map_key_clear(KEY_RADIO);
76 break;
77 /* report 4 */
78 case 0x0d:
79 zc_map_key_clear(KEY_PVR);
80 break;
81 case 0x25:
82 zc_map_key_clear(KEY_TV);
83 break;
84 case 0x47:
85 zc_map_key_clear(KEY_AUDIO);
86 break;
87 case 0x49:
88 zc_map_key_clear(KEY_AUX);
89 break;
90 case 0x4a:
91 zc_map_key_clear(KEY_VIDEO);
92 break;
93 case 0x48:
94 zc_map_key_clear(KEY_DVD);
95 break;
96 case 0x24:
97 zc_map_key_clear(KEY_MENU);
98 break;
99 case 0x32:
100 zc_map_key_clear(KEY_TEXT);
101 break;
102 default:
103 return 0;
104 }
105
106 for (i = 0; i < 4; i++)
107 zc->last_key[i] = 0;
108
109 return 1;
110}
111
112static int zc_raw_event(struct hid_device *hdev, struct hid_report *report,
113 u8 *data, int size)
114{
115 struct zc_device *zc = hid_get_drvdata(hdev);
116 int ret = 0;
117 unsigned key;
118 unsigned short index;
119
120 if (report->id == data[0]) {
121
122 /* break keys */
123 for (index = 0; index < 4; index++) {
124 key = zc->last_key[index];
125 if (key) {
126 input_event(zc->input_ep81, EV_KEY, key, 0);
127 zc->last_key[index] = 0;
128 }
129 }
130
131 key = 0;
132 switch (report->id) {
133 case 0x02:
134 case 0x03:
135 switch (data[1]) {
136 case 0x10:
137 key = KEY_MODE;
138 index = 0;
139 break;
140 case 0x30:
141 key = KEY_SCREEN;
142 index = 1;
143 break;
144 case 0x70:
145 key = KEY_INFO;
146 index = 2;
147 break;
148 case 0x04:
149 key = KEY_RADIO;
150 index = 3;
151 break;
152 }
153
154 if (key) {
155 input_event(zc->input_ep81, EV_KEY, key, 1);
156 zc->last_key[index] = key;
157 }
158
159 ret = 1;
160 break;
161 }
162 }
163
164 return ret;
165}
166
167static int zc_probe(struct hid_device *hdev, const struct hid_device_id *id)
168{
169 int ret;
170 struct zc_device *zc;
171
172 zc = kzalloc(sizeof(*zc), GFP_KERNEL);
173 if (zc == NULL) {
174 dev_err(&hdev->dev, "zydacron: can't alloc descriptor\n");
175 return -ENOMEM;
176 }
177
178 hid_set_drvdata(hdev, zc);
179
180 ret = hid_parse(hdev);
181 if (ret) {
182 dev_err(&hdev->dev, "zydacron: parse failed\n");
183 goto err_free;
184 }
185
186 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
187 if (ret) {
188 dev_err(&hdev->dev, "zydacron: hw start failed\n");
189 goto err_free;
190 }
191
192 return 0;
193err_free:
194 kfree(zc);
195
196 return ret;
197}
198
199static void zc_remove(struct hid_device *hdev)
200{
201 struct zc_device *zc = hid_get_drvdata(hdev);
202
203 hid_hw_stop(hdev);
204
205 if (NULL != zc)
206 kfree(zc);
207}
208
209static const struct hid_device_id zc_devices[] = {
210 { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
211 { }
212};
213MODULE_DEVICE_TABLE(hid, zc_devices);
214
215static struct hid_driver zc_driver = {
216 .name = "zydacron",
217 .id_table = zc_devices,
218 .report_fixup = zc_report_fixup,
219 .input_mapping = zc_input_mapping,
220 .raw_event = zc_raw_event,
221 .probe = zc_probe,
222 .remove = zc_remove,
223};
224
225static int __init zc_init(void)
226{
227 return hid_register_driver(&zc_driver);
228}
229
230static void __exit zc_exit(void)
231{
232 hid_unregister_driver(&zc_driver);
233}
234
235module_init(zc_init);
236module_exit(zc_exit);
237MODULE_LICENSE("GPL");
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 6eadf1a9b3cc..3ccd47850677 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -106,38 +106,48 @@ out:
106static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) 106static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
107{ 107{
108 unsigned int minor = iminor(file->f_path.dentry->d_inode); 108 unsigned int minor = iminor(file->f_path.dentry->d_inode);
109 /* FIXME: What stops hidraw_table going NULL */ 109 struct hid_device *dev;
110 struct hid_device *dev = hidraw_table[minor]->hid;
111 __u8 *buf; 110 __u8 *buf;
112 int ret = 0; 111 int ret = 0;
113 112
114 if (!dev->hid_output_raw_report) 113 mutex_lock(&minors_lock);
115 return -ENODEV; 114 dev = hidraw_table[minor]->hid;
115
116 if (!dev->hid_output_raw_report) {
117 ret = -ENODEV;
118 goto out;
119 }
116 120
117 if (count > HID_MAX_BUFFER_SIZE) { 121 if (count > HID_MAX_BUFFER_SIZE) {
118 printk(KERN_WARNING "hidraw: pid %d passed too large report\n", 122 printk(KERN_WARNING "hidraw: pid %d passed too large report\n",
119 task_pid_nr(current)); 123 task_pid_nr(current));
120 return -EINVAL; 124 ret = -EINVAL;
125 goto out;
121 } 126 }
122 127
123 if (count < 2) { 128 if (count < 2) {
124 printk(KERN_WARNING "hidraw: pid %d passed too short report\n", 129 printk(KERN_WARNING "hidraw: pid %d passed too short report\n",
125 task_pid_nr(current)); 130 task_pid_nr(current));
126 return -EINVAL; 131 ret = -EINVAL;
132 goto out;
127 } 133 }
128 134
129 buf = kmalloc(count * sizeof(__u8), GFP_KERNEL); 135 buf = kmalloc(count * sizeof(__u8), GFP_KERNEL);
130 if (!buf) 136 if (!buf) {
131 return -ENOMEM; 137 ret = -ENOMEM;
138 goto out;
139 }
132 140
133 if (copy_from_user(buf, buffer, count)) { 141 if (copy_from_user(buf, buffer, count)) {
134 ret = -EFAULT; 142 ret = -EFAULT;
135 goto out; 143 goto out_free;
136 } 144 }
137 145
138 ret = dev->hid_output_raw_report(dev, buf, count, HID_OUTPUT_REPORT); 146 ret = dev->hid_output_raw_report(dev, buf, count, HID_OUTPUT_REPORT);
139out: 147out_free:
140 kfree(buf); 148 kfree(buf);
149out:
150 mutex_unlock(&minors_lock);
141 return ret; 151 return ret;
142} 152}
143 153
@@ -165,11 +175,8 @@ static int hidraw_open(struct inode *inode, struct file *file)
165 goto out; 175 goto out;
166 } 176 }
167 177
168 lock_kernel();
169 mutex_lock(&minors_lock); 178 mutex_lock(&minors_lock);
170 if (!hidraw_table[minor]) { 179 if (!hidraw_table[minor]) {
171 printk(KERN_EMERG "hidraw device with minor %d doesn't exist\n",
172 minor);
173 kfree(list); 180 kfree(list);
174 err = -ENODEV; 181 err = -ENODEV;
175 goto out_unlock; 182 goto out_unlock;
@@ -197,7 +204,6 @@ static int hidraw_open(struct inode *inode, struct file *file)
197 204
198out_unlock: 205out_unlock:
199 mutex_unlock(&minors_lock); 206 mutex_unlock(&minors_lock);
200 unlock_kernel();
201out: 207out:
202 return err; 208 return err;
203 209
@@ -209,11 +215,8 @@ static int hidraw_release(struct inode * inode, struct file * file)
209 struct hidraw *dev; 215 struct hidraw *dev;
210 struct hidraw_list *list = file->private_data; 216 struct hidraw_list *list = file->private_data;
211 217
212 if (!hidraw_table[minor]) { 218 if (!hidraw_table[minor])
213 printk(KERN_EMERG "hidraw device with minor %d doesn't exist\n",
214 minor);
215 return -ENODEV; 219 return -ENODEV;
216 }
217 220
218 list_del(&list->node); 221 list_del(&list->node);
219 dev = hidraw_table[minor]; 222 dev = hidraw_table[minor];
@@ -238,11 +241,12 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
238 struct inode *inode = file->f_path.dentry->d_inode; 241 struct inode *inode = file->f_path.dentry->d_inode;
239 unsigned int minor = iminor(inode); 242 unsigned int minor = iminor(inode);
240 long ret = 0; 243 long ret = 0;
241 /* FIXME: What stops hidraw_table going NULL */ 244 struct hidraw *dev;
242 struct hidraw *dev = hidraw_table[minor];
243 void __user *user_arg = (void __user*) arg; 245 void __user *user_arg = (void __user*) arg;
244 246
245 lock_kernel(); 247 mutex_lock(&minors_lock);
248 dev = hidraw_table[minor];
249
246 switch (cmd) { 250 switch (cmd) {
247 case HIDIOCGRDESCSIZE: 251 case HIDIOCGRDESCSIZE:
248 if (put_user(dev->hid->rsize, (int __user *)arg)) 252 if (put_user(dev->hid->rsize, (int __user *)arg))
@@ -311,11 +315,11 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
311 -EFAULT : len; 315 -EFAULT : len;
312 break; 316 break;
313 } 317 }
314 } 318 }
315 319
316 ret = -ENOTTY; 320 ret = -ENOTTY;
317 } 321 }
318 unlock_kernel(); 322 mutex_unlock(&minors_lock);
319 return ret; 323 return ret;
320} 324}
321 325
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 14a67fba590e..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
1037fail: 1053fail:
@@ -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)
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 1152f9b5fd44..7a6bda23283e 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_EGALAX, USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER, 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
318fail2: 319fail2: