diff options
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-apple.c | 11 | ||||
-rw-r--r-- | drivers/hid/hid-core.c | 12 | ||||
-rw-r--r-- | drivers/hid/hid-dell.c | 1 | ||||
-rw-r--r-- | drivers/hid/hid-ids.h | 9 | ||||
-rw-r--r-- | drivers/hid/hidraw.c | 30 | ||||
-rw-r--r-- | drivers/hid/usbhid/hid-core.c | 83 | ||||
-rw-r--r-- | drivers/hid/usbhid/hiddev.c | 2 | ||||
-rw-r--r-- | drivers/hid/usbhid/usbhid.h | 2 |
8 files changed, 107 insertions, 43 deletions
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index c6ab4ba60c52..9b97795e45ad 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c | |||
@@ -55,10 +55,11 @@ struct apple_key_translation { | |||
55 | 55 | ||
56 | static struct apple_key_translation apple_fn_keys[] = { | 56 | static struct apple_key_translation apple_fn_keys[] = { |
57 | { KEY_BACKSPACE, KEY_DELETE }, | 57 | { KEY_BACKSPACE, KEY_DELETE }, |
58 | { KEY_ENTER, KEY_INSERT }, | ||
58 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, | 59 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, |
59 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, | 60 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, |
60 | { KEY_F3, KEY_FN_F5, APPLE_FLAG_FKEY }, /* Exposé */ | 61 | { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY }, |
61 | { KEY_F4, KEY_FN_F4, APPLE_FLAG_FKEY }, /* Dashboard */ | 62 | { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY }, |
62 | { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, | 63 | { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, |
63 | { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, | 64 | { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, |
64 | { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, | 65 | { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, |
@@ -418,6 +419,12 @@ static const struct hid_device_id apple_devices[] = { | |||
418 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, | 419 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
419 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), | 420 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), |
420 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | 421 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
422 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), | ||
423 | .driver_data = APPLE_HAS_FN }, | ||
424 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), | ||
425 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, | ||
426 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), | ||
427 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | ||
421 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY), | 428 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY), |
422 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | 429 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
423 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), | 430 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 743e6f8cb202..147ec591a806 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1250,9 +1250,11 @@ static const struct hid_device_id hid_blacklist[] = { | |||
1250 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, | 1250 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, |
1251 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, | 1251 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, |
1252 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, | 1252 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, |
1253 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, | ||
1254 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, | ||
1255 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, | ||
1253 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, | 1256 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
1254 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, | 1257 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
1255 | { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, | ||
1256 | { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, | 1258 | { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, |
1257 | { HID_USB_DEVICE(USB_VENDOR_ID_BRIGHT, USB_DEVICE_ID_BRIGHT_ABNT2) }, | 1259 | { HID_USB_DEVICE(USB_VENDOR_ID_BRIGHT, USB_DEVICE_ID_BRIGHT_ABNT2) }, |
1258 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, | 1260 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, |
@@ -1263,6 +1265,7 @@ static const struct hid_device_id hid_blacklist[] = { | |||
1263 | { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658) }, | 1265 | { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658) }, |
1264 | { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_SK8115) }, | 1266 | { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_SK8115) }, |
1265 | { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, | 1267 | { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, |
1268 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) }, | ||
1266 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, | 1269 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, |
1267 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, | 1270 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, |
1268 | { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, | 1271 | { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, |
@@ -1407,6 +1410,7 @@ static const struct hid_device_id hid_ignore_list[] = { | |||
1407 | { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, | 1410 | { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, |
1408 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)}, | 1411 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)}, |
1409 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2)}, | 1412 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2)}, |
1413 | { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, | ||
1410 | { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, | 1414 | { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, |
1411 | { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, | 1415 | { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, |
1412 | { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, | 1416 | { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, |
@@ -1484,6 +1488,7 @@ static const struct hid_device_id hid_ignore_list[] = { | |||
1484 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, | 1488 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, |
1485 | { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, | 1489 | { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, |
1486 | { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, | 1490 | { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, |
1491 | { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, | ||
1487 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, | 1492 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, |
1488 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, | 1493 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, |
1489 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, | 1494 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, |
@@ -1571,6 +1576,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = { | |||
1571 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, | 1576 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, |
1572 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, | 1577 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, |
1573 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, | 1578 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, |
1579 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, | ||
1580 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, | ||
1581 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, | ||
1574 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, | 1582 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
1575 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, | 1583 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
1576 | { } | 1584 | { } |
@@ -1728,7 +1736,7 @@ static int __init hid_init(void) | |||
1728 | goto err_bus; | 1736 | goto err_bus; |
1729 | 1737 | ||
1730 | #ifdef CONFIG_HID_COMPAT | 1738 | #ifdef CONFIG_HID_COMPAT |
1731 | hid_compat_wq = create_workqueue("hid_compat"); | 1739 | hid_compat_wq = create_singlethread_workqueue("hid_compat"); |
1732 | if (!hid_compat_wq) { | 1740 | if (!hid_compat_wq) { |
1733 | hidraw_exit(); | 1741 | hidraw_exit(); |
1734 | goto err; | 1742 | goto err; |
diff --git a/drivers/hid/hid-dell.c b/drivers/hid/hid-dell.c index 1a0d0dfc62fc..f5474300b83a 100644 --- a/drivers/hid/hid-dell.c +++ b/drivers/hid/hid-dell.c | |||
@@ -48,6 +48,7 @@ err_free: | |||
48 | static const struct hid_device_id dell_devices[] = { | 48 | static const struct hid_device_id dell_devices[] = { |
49 | { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658) }, | 49 | { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658) }, |
50 | { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_SK8115) }, | 50 | { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_SK8115) }, |
51 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) }, | ||
51 | { } | 52 | { } |
52 | }; | 53 | }; |
53 | MODULE_DEVICE_TABLE(hid, dell_devices); | 54 | MODULE_DEVICE_TABLE(hid, dell_devices); |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index a0d6a6cb1842..d70075dd3d81 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -82,6 +82,9 @@ | |||
82 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230 | 82 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230 |
83 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231 | 83 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231 |
84 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232 | 84 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232 |
85 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 | ||
86 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 | ||
87 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 | ||
85 | #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a | 88 | #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a |
86 | #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b | 89 | #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b |
87 | #define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241 | 90 | #define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241 |
@@ -163,6 +166,9 @@ | |||
163 | 166 | ||
164 | #define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc | 167 | #define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc |
165 | 168 | ||
169 | #define USB_VENDOR_ID_GENERIC_13BA 0x13ba | ||
170 | #define USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE 0x0017 | ||
171 | |||
166 | #define USB_VENDOR_ID_GLAB 0x06c2 | 172 | #define USB_VENDOR_ID_GLAB 0x06c2 |
167 | #define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038 | 173 | #define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038 |
168 | #define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039 | 174 | #define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039 |
@@ -250,6 +256,9 @@ | |||
250 | #define USB_VENDOR_ID_KBGEAR 0x084e | 256 | #define USB_VENDOR_ID_KBGEAR 0x084e |
251 | #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 | 257 | #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 |
252 | 258 | ||
259 | #define USB_VENDOR_ID_KWORLD 0x1b80 | ||
260 | #define USB_DEVICE_ID_KWORLD_RADIO_FM700 0xd700 | ||
261 | |||
253 | #define USB_VENDOR_ID_LABTEC 0x1020 | 262 | #define USB_VENDOR_ID_LABTEC 0x1020 |
254 | #define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006 | 263 | #define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006 |
255 | 264 | ||
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 894d52e05bf9..7685ae6808c4 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
@@ -38,7 +38,7 @@ static int hidraw_major; | |||
38 | static struct cdev hidraw_cdev; | 38 | static struct cdev hidraw_cdev; |
39 | static struct class *hidraw_class; | 39 | static struct class *hidraw_class; |
40 | static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES]; | 40 | static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES]; |
41 | static DEFINE_SPINLOCK(minors_lock); | 41 | static DEFINE_MUTEX(minors_lock); |
42 | 42 | ||
43 | static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) | 43 | static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) |
44 | { | 44 | { |
@@ -159,13 +159,13 @@ static int hidraw_open(struct inode *inode, struct file *file) | |||
159 | struct hidraw_list *list; | 159 | struct hidraw_list *list; |
160 | int err = 0; | 160 | int err = 0; |
161 | 161 | ||
162 | lock_kernel(); | ||
163 | if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) { | 162 | if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) { |
164 | err = -ENOMEM; | 163 | err = -ENOMEM; |
165 | goto out; | 164 | goto out; |
166 | } | 165 | } |
167 | 166 | ||
168 | spin_lock(&minors_lock); | 167 | lock_kernel(); |
168 | mutex_lock(&minors_lock); | ||
169 | if (!hidraw_table[minor]) { | 169 | if (!hidraw_table[minor]) { |
170 | printk(KERN_EMERG "hidraw device with minor %d doesn't exist\n", | 170 | printk(KERN_EMERG "hidraw device with minor %d doesn't exist\n", |
171 | minor); | 171 | minor); |
@@ -180,13 +180,16 @@ static int hidraw_open(struct inode *inode, struct file *file) | |||
180 | file->private_data = list; | 180 | file->private_data = list; |
181 | 181 | ||
182 | dev = hidraw_table[minor]; | 182 | dev = hidraw_table[minor]; |
183 | if (!dev->open++) | 183 | if (!dev->open++) { |
184 | dev->hid->ll_driver->open(dev->hid); | 184 | err = dev->hid->ll_driver->open(dev->hid); |
185 | if (err < 0) | ||
186 | dev->open--; | ||
187 | } | ||
185 | 188 | ||
186 | out_unlock: | 189 | out_unlock: |
187 | spin_unlock(&minors_lock); | 190 | mutex_unlock(&minors_lock); |
188 | out: | ||
189 | unlock_kernel(); | 191 | unlock_kernel(); |
192 | out: | ||
190 | return err; | 193 | return err; |
191 | 194 | ||
192 | } | 195 | } |
@@ -310,7 +313,7 @@ int hidraw_connect(struct hid_device *hid) | |||
310 | 313 | ||
311 | result = -EINVAL; | 314 | result = -EINVAL; |
312 | 315 | ||
313 | spin_lock(&minors_lock); | 316 | mutex_lock(&minors_lock); |
314 | 317 | ||
315 | for (minor = 0; minor < HIDRAW_MAX_DEVICES; minor++) { | 318 | for (minor = 0; minor < HIDRAW_MAX_DEVICES; minor++) { |
316 | if (hidraw_table[minor]) | 319 | if (hidraw_table[minor]) |
@@ -320,9 +323,8 @@ int hidraw_connect(struct hid_device *hid) | |||
320 | break; | 323 | break; |
321 | } | 324 | } |
322 | 325 | ||
323 | spin_unlock(&minors_lock); | ||
324 | |||
325 | if (result) { | 326 | if (result) { |
327 | mutex_unlock(&minors_lock); | ||
326 | kfree(dev); | 328 | kfree(dev); |
327 | goto out; | 329 | goto out; |
328 | } | 330 | } |
@@ -331,14 +333,14 @@ int hidraw_connect(struct hid_device *hid) | |||
331 | NULL, "%s%d", "hidraw", minor); | 333 | NULL, "%s%d", "hidraw", minor); |
332 | 334 | ||
333 | if (IS_ERR(dev->dev)) { | 335 | if (IS_ERR(dev->dev)) { |
334 | spin_lock(&minors_lock); | ||
335 | hidraw_table[minor] = NULL; | 336 | hidraw_table[minor] = NULL; |
336 | spin_unlock(&minors_lock); | 337 | mutex_unlock(&minors_lock); |
337 | result = PTR_ERR(dev->dev); | 338 | result = PTR_ERR(dev->dev); |
338 | kfree(dev); | 339 | kfree(dev); |
339 | goto out; | 340 | goto out; |
340 | } | 341 | } |
341 | 342 | ||
343 | mutex_unlock(&minors_lock); | ||
342 | init_waitqueue_head(&dev->wait); | 344 | init_waitqueue_head(&dev->wait); |
343 | INIT_LIST_HEAD(&dev->list); | 345 | INIT_LIST_HEAD(&dev->list); |
344 | 346 | ||
@@ -360,9 +362,9 @@ void hidraw_disconnect(struct hid_device *hid) | |||
360 | 362 | ||
361 | hidraw->exist = 0; | 363 | hidraw->exist = 0; |
362 | 364 | ||
363 | spin_lock(&minors_lock); | 365 | mutex_lock(&minors_lock); |
364 | hidraw_table[hidraw->minor] = NULL; | 366 | hidraw_table[hidraw->minor] = NULL; |
365 | spin_unlock(&minors_lock); | 367 | mutex_unlock(&minors_lock); |
366 | 368 | ||
367 | device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); | 369 | device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); |
368 | 370 | ||
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 42bdd83444c1..d746bf8284dd 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/mutex.h> | ||
23 | #include <linux/smp_lock.h> | 24 | #include <linux/smp_lock.h> |
24 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
25 | #include <asm/unaligned.h> | 26 | #include <asm/unaligned.h> |
@@ -776,20 +777,11 @@ static int usbhid_start(struct hid_device *hid) | |||
776 | struct usb_interface *intf = to_usb_interface(hid->dev.parent); | 777 | struct usb_interface *intf = to_usb_interface(hid->dev.parent); |
777 | struct usb_host_interface *interface = intf->cur_altsetting; | 778 | struct usb_host_interface *interface = intf->cur_altsetting; |
778 | struct usb_device *dev = interface_to_usbdev(intf); | 779 | struct usb_device *dev = interface_to_usbdev(intf); |
779 | struct usbhid_device *usbhid; | 780 | struct usbhid_device *usbhid = hid->driver_data; |
780 | unsigned int n, insize = 0; | 781 | unsigned int n, insize = 0; |
781 | int ret; | 782 | int ret; |
782 | 783 | ||
783 | WARN_ON(hid->driver_data); | 784 | clear_bit(HID_DISCONNECTED, &usbhid->iofl); |
784 | |||
785 | usbhid = kzalloc(sizeof(struct usbhid_device), GFP_KERNEL); | ||
786 | if (usbhid == NULL) { | ||
787 | ret = -ENOMEM; | ||
788 | goto err; | ||
789 | } | ||
790 | |||
791 | hid->driver_data = usbhid; | ||
792 | usbhid->hid = hid; | ||
793 | 785 | ||
794 | usbhid->bufsize = HID_MIN_BUFFER_SIZE; | 786 | usbhid->bufsize = HID_MIN_BUFFER_SIZE; |
795 | hid_find_max_report(hid, HID_INPUT_REPORT, &usbhid->bufsize); | 787 | hid_find_max_report(hid, HID_INPUT_REPORT, &usbhid->bufsize); |
@@ -804,6 +796,7 @@ static int usbhid_start(struct hid_device *hid) | |||
804 | if (insize > HID_MAX_BUFFER_SIZE) | 796 | if (insize > HID_MAX_BUFFER_SIZE) |
805 | insize = HID_MAX_BUFFER_SIZE; | 797 | insize = HID_MAX_BUFFER_SIZE; |
806 | 798 | ||
799 | mutex_lock(&usbhid->setup); | ||
807 | if (hid_alloc_buffers(dev, hid)) { | 800 | if (hid_alloc_buffers(dev, hid)) { |
808 | ret = -ENOMEM; | 801 | ret = -ENOMEM; |
809 | goto fail; | 802 | goto fail; |
@@ -856,12 +849,6 @@ static int usbhid_start(struct hid_device *hid) | |||
856 | } | 849 | } |
857 | } | 850 | } |
858 | 851 | ||
859 | if (!usbhid->urbin) { | ||
860 | err_hid("couldn't find an input interrupt endpoint"); | ||
861 | ret = -ENODEV; | ||
862 | goto fail; | ||
863 | } | ||
864 | |||
865 | init_waitqueue_head(&usbhid->wait); | 852 | init_waitqueue_head(&usbhid->wait); |
866 | INIT_WORK(&usbhid->reset_work, hid_reset); | 853 | INIT_WORK(&usbhid->reset_work, hid_reset); |
867 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); | 854 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); |
@@ -888,15 +875,20 @@ static int usbhid_start(struct hid_device *hid) | |||
888 | usbhid_init_reports(hid); | 875 | usbhid_init_reports(hid); |
889 | hid_dump_device(hid); | 876 | hid_dump_device(hid); |
890 | 877 | ||
878 | set_bit(HID_STARTED, &usbhid->iofl); | ||
879 | mutex_unlock(&usbhid->setup); | ||
880 | |||
891 | return 0; | 881 | return 0; |
892 | 882 | ||
893 | fail: | 883 | fail: |
894 | usb_free_urb(usbhid->urbin); | 884 | usb_free_urb(usbhid->urbin); |
895 | usb_free_urb(usbhid->urbout); | 885 | usb_free_urb(usbhid->urbout); |
896 | usb_free_urb(usbhid->urbctrl); | 886 | usb_free_urb(usbhid->urbctrl); |
887 | usbhid->urbin = NULL; | ||
888 | usbhid->urbout = NULL; | ||
889 | usbhid->urbctrl = NULL; | ||
897 | hid_free_buffers(dev, hid); | 890 | hid_free_buffers(dev, hid); |
898 | kfree(usbhid); | 891 | mutex_unlock(&usbhid->setup); |
899 | err: | ||
900 | return ret; | 892 | return ret; |
901 | } | 893 | } |
902 | 894 | ||
@@ -907,6 +899,8 @@ static void usbhid_stop(struct hid_device *hid) | |||
907 | if (WARN_ON(!usbhid)) | 899 | if (WARN_ON(!usbhid)) |
908 | return; | 900 | return; |
909 | 901 | ||
902 | mutex_lock(&usbhid->setup); | ||
903 | clear_bit(HID_STARTED, &usbhid->iofl); | ||
910 | spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ | 904 | spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ |
911 | set_bit(HID_DISCONNECTED, &usbhid->iofl); | 905 | set_bit(HID_DISCONNECTED, &usbhid->iofl); |
912 | spin_unlock_irq(&usbhid->inlock); | 906 | spin_unlock_irq(&usbhid->inlock); |
@@ -929,10 +923,12 @@ static void usbhid_stop(struct hid_device *hid) | |||
929 | usb_free_urb(usbhid->urbin); | 923 | usb_free_urb(usbhid->urbin); |
930 | usb_free_urb(usbhid->urbctrl); | 924 | usb_free_urb(usbhid->urbctrl); |
931 | usb_free_urb(usbhid->urbout); | 925 | usb_free_urb(usbhid->urbout); |
926 | usbhid->urbin = NULL; /* don't mess up next start */ | ||
927 | usbhid->urbctrl = NULL; | ||
928 | usbhid->urbout = NULL; | ||
932 | 929 | ||
933 | hid_free_buffers(hid_to_usb_dev(hid), hid); | 930 | hid_free_buffers(hid_to_usb_dev(hid), hid); |
934 | kfree(usbhid); | 931 | mutex_unlock(&usbhid->setup); |
935 | hid->driver_data = NULL; | ||
936 | } | 932 | } |
937 | 933 | ||
938 | static struct hid_ll_driver usb_hid_driver = { | 934 | static struct hid_ll_driver usb_hid_driver = { |
@@ -946,14 +942,26 @@ static struct hid_ll_driver usb_hid_driver = { | |||
946 | 942 | ||
947 | static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) | 943 | static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) |
948 | { | 944 | { |
945 | struct usb_host_interface *interface = intf->cur_altsetting; | ||
949 | struct usb_device *dev = interface_to_usbdev(intf); | 946 | struct usb_device *dev = interface_to_usbdev(intf); |
947 | struct usbhid_device *usbhid; | ||
950 | struct hid_device *hid; | 948 | struct hid_device *hid; |
949 | unsigned int n, has_in = 0; | ||
951 | size_t len; | 950 | size_t len; |
952 | int ret; | 951 | int ret; |
953 | 952 | ||
954 | dbg_hid("HID probe called for ifnum %d\n", | 953 | dbg_hid("HID probe called for ifnum %d\n", |
955 | intf->altsetting->desc.bInterfaceNumber); | 954 | intf->altsetting->desc.bInterfaceNumber); |
956 | 955 | ||
956 | for (n = 0; n < interface->desc.bNumEndpoints; n++) | ||
957 | if (usb_endpoint_is_int_in(&interface->endpoint[n].desc)) | ||
958 | has_in++; | ||
959 | if (!has_in) { | ||
960 | dev_err(&intf->dev, "couldn't find an input interrupt " | ||
961 | "endpoint\n"); | ||
962 | return -ENODEV; | ||
963 | } | ||
964 | |||
957 | hid = hid_allocate_device(); | 965 | hid = hid_allocate_device(); |
958 | if (IS_ERR(hid)) | 966 | if (IS_ERR(hid)) |
959 | return PTR_ERR(hid); | 967 | return PTR_ERR(hid); |
@@ -1000,14 +1008,26 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1000 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) | 1008 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) |
1001 | hid->uniq[0] = 0; | 1009 | hid->uniq[0] = 0; |
1002 | 1010 | ||
1011 | usbhid = kzalloc(sizeof(*usbhid), GFP_KERNEL); | ||
1012 | if (usbhid == NULL) { | ||
1013 | ret = -ENOMEM; | ||
1014 | goto err; | ||
1015 | } | ||
1016 | |||
1017 | hid->driver_data = usbhid; | ||
1018 | usbhid->hid = hid; | ||
1019 | mutex_init(&usbhid->setup); /* needed on suspend/resume */ | ||
1020 | |||
1003 | ret = hid_add_device(hid); | 1021 | ret = hid_add_device(hid); |
1004 | if (ret) { | 1022 | if (ret) { |
1005 | if (ret != -ENODEV) | 1023 | if (ret != -ENODEV) |
1006 | dev_err(&intf->dev, "can't add hid device: %d\n", ret); | 1024 | dev_err(&intf->dev, "can't add hid device: %d\n", ret); |
1007 | goto err; | 1025 | goto err_free; |
1008 | } | 1026 | } |
1009 | 1027 | ||
1010 | return 0; | 1028 | return 0; |
1029 | err_free: | ||
1030 | kfree(usbhid); | ||
1011 | err: | 1031 | err: |
1012 | hid_destroy_device(hid); | 1032 | hid_destroy_device(hid); |
1013 | return ret; | 1033 | return ret; |
@@ -1016,11 +1036,14 @@ err: | |||
1016 | static void hid_disconnect(struct usb_interface *intf) | 1036 | static void hid_disconnect(struct usb_interface *intf) |
1017 | { | 1037 | { |
1018 | struct hid_device *hid = usb_get_intfdata(intf); | 1038 | struct hid_device *hid = usb_get_intfdata(intf); |
1039 | struct usbhid_device *usbhid; | ||
1019 | 1040 | ||
1020 | if (WARN_ON(!hid)) | 1041 | if (WARN_ON(!hid)) |
1021 | return; | 1042 | return; |
1022 | 1043 | ||
1044 | usbhid = hid->driver_data; | ||
1023 | hid_destroy_device(hid); | 1045 | hid_destroy_device(hid); |
1046 | kfree(usbhid); | ||
1024 | } | 1047 | } |
1025 | 1048 | ||
1026 | static int hid_suspend(struct usb_interface *intf, pm_message_t message) | 1049 | static int hid_suspend(struct usb_interface *intf, pm_message_t message) |
@@ -1028,11 +1051,18 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message) | |||
1028 | struct hid_device *hid = usb_get_intfdata (intf); | 1051 | struct hid_device *hid = usb_get_intfdata (intf); |
1029 | struct usbhid_device *usbhid = hid->driver_data; | 1052 | struct usbhid_device *usbhid = hid->driver_data; |
1030 | 1053 | ||
1054 | mutex_lock(&usbhid->setup); | ||
1055 | if (!test_bit(HID_STARTED, &usbhid->iofl)) { | ||
1056 | mutex_unlock(&usbhid->setup); | ||
1057 | return 0; | ||
1058 | } | ||
1059 | |||
1031 | spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ | 1060 | spin_lock_irq(&usbhid->inlock); /* Sync with error handler */ |
1032 | set_bit(HID_SUSPENDED, &usbhid->iofl); | 1061 | set_bit(HID_SUSPENDED, &usbhid->iofl); |
1033 | spin_unlock_irq(&usbhid->inlock); | 1062 | spin_unlock_irq(&usbhid->inlock); |
1034 | del_timer(&usbhid->io_retry); | 1063 | del_timer_sync(&usbhid->io_retry); |
1035 | usb_kill_urb(usbhid->urbin); | 1064 | usb_kill_urb(usbhid->urbin); |
1065 | mutex_unlock(&usbhid->setup); | ||
1036 | dev_dbg(&intf->dev, "suspend\n"); | 1066 | dev_dbg(&intf->dev, "suspend\n"); |
1037 | return 0; | 1067 | return 0; |
1038 | } | 1068 | } |
@@ -1043,9 +1073,16 @@ static int hid_resume(struct usb_interface *intf) | |||
1043 | struct usbhid_device *usbhid = hid->driver_data; | 1073 | struct usbhid_device *usbhid = hid->driver_data; |
1044 | int status; | 1074 | int status; |
1045 | 1075 | ||
1076 | mutex_lock(&usbhid->setup); | ||
1077 | if (!test_bit(HID_STARTED, &usbhid->iofl)) { | ||
1078 | mutex_unlock(&usbhid->setup); | ||
1079 | return 0; | ||
1080 | } | ||
1081 | |||
1046 | clear_bit(HID_SUSPENDED, &usbhid->iofl); | 1082 | clear_bit(HID_SUSPENDED, &usbhid->iofl); |
1047 | usbhid->retry_delay = 0; | 1083 | usbhid->retry_delay = 0; |
1048 | status = hid_start_in(hid); | 1084 | status = hid_start_in(hid); |
1085 | mutex_unlock(&usbhid->setup); | ||
1049 | dev_dbg(&intf->dev, "resume status %d\n", status); | 1086 | dev_dbg(&intf->dev, "resume status %d\n", status); |
1050 | return status; | 1087 | return status; |
1051 | } | 1088 | } |
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index 3ac320785fc5..83e851a5ed30 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c | |||
@@ -242,8 +242,6 @@ static int hiddev_release(struct inode * inode, struct file * file) | |||
242 | struct hiddev_list *list = file->private_data; | 242 | struct hiddev_list *list = file->private_data; |
243 | unsigned long flags; | 243 | unsigned long flags; |
244 | 244 | ||
245 | hiddev_fasync(-1, file, 0); | ||
246 | |||
247 | spin_lock_irqsave(&list->hiddev->list_lock, flags); | 245 | spin_lock_irqsave(&list->hiddev->list_lock, flags); |
248 | list_del(&list->node); | 246 | list_del(&list->node); |
249 | spin_unlock_irqrestore(&list->hiddev->list_lock, flags); | 247 | spin_unlock_irqrestore(&list->hiddev->list_lock, flags); |
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h index abedb13c623e..55973ff54008 100644 --- a/drivers/hid/usbhid/usbhid.h +++ b/drivers/hid/usbhid/usbhid.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/list.h> | 29 | #include <linux/list.h> |
30 | #include <linux/mutex.h> | ||
30 | #include <linux/timer.h> | 31 | #include <linux/timer.h> |
31 | #include <linux/wait.h> | 32 | #include <linux/wait.h> |
32 | #include <linux/workqueue.h> | 33 | #include <linux/workqueue.h> |
@@ -73,6 +74,7 @@ struct usbhid_device { | |||
73 | dma_addr_t outbuf_dma; /* Output buffer dma */ | 74 | dma_addr_t outbuf_dma; /* Output buffer dma */ |
74 | spinlock_t outlock; /* Output fifo spinlock */ | 75 | spinlock_t outlock; /* Output fifo spinlock */ |
75 | 76 | ||
77 | struct mutex setup; | ||
76 | unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ | 78 | unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ |
77 | struct timer_list io_retry; /* Retry timer */ | 79 | struct timer_list io_retry; /* Retry timer */ |
78 | unsigned long stop_retry; /* Time to give up, in jiffies */ | 80 | unsigned long stop_retry; /* Time to give up, in jiffies */ |