Commit fea6f1833b5bbff7066bcde1fa1141c9717bbad2

Authored by Jiri Slaby
Committed by Jiri Kosina
1 parent bd28ce008b

HID: move dell quirks

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Showing 6 changed files with 86 additions and 2 deletions Inline Diff

1 # 1 #
2 # HID driver configuration 2 # HID driver configuration
3 # 3 #
4 menuconfig HID_SUPPORT 4 menuconfig HID_SUPPORT
5 bool "HID Devices" 5 bool "HID Devices"
6 depends on INPUT 6 depends on INPUT
7 default y 7 default y
8 ---help--- 8 ---help---
9 Say Y here to get to see options for various computer-human interface 9 Say Y here to get to see options for various computer-human interface
10 device drivers. This option alone does not add any kernel code. 10 device drivers. This option alone does not add any kernel code.
11 11
12 If you say N, all options in this submenu will be skipped and disabled. 12 If you say N, all options in this submenu will be skipped and disabled.
13 13
14 if HID_SUPPORT 14 if HID_SUPPORT
15 15
16 config HID 16 config HID
17 tristate "Generic HID support" 17 tristate "Generic HID support"
18 depends on INPUT 18 depends on INPUT
19 default y 19 default y
20 ---help--- 20 ---help---
21 A human interface device (HID) is a type of computer device that 21 A human interface device (HID) is a type of computer device that
22 interacts directly with and takes input from humans. The term "HID" 22 interacts directly with and takes input from humans. The term "HID"
23 most commonly used to refer to the USB-HID specification, but other 23 most commonly used to refer to the USB-HID specification, but other
24 devices (such as, but not strictly limited to, Bluetooth) are 24 devices (such as, but not strictly limited to, Bluetooth) are
25 designed using HID specification (this involves certain keyboards, 25 designed using HID specification (this involves certain keyboards,
26 mice, tablets, etc). This option compiles into kernel the generic 26 mice, tablets, etc). This option compiles into kernel the generic
27 HID layer code (parser, usages, etc.), which can then be used by 27 HID layer code (parser, usages, etc.), which can then be used by
28 transport-specific HID implementation (like USB or Bluetooth). 28 transport-specific HID implementation (like USB or Bluetooth).
29 29
30 For docs and specs, see http://www.usb.org/developers/hidpage/ 30 For docs and specs, see http://www.usb.org/developers/hidpage/
31 31
32 If unsure, say Y 32 If unsure, say Y
33 33
34 config HID_DEBUG 34 config HID_DEBUG
35 bool "HID debugging support" 35 bool "HID debugging support"
36 default y if !EMBEDDED 36 default y if !EMBEDDED
37 depends on HID 37 depends on HID
38 ---help--- 38 ---help---
39 This option lets the HID layer output diagnostics about its internal 39 This option lets the HID layer output diagnostics about its internal
40 state, resolve HID usages, dump HID fields, etc. Individual HID drivers 40 state, resolve HID usages, dump HID fields, etc. Individual HID drivers
41 use this debugging facility to output information about individual HID 41 use this debugging facility to output information about individual HID
42 devices, etc. 42 devices, etc.
43 43
44 This feature is useful for those who are either debugging the HID parser 44 This feature is useful for those who are either debugging the HID parser
45 or any HID hardware device. 45 or any HID hardware device.
46 46
47 If unsure, say N 47 If unsure, say N
48 48
49 config HIDRAW 49 config HIDRAW
50 bool "/dev/hidraw raw HID device support" 50 bool "/dev/hidraw raw HID device support"
51 depends on HID 51 depends on HID
52 ---help--- 52 ---help---
53 Say Y here if you want to support HID devices (from the USB 53 Say Y here if you want to support HID devices (from the USB
54 specification standpoint) that aren't strictly user interface 54 specification standpoint) that aren't strictly user interface
55 devices, like monitor controls and Uninterruptable Power Supplies. 55 devices, like monitor controls and Uninterruptable Power Supplies.
56 56
57 This module supports these devices separately using a separate 57 This module supports these devices separately using a separate
58 event interface on /dev/hidraw. 58 event interface on /dev/hidraw.
59 59
60 There is also a /dev/hiddev configuration option in the USB HID 60 There is also a /dev/hiddev configuration option in the USB HID
61 configuration menu. In comparison to hiddev, this device does not process 61 configuration menu. In comparison to hiddev, this device does not process
62 the hid events at all (no parsing, no lookups). This lets applications 62 the hid events at all (no parsing, no lookups). This lets applications
63 to work on raw hid events when they want to, and avoid using transport-specific 63 to work on raw hid events when they want to, and avoid using transport-specific
64 userspace libhid/libusb libraries. 64 userspace libhid/libusb libraries.
65 65
66 If unsure, say Y. 66 If unsure, say Y.
67 67
68 source "drivers/hid/usbhid/Kconfig" 68 source "drivers/hid/usbhid/Kconfig"
69 69
70 menu "Special HID drivers" 70 menu "Special HID drivers"
71 depends on HID 71 depends on HID
72 72
73 config HID_COMPAT 73 config HID_COMPAT
74 bool "Load all HID drivers on hid core load" 74 bool "Load all HID drivers on hid core load"
75 default y 75 default y
76 ---help--- 76 ---help---
77 Compatible option for older userspace. If you have system without udev 77 Compatible option for older userspace. If you have system without udev
78 support of module loading through aliases and also old 78 support of module loading through aliases and also old
79 module-init-tools which can't handle hid bus, choose Y here. Otherwise 79 module-init-tools which can't handle hid bus, choose Y here. Otherwise
80 say N. If you say N and your userspace is old enough, the only 80 say N. If you say N and your userspace is old enough, the only
81 functionality you loose is modules autoloading. 81 functionality you loose is modules autoloading.
82 82
83 If unsure, say Y. 83 If unsure, say Y.
84 84
85 config HID_A4TECH 85 config HID_A4TECH
86 tristate "A4 tech" 86 tristate "A4 tech"
87 default m 87 default m
88 depends on USB_HID 88 depends on USB_HID
89 ---help--- 89 ---help---
90 Support for A4 tech X5 and WOP-35 / Trust 450L mice. 90 Support for A4 tech X5 and WOP-35 / Trust 450L mice.
91 91
92 config HID_APPLE 92 config HID_APPLE
93 tristate "Apple" 93 tristate "Apple"
94 default m 94 default m
95 depends on (USB_HID || BT_HIDP) 95 depends on (USB_HID || BT_HIDP)
96 ---help--- 96 ---help---
97 Support for some Apple devices which less or more break 97 Support for some Apple devices which less or more break
98 HID specification. 98 HID specification.
99 99
100 Say Y here if you want support for the special keys (Fn, Numlock) on 100 Say Y here if you want support for the special keys (Fn, Numlock) on
101 Apple iBooks, PowerBooks, MacBooks, MacBook Pros and aluminum USB 101 Apple iBooks, PowerBooks, MacBooks, MacBook Pros and aluminum USB
102 keyboards. 102 keyboards.
103 103
104 If unsure, say M. 104 If unsure, say M.
105 105
106 config HID_BELKIN 106 config HID_BELKIN
107 tristate "Belkin" 107 tristate "Belkin"
108 default m 108 default m
109 depends on USB_HID 109 depends on USB_HID
110 ---help--- 110 ---help---
111 Support for Belkin Flip KVM and Wireless keyboard. 111 Support for Belkin Flip KVM and Wireless keyboard.
112 112
113 config HID_CHERRY 113 config HID_CHERRY
114 tristate "Cherry" 114 tristate "Cherry"
115 default m 115 default m
116 depends on USB_HID 116 depends on USB_HID
117 ---help--- 117 ---help---
118 Support for Cherry Cymotion. 118 Support for Cherry Cymotion.
119 119
120 config HID_CHICONY 120 config HID_CHICONY
121 tristate "Chicony" 121 tristate "Chicony"
122 default m 122 default m
123 depends on USB_HID 123 depends on USB_HID
124 ---help--- 124 ---help---
125 Support for Chicony Tactical pad. 125 Support for Chicony Tactical pad.
126 126
127 config HID_CYPRESS 127 config HID_CYPRESS
128 tristate "Cypress" 128 tristate "Cypress"
129 default m 129 default m
130 depends on USB_HID 130 depends on USB_HID
131 ---help--- 131 ---help---
132 Support for Cypress mouse and barcodes. 132 Support for Cypress mouse and barcodes.
133 133
134 config HID_DELL
135 tristate "Dell"
136 default m
137 depends on USB_HID
138 ---help---
139 Support for Dell W7658.
140
134 config HID_EZKEY 141 config HID_EZKEY
135 tristate "Ezkey" 142 tristate "Ezkey"
136 default m 143 default m
137 depends on USB_HID 144 depends on USB_HID
138 ---help--- 145 ---help---
139 Support for Ezkey mouse and barcodes. 146 Support for Ezkey mouse and barcodes.
140 147
141 config HID_GYRATION 148 config HID_GYRATION
142 tristate "Gyration" 149 tristate "Gyration"
143 default m 150 default m
144 depends on USB_HID 151 depends on USB_HID
145 ---help--- 152 ---help---
146 Support for Gyration remote. 153 Support for Gyration remote.
147 154
148 config HID_LOGITECH 155 config HID_LOGITECH
149 tristate "Logitech" 156 tristate "Logitech"
150 default m 157 default m
151 depends on USB_HID 158 depends on USB_HID
152 ---help--- 159 ---help---
153 Support for some Logitech devices which breaks less or more 160 Support for some Logitech devices which breaks less or more
154 HID specification. 161 HID specification.
155 162
156 config HID_MICROSOFT 163 config HID_MICROSOFT
157 tristate "Microsoft" 164 tristate "Microsoft"
158 default m 165 default m
159 depends on USB_HID 166 depends on USB_HID
160 ---help--- 167 ---help---
161 Support for some Microsoft devices which breaks less or more 168 Support for some Microsoft devices which breaks less or more
162 HID specification. 169 HID specification.
163 170
164 config HID_MONTEREY 171 config HID_MONTEREY
165 tristate "Monterey" 172 tristate "Monterey"
166 default m 173 default m
167 depends on USB_HID 174 depends on USB_HID
168 ---help--- 175 ---help---
169 Support for Monterey Genius KB29E. 176 Support for Monterey Genius KB29E.
170 177
171 config HID_PETALYNX 178 config HID_PETALYNX
172 tristate "Petalynx" 179 tristate "Petalynx"
173 default m 180 default m
174 depends on USB_HID 181 depends on USB_HID
175 ---help--- 182 ---help---
176 Support for Petalynx Maxter remote. 183 Support for Petalynx Maxter remote.
177 184
178 config HID_SAMSUNG 185 config HID_SAMSUNG
179 tristate "Samsung" 186 tristate "Samsung"
180 default m 187 default m
181 depends on USB_HID 188 depends on USB_HID
182 ---help--- 189 ---help---
183 Support for Samsung IR remote. 190 Support for Samsung IR remote.
184 191
185 config HID_SONY 192 config HID_SONY
186 tristate "Sony" 193 tristate "Sony"
187 default m 194 default m
188 depends on USB_HID 195 depends on USB_HID
189 ---help--- 196 ---help---
190 Support for Sony PS3 controller. 197 Support for Sony PS3 controller.
191 198
192 config HID_SUNPLUS 199 config HID_SUNPLUS
193 tristate "Sunplus" 200 tristate "Sunplus"
194 default m 201 default m
195 depends on USB_HID 202 depends on USB_HID
196 ---help--- 203 ---help---
197 Support for Sunplus WDesktop input device. 204 Support for Sunplus WDesktop input device.
198 205
199 endmenu 206 endmenu
200 207
201 endif # HID_SUPPORT 208 endif # HID_SUPPORT
202 209
drivers/hid/Makefile
1 # 1 #
2 # Makefile for the HID driver 2 # Makefile for the HID driver
3 # 3 #
4 hid-objs := hid-core.o hid-input.o 4 hid-objs := hid-core.o hid-input.o
5 5
6 obj-$(CONFIG_HID) += hid.o 6 obj-$(CONFIG_HID) += hid.o
7 7
8 hid-$(CONFIG_HID_DEBUG) += hid-debug.o 8 hid-$(CONFIG_HID_DEBUG) += hid-debug.o
9 hid-$(CONFIG_HIDRAW) += hidraw.o 9 hid-$(CONFIG_HIDRAW) += hidraw.o
10 10
11 ifdef CONFIG_HID_COMPAT 11 ifdef CONFIG_HID_COMPAT
12 obj-m += hid-dummy.o 12 obj-m += hid-dummy.o
13 endif 13 endif
14 14
15 obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o 15 obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
16 obj-$(CONFIG_HID_APPLE) += hid-apple.o 16 obj-$(CONFIG_HID_APPLE) += hid-apple.o
17 obj-$(CONFIG_HID_BELKIN) += hid-belkin.o 17 obj-$(CONFIG_HID_BELKIN) += hid-belkin.o
18 obj-$(CONFIG_HID_CHERRY) += hid-cherry.o 18 obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
19 obj-$(CONFIG_HID_CHICONY) += hid-chicony.o 19 obj-$(CONFIG_HID_CHICONY) += hid-chicony.o
20 obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o 20 obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
21 obj-$(CONFIG_HID_DELL) += hid-dell.o
21 obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o 22 obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
22 obj-$(CONFIG_HID_GYRATION) += hid-gyration.o 23 obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
23 obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o 24 obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o
24 obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o 25 obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
25 obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o 26 obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o
26 obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o 27 obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
27 obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o 28 obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
28 obj-$(CONFIG_HID_SONY) += hid-sony.o 29 obj-$(CONFIG_HID_SONY) += hid-sony.o
29 obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o 30 obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
30 31
31 obj-$(CONFIG_USB_HID) += usbhid/ 32 obj-$(CONFIG_USB_HID) += usbhid/
32 obj-$(CONFIG_USB_MOUSE) += usbhid/ 33 obj-$(CONFIG_USB_MOUSE) += usbhid/
33 obj-$(CONFIG_USB_KBD) += usbhid/ 34 obj-$(CONFIG_USB_KBD) += usbhid/
34 35
35 36
drivers/hid/hid-core.c
1 /* 1 /*
2 * HID support for Linux 2 * HID support for Linux
3 * 3 *
4 * Copyright (c) 1999 Andreas Gal 4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina 7 * Copyright (c) 2006-2007 Jiri Kosina
8 */ 8 */
9 9
10 /* 10 /*
11 * This program is free software; you can redistribute it and/or modify it 11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free 12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2 of the License, or (at your option) 13 * Software Foundation; either version 2 of the License, or (at your option)
14 * any later version. 14 * any later version.
15 */ 15 */
16 16
17 #include <linux/module.h> 17 #include <linux/module.h>
18 #include <linux/slab.h> 18 #include <linux/slab.h>
19 #include <linux/init.h> 19 #include <linux/init.h>
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/spinlock.h> 23 #include <linux/spinlock.h>
24 #include <asm/unaligned.h> 24 #include <asm/unaligned.h>
25 #include <asm/byteorder.h> 25 #include <asm/byteorder.h>
26 #include <linux/input.h> 26 #include <linux/input.h>
27 #include <linux/wait.h> 27 #include <linux/wait.h>
28 #include <linux/vmalloc.h> 28 #include <linux/vmalloc.h>
29 #include <linux/sched.h> 29 #include <linux/sched.h>
30 30
31 #include <linux/hid.h> 31 #include <linux/hid.h>
32 #include <linux/hiddev.h> 32 #include <linux/hiddev.h>
33 #include <linux/hid-debug.h> 33 #include <linux/hid-debug.h>
34 #include <linux/hidraw.h> 34 #include <linux/hidraw.h>
35 35
36 #include "hid-ids.h" 36 #include "hid-ids.h"
37 37
38 /* 38 /*
39 * Version Information 39 * Version Information
40 */ 40 */
41 41
42 #define DRIVER_VERSION "v2.6" 42 #define DRIVER_VERSION "v2.6"
43 #define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik, Jiri Kosina" 43 #define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik, Jiri Kosina"
44 #define DRIVER_DESC "HID core driver" 44 #define DRIVER_DESC "HID core driver"
45 #define DRIVER_LICENSE "GPL" 45 #define DRIVER_LICENSE "GPL"
46 46
47 #ifdef CONFIG_HID_DEBUG 47 #ifdef CONFIG_HID_DEBUG
48 int hid_debug = 0; 48 int hid_debug = 0;
49 module_param_named(debug, hid_debug, int, 0600); 49 module_param_named(debug, hid_debug, int, 0600);
50 MODULE_PARM_DESC(debug, "HID debugging (0=off, 1=probing info, 2=continuous data dumping)"); 50 MODULE_PARM_DESC(debug, "HID debugging (0=off, 1=probing info, 2=continuous data dumping)");
51 EXPORT_SYMBOL_GPL(hid_debug); 51 EXPORT_SYMBOL_GPL(hid_debug);
52 #endif 52 #endif
53 53
54 /* 54 /*
55 * Register a new report for a device. 55 * Register a new report for a device.
56 */ 56 */
57 57
58 static struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) 58 static struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id)
59 { 59 {
60 struct hid_report_enum *report_enum = device->report_enum + type; 60 struct hid_report_enum *report_enum = device->report_enum + type;
61 struct hid_report *report; 61 struct hid_report *report;
62 62
63 if (report_enum->report_id_hash[id]) 63 if (report_enum->report_id_hash[id])
64 return report_enum->report_id_hash[id]; 64 return report_enum->report_id_hash[id];
65 65
66 if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL))) 66 if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL)))
67 return NULL; 67 return NULL;
68 68
69 if (id != 0) 69 if (id != 0)
70 report_enum->numbered = 1; 70 report_enum->numbered = 1;
71 71
72 report->id = id; 72 report->id = id;
73 report->type = type; 73 report->type = type;
74 report->size = 0; 74 report->size = 0;
75 report->device = device; 75 report->device = device;
76 report_enum->report_id_hash[id] = report; 76 report_enum->report_id_hash[id] = report;
77 77
78 list_add_tail(&report->list, &report_enum->report_list); 78 list_add_tail(&report->list, &report_enum->report_list);
79 79
80 return report; 80 return report;
81 } 81 }
82 82
83 /* 83 /*
84 * Register a new field for this report. 84 * Register a new field for this report.
85 */ 85 */
86 86
87 static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) 87 static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
88 { 88 {
89 struct hid_field *field; 89 struct hid_field *field;
90 90
91 if (report->maxfield == HID_MAX_FIELDS) { 91 if (report->maxfield == HID_MAX_FIELDS) {
92 dbg_hid("too many fields in report\n"); 92 dbg_hid("too many fields in report\n");
93 return NULL; 93 return NULL;
94 } 94 }
95 95
96 if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage) 96 if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage)
97 + values * sizeof(unsigned), GFP_KERNEL))) return NULL; 97 + values * sizeof(unsigned), GFP_KERNEL))) return NULL;
98 98
99 field->index = report->maxfield++; 99 field->index = report->maxfield++;
100 report->field[field->index] = field; 100 report->field[field->index] = field;
101 field->usage = (struct hid_usage *)(field + 1); 101 field->usage = (struct hid_usage *)(field + 1);
102 field->value = (s32 *)(field->usage + usages); 102 field->value = (s32 *)(field->usage + usages);
103 field->report = report; 103 field->report = report;
104 104
105 return field; 105 return field;
106 } 106 }
107 107
108 /* 108 /*
109 * Open a collection. The type/usage is pushed on the stack. 109 * Open a collection. The type/usage is pushed on the stack.
110 */ 110 */
111 111
112 static int open_collection(struct hid_parser *parser, unsigned type) 112 static int open_collection(struct hid_parser *parser, unsigned type)
113 { 113 {
114 struct hid_collection *collection; 114 struct hid_collection *collection;
115 unsigned usage; 115 unsigned usage;
116 116
117 usage = parser->local.usage[0]; 117 usage = parser->local.usage[0];
118 118
119 if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { 119 if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) {
120 dbg_hid("collection stack overflow\n"); 120 dbg_hid("collection stack overflow\n");
121 return -1; 121 return -1;
122 } 122 }
123 123
124 if (parser->device->maxcollection == parser->device->collection_size) { 124 if (parser->device->maxcollection == parser->device->collection_size) {
125 collection = kmalloc(sizeof(struct hid_collection) * 125 collection = kmalloc(sizeof(struct hid_collection) *
126 parser->device->collection_size * 2, GFP_KERNEL); 126 parser->device->collection_size * 2, GFP_KERNEL);
127 if (collection == NULL) { 127 if (collection == NULL) {
128 dbg_hid("failed to reallocate collection array\n"); 128 dbg_hid("failed to reallocate collection array\n");
129 return -1; 129 return -1;
130 } 130 }
131 memcpy(collection, parser->device->collection, 131 memcpy(collection, parser->device->collection,
132 sizeof(struct hid_collection) * 132 sizeof(struct hid_collection) *
133 parser->device->collection_size); 133 parser->device->collection_size);
134 memset(collection + parser->device->collection_size, 0, 134 memset(collection + parser->device->collection_size, 0,
135 sizeof(struct hid_collection) * 135 sizeof(struct hid_collection) *
136 parser->device->collection_size); 136 parser->device->collection_size);
137 kfree(parser->device->collection); 137 kfree(parser->device->collection);
138 parser->device->collection = collection; 138 parser->device->collection = collection;
139 parser->device->collection_size *= 2; 139 parser->device->collection_size *= 2;
140 } 140 }
141 141
142 parser->collection_stack[parser->collection_stack_ptr++] = 142 parser->collection_stack[parser->collection_stack_ptr++] =
143 parser->device->maxcollection; 143 parser->device->maxcollection;
144 144
145 collection = parser->device->collection + 145 collection = parser->device->collection +
146 parser->device->maxcollection++; 146 parser->device->maxcollection++;
147 collection->type = type; 147 collection->type = type;
148 collection->usage = usage; 148 collection->usage = usage;
149 collection->level = parser->collection_stack_ptr - 1; 149 collection->level = parser->collection_stack_ptr - 1;
150 150
151 if (type == HID_COLLECTION_APPLICATION) 151 if (type == HID_COLLECTION_APPLICATION)
152 parser->device->maxapplication++; 152 parser->device->maxapplication++;
153 153
154 return 0; 154 return 0;
155 } 155 }
156 156
157 /* 157 /*
158 * Close a collection. 158 * Close a collection.
159 */ 159 */
160 160
161 static int close_collection(struct hid_parser *parser) 161 static int close_collection(struct hid_parser *parser)
162 { 162 {
163 if (!parser->collection_stack_ptr) { 163 if (!parser->collection_stack_ptr) {
164 dbg_hid("collection stack underflow\n"); 164 dbg_hid("collection stack underflow\n");
165 return -1; 165 return -1;
166 } 166 }
167 parser->collection_stack_ptr--; 167 parser->collection_stack_ptr--;
168 return 0; 168 return 0;
169 } 169 }
170 170
171 /* 171 /*
172 * Climb up the stack, search for the specified collection type 172 * Climb up the stack, search for the specified collection type
173 * and return the usage. 173 * and return the usage.
174 */ 174 */
175 175
176 static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) 176 static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
177 { 177 {
178 int n; 178 int n;
179 for (n = parser->collection_stack_ptr - 1; n >= 0; n--) 179 for (n = parser->collection_stack_ptr - 1; n >= 0; n--)
180 if (parser->device->collection[parser->collection_stack[n]].type == type) 180 if (parser->device->collection[parser->collection_stack[n]].type == type)
181 return parser->device->collection[parser->collection_stack[n]].usage; 181 return parser->device->collection[parser->collection_stack[n]].usage;
182 return 0; /* we know nothing about this usage type */ 182 return 0; /* we know nothing about this usage type */
183 } 183 }
184 184
185 /* 185 /*
186 * Add a usage to the temporary parser table. 186 * Add a usage to the temporary parser table.
187 */ 187 */
188 188
189 static int hid_add_usage(struct hid_parser *parser, unsigned usage) 189 static int hid_add_usage(struct hid_parser *parser, unsigned usage)
190 { 190 {
191 if (parser->local.usage_index >= HID_MAX_USAGES) { 191 if (parser->local.usage_index >= HID_MAX_USAGES) {
192 dbg_hid("usage index exceeded\n"); 192 dbg_hid("usage index exceeded\n");
193 return -1; 193 return -1;
194 } 194 }
195 parser->local.usage[parser->local.usage_index] = usage; 195 parser->local.usage[parser->local.usage_index] = usage;
196 parser->local.collection_index[parser->local.usage_index] = 196 parser->local.collection_index[parser->local.usage_index] =
197 parser->collection_stack_ptr ? 197 parser->collection_stack_ptr ?
198 parser->collection_stack[parser->collection_stack_ptr - 1] : 0; 198 parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
199 parser->local.usage_index++; 199 parser->local.usage_index++;
200 return 0; 200 return 0;
201 } 201 }
202 202
203 /* 203 /*
204 * Register a new field for this report. 204 * Register a new field for this report.
205 */ 205 */
206 206
207 static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags) 207 static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags)
208 { 208 {
209 struct hid_report *report; 209 struct hid_report *report;
210 struct hid_field *field; 210 struct hid_field *field;
211 int usages; 211 int usages;
212 unsigned offset; 212 unsigned offset;
213 int i; 213 int i;
214 214
215 if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) { 215 if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) {
216 dbg_hid("hid_register_report failed\n"); 216 dbg_hid("hid_register_report failed\n");
217 return -1; 217 return -1;
218 } 218 }
219 219
220 if (parser->global.logical_maximum < parser->global.logical_minimum) { 220 if (parser->global.logical_maximum < parser->global.logical_minimum) {
221 dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum); 221 dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum);
222 return -1; 222 return -1;
223 } 223 }
224 224
225 offset = report->size; 225 offset = report->size;
226 report->size += parser->global.report_size * parser->global.report_count; 226 report->size += parser->global.report_size * parser->global.report_count;
227 227
228 if (!parser->local.usage_index) /* Ignore padding fields */ 228 if (!parser->local.usage_index) /* Ignore padding fields */
229 return 0; 229 return 0;
230 230
231 usages = max_t(int, parser->local.usage_index, parser->global.report_count); 231 usages = max_t(int, parser->local.usage_index, parser->global.report_count);
232 232
233 if ((field = hid_register_field(report, usages, parser->global.report_count)) == NULL) 233 if ((field = hid_register_field(report, usages, parser->global.report_count)) == NULL)
234 return 0; 234 return 0;
235 235
236 field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); 236 field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL);
237 field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL); 237 field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL);
238 field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); 238 field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION);
239 239
240 for (i = 0; i < usages; i++) { 240 for (i = 0; i < usages; i++) {
241 int j = i; 241 int j = i;
242 /* Duplicate the last usage we parsed if we have excess values */ 242 /* Duplicate the last usage we parsed if we have excess values */
243 if (i >= parser->local.usage_index) 243 if (i >= parser->local.usage_index)
244 j = parser->local.usage_index - 1; 244 j = parser->local.usage_index - 1;
245 field->usage[i].hid = parser->local.usage[j]; 245 field->usage[i].hid = parser->local.usage[j];
246 field->usage[i].collection_index = 246 field->usage[i].collection_index =
247 parser->local.collection_index[j]; 247 parser->local.collection_index[j];
248 } 248 }
249 249
250 field->maxusage = usages; 250 field->maxusage = usages;
251 field->flags = flags; 251 field->flags = flags;
252 field->report_offset = offset; 252 field->report_offset = offset;
253 field->report_type = report_type; 253 field->report_type = report_type;
254 field->report_size = parser->global.report_size; 254 field->report_size = parser->global.report_size;
255 field->report_count = parser->global.report_count; 255 field->report_count = parser->global.report_count;
256 field->logical_minimum = parser->global.logical_minimum; 256 field->logical_minimum = parser->global.logical_minimum;
257 field->logical_maximum = parser->global.logical_maximum; 257 field->logical_maximum = parser->global.logical_maximum;
258 field->physical_minimum = parser->global.physical_minimum; 258 field->physical_minimum = parser->global.physical_minimum;
259 field->physical_maximum = parser->global.physical_maximum; 259 field->physical_maximum = parser->global.physical_maximum;
260 field->unit_exponent = parser->global.unit_exponent; 260 field->unit_exponent = parser->global.unit_exponent;
261 field->unit = parser->global.unit; 261 field->unit = parser->global.unit;
262 262
263 return 0; 263 return 0;
264 } 264 }
265 265
266 /* 266 /*
267 * Read data value from item. 267 * Read data value from item.
268 */ 268 */
269 269
270 static u32 item_udata(struct hid_item *item) 270 static u32 item_udata(struct hid_item *item)
271 { 271 {
272 switch (item->size) { 272 switch (item->size) {
273 case 1: return item->data.u8; 273 case 1: return item->data.u8;
274 case 2: return item->data.u16; 274 case 2: return item->data.u16;
275 case 4: return item->data.u32; 275 case 4: return item->data.u32;
276 } 276 }
277 return 0; 277 return 0;
278 } 278 }
279 279
280 static s32 item_sdata(struct hid_item *item) 280 static s32 item_sdata(struct hid_item *item)
281 { 281 {
282 switch (item->size) { 282 switch (item->size) {
283 case 1: return item->data.s8; 283 case 1: return item->data.s8;
284 case 2: return item->data.s16; 284 case 2: return item->data.s16;
285 case 4: return item->data.s32; 285 case 4: return item->data.s32;
286 } 286 }
287 return 0; 287 return 0;
288 } 288 }
289 289
290 /* 290 /*
291 * Process a global item. 291 * Process a global item.
292 */ 292 */
293 293
294 static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) 294 static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
295 { 295 {
296 switch (item->tag) { 296 switch (item->tag) {
297 case HID_GLOBAL_ITEM_TAG_PUSH: 297 case HID_GLOBAL_ITEM_TAG_PUSH:
298 298
299 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { 299 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) {
300 dbg_hid("global enviroment stack overflow\n"); 300 dbg_hid("global enviroment stack overflow\n");
301 return -1; 301 return -1;
302 } 302 }
303 303
304 memcpy(parser->global_stack + parser->global_stack_ptr++, 304 memcpy(parser->global_stack + parser->global_stack_ptr++,
305 &parser->global, sizeof(struct hid_global)); 305 &parser->global, sizeof(struct hid_global));
306 return 0; 306 return 0;
307 307
308 case HID_GLOBAL_ITEM_TAG_POP: 308 case HID_GLOBAL_ITEM_TAG_POP:
309 309
310 if (!parser->global_stack_ptr) { 310 if (!parser->global_stack_ptr) {
311 dbg_hid("global enviroment stack underflow\n"); 311 dbg_hid("global enviroment stack underflow\n");
312 return -1; 312 return -1;
313 } 313 }
314 314
315 memcpy(&parser->global, parser->global_stack + 315 memcpy(&parser->global, parser->global_stack +
316 --parser->global_stack_ptr, sizeof(struct hid_global)); 316 --parser->global_stack_ptr, sizeof(struct hid_global));
317 return 0; 317 return 0;
318 318
319 case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: 319 case HID_GLOBAL_ITEM_TAG_USAGE_PAGE:
320 parser->global.usage_page = item_udata(item); 320 parser->global.usage_page = item_udata(item);
321 return 0; 321 return 0;
322 322
323 case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: 323 case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM:
324 parser->global.logical_minimum = item_sdata(item); 324 parser->global.logical_minimum = item_sdata(item);
325 return 0; 325 return 0;
326 326
327 case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: 327 case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM:
328 if (parser->global.logical_minimum < 0) 328 if (parser->global.logical_minimum < 0)
329 parser->global.logical_maximum = item_sdata(item); 329 parser->global.logical_maximum = item_sdata(item);
330 else 330 else
331 parser->global.logical_maximum = item_udata(item); 331 parser->global.logical_maximum = item_udata(item);
332 return 0; 332 return 0;
333 333
334 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: 334 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM:
335 parser->global.physical_minimum = item_sdata(item); 335 parser->global.physical_minimum = item_sdata(item);
336 return 0; 336 return 0;
337 337
338 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: 338 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM:
339 if (parser->global.physical_minimum < 0) 339 if (parser->global.physical_minimum < 0)
340 parser->global.physical_maximum = item_sdata(item); 340 parser->global.physical_maximum = item_sdata(item);
341 else 341 else
342 parser->global.physical_maximum = item_udata(item); 342 parser->global.physical_maximum = item_udata(item);
343 return 0; 343 return 0;
344 344
345 case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: 345 case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT:
346 parser->global.unit_exponent = item_sdata(item); 346 parser->global.unit_exponent = item_sdata(item);
347 return 0; 347 return 0;
348 348
349 case HID_GLOBAL_ITEM_TAG_UNIT: 349 case HID_GLOBAL_ITEM_TAG_UNIT:
350 parser->global.unit = item_udata(item); 350 parser->global.unit = item_udata(item);
351 return 0; 351 return 0;
352 352
353 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: 353 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
354 parser->global.report_size = item_udata(item); 354 parser->global.report_size = item_udata(item);
355 if (parser->global.report_size > 32) { 355 if (parser->global.report_size > 32) {
356 dbg_hid("invalid report_size %d\n", 356 dbg_hid("invalid report_size %d\n",
357 parser->global.report_size); 357 parser->global.report_size);
358 return -1; 358 return -1;
359 } 359 }
360 return 0; 360 return 0;
361 361
362 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: 362 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT:
363 parser->global.report_count = item_udata(item); 363 parser->global.report_count = item_udata(item);
364 if (parser->global.report_count > HID_MAX_USAGES) { 364 if (parser->global.report_count > HID_MAX_USAGES) {
365 dbg_hid("invalid report_count %d\n", 365 dbg_hid("invalid report_count %d\n",
366 parser->global.report_count); 366 parser->global.report_count);
367 return -1; 367 return -1;
368 } 368 }
369 return 0; 369 return 0;
370 370
371 case HID_GLOBAL_ITEM_TAG_REPORT_ID: 371 case HID_GLOBAL_ITEM_TAG_REPORT_ID:
372 parser->global.report_id = item_udata(item); 372 parser->global.report_id = item_udata(item);
373 if (parser->global.report_id == 0) { 373 if (parser->global.report_id == 0) {
374 dbg_hid("report_id 0 is invalid\n"); 374 dbg_hid("report_id 0 is invalid\n");
375 return -1; 375 return -1;
376 } 376 }
377 return 0; 377 return 0;
378 378
379 default: 379 default:
380 dbg_hid("unknown global tag 0x%x\n", item->tag); 380 dbg_hid("unknown global tag 0x%x\n", item->tag);
381 return -1; 381 return -1;
382 } 382 }
383 } 383 }
384 384
385 /* 385 /*
386 * Process a local item. 386 * Process a local item.
387 */ 387 */
388 388
389 static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) 389 static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
390 { 390 {
391 __u32 data; 391 __u32 data;
392 unsigned n; 392 unsigned n;
393 393
394 if (item->size == 0) { 394 if (item->size == 0) {
395 dbg_hid("item data expected for local item\n"); 395 dbg_hid("item data expected for local item\n");
396 return -1; 396 return -1;
397 } 397 }
398 398
399 data = item_udata(item); 399 data = item_udata(item);
400 400
401 switch (item->tag) { 401 switch (item->tag) {
402 case HID_LOCAL_ITEM_TAG_DELIMITER: 402 case HID_LOCAL_ITEM_TAG_DELIMITER:
403 403
404 if (data) { 404 if (data) {
405 /* 405 /*
406 * We treat items before the first delimiter 406 * We treat items before the first delimiter
407 * as global to all usage sets (branch 0). 407 * as global to all usage sets (branch 0).
408 * In the moment we process only these global 408 * In the moment we process only these global
409 * items and the first delimiter set. 409 * items and the first delimiter set.
410 */ 410 */
411 if (parser->local.delimiter_depth != 0) { 411 if (parser->local.delimiter_depth != 0) {
412 dbg_hid("nested delimiters\n"); 412 dbg_hid("nested delimiters\n");
413 return -1; 413 return -1;
414 } 414 }
415 parser->local.delimiter_depth++; 415 parser->local.delimiter_depth++;
416 parser->local.delimiter_branch++; 416 parser->local.delimiter_branch++;
417 } else { 417 } else {
418 if (parser->local.delimiter_depth < 1) { 418 if (parser->local.delimiter_depth < 1) {
419 dbg_hid("bogus close delimiter\n"); 419 dbg_hid("bogus close delimiter\n");
420 return -1; 420 return -1;
421 } 421 }
422 parser->local.delimiter_depth--; 422 parser->local.delimiter_depth--;
423 } 423 }
424 return 1; 424 return 1;
425 425
426 case HID_LOCAL_ITEM_TAG_USAGE: 426 case HID_LOCAL_ITEM_TAG_USAGE:
427 427
428 if (parser->local.delimiter_branch > 1) { 428 if (parser->local.delimiter_branch > 1) {
429 dbg_hid("alternative usage ignored\n"); 429 dbg_hid("alternative usage ignored\n");
430 return 0; 430 return 0;
431 } 431 }
432 432
433 if (item->size <= 2) 433 if (item->size <= 2)
434 data = (parser->global.usage_page << 16) + data; 434 data = (parser->global.usage_page << 16) + data;
435 435
436 return hid_add_usage(parser, data); 436 return hid_add_usage(parser, data);
437 437
438 case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: 438 case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
439 439
440 if (parser->local.delimiter_branch > 1) { 440 if (parser->local.delimiter_branch > 1) {
441 dbg_hid("alternative usage ignored\n"); 441 dbg_hid("alternative usage ignored\n");
442 return 0; 442 return 0;
443 } 443 }
444 444
445 if (item->size <= 2) 445 if (item->size <= 2)
446 data = (parser->global.usage_page << 16) + data; 446 data = (parser->global.usage_page << 16) + data;
447 447
448 parser->local.usage_minimum = data; 448 parser->local.usage_minimum = data;
449 return 0; 449 return 0;
450 450
451 case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: 451 case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
452 452
453 if (parser->local.delimiter_branch > 1) { 453 if (parser->local.delimiter_branch > 1) {
454 dbg_hid("alternative usage ignored\n"); 454 dbg_hid("alternative usage ignored\n");
455 return 0; 455 return 0;
456 } 456 }
457 457
458 if (item->size <= 2) 458 if (item->size <= 2)
459 data = (parser->global.usage_page << 16) + data; 459 data = (parser->global.usage_page << 16) + data;
460 460
461 for (n = parser->local.usage_minimum; n <= data; n++) 461 for (n = parser->local.usage_minimum; n <= data; n++)
462 if (hid_add_usage(parser, n)) { 462 if (hid_add_usage(parser, n)) {
463 dbg_hid("hid_add_usage failed\n"); 463 dbg_hid("hid_add_usage failed\n");
464 return -1; 464 return -1;
465 } 465 }
466 return 0; 466 return 0;
467 467
468 default: 468 default:
469 469
470 dbg_hid("unknown local item tag 0x%x\n", item->tag); 470 dbg_hid("unknown local item tag 0x%x\n", item->tag);
471 return 0; 471 return 0;
472 } 472 }
473 return 0; 473 return 0;
474 } 474 }
475 475
476 /* 476 /*
477 * Process a main item. 477 * Process a main item.
478 */ 478 */
479 479
480 static int hid_parser_main(struct hid_parser *parser, struct hid_item *item) 480 static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
481 { 481 {
482 __u32 data; 482 __u32 data;
483 int ret; 483 int ret;
484 484
485 data = item_udata(item); 485 data = item_udata(item);
486 486
487 switch (item->tag) { 487 switch (item->tag) {
488 case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: 488 case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION:
489 ret = open_collection(parser, data & 0xff); 489 ret = open_collection(parser, data & 0xff);
490 break; 490 break;
491 case HID_MAIN_ITEM_TAG_END_COLLECTION: 491 case HID_MAIN_ITEM_TAG_END_COLLECTION:
492 ret = close_collection(parser); 492 ret = close_collection(parser);
493 break; 493 break;
494 case HID_MAIN_ITEM_TAG_INPUT: 494 case HID_MAIN_ITEM_TAG_INPUT:
495 ret = hid_add_field(parser, HID_INPUT_REPORT, data); 495 ret = hid_add_field(parser, HID_INPUT_REPORT, data);
496 break; 496 break;
497 case HID_MAIN_ITEM_TAG_OUTPUT: 497 case HID_MAIN_ITEM_TAG_OUTPUT:
498 ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); 498 ret = hid_add_field(parser, HID_OUTPUT_REPORT, data);
499 break; 499 break;
500 case HID_MAIN_ITEM_TAG_FEATURE: 500 case HID_MAIN_ITEM_TAG_FEATURE:
501 ret = hid_add_field(parser, HID_FEATURE_REPORT, data); 501 ret = hid_add_field(parser, HID_FEATURE_REPORT, data);
502 break; 502 break;
503 default: 503 default:
504 dbg_hid("unknown main item tag 0x%x\n", item->tag); 504 dbg_hid("unknown main item tag 0x%x\n", item->tag);
505 ret = 0; 505 ret = 0;
506 } 506 }
507 507
508 memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ 508 memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */
509 509
510 return ret; 510 return ret;
511 } 511 }
512 512
513 /* 513 /*
514 * Process a reserved item. 514 * Process a reserved item.
515 */ 515 */
516 516
517 static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) 517 static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item)
518 { 518 {
519 dbg_hid("reserved item type, tag 0x%x\n", item->tag); 519 dbg_hid("reserved item type, tag 0x%x\n", item->tag);
520 return 0; 520 return 0;
521 } 521 }
522 522
523 /* 523 /*
524 * Free a report and all registered fields. The field->usage and 524 * Free a report and all registered fields. The field->usage and
525 * field->value table's are allocated behind the field, so we need 525 * field->value table's are allocated behind the field, so we need
526 * only to free(field) itself. 526 * only to free(field) itself.
527 */ 527 */
528 528
529 static void hid_free_report(struct hid_report *report) 529 static void hid_free_report(struct hid_report *report)
530 { 530 {
531 unsigned n; 531 unsigned n;
532 532
533 for (n = 0; n < report->maxfield; n++) 533 for (n = 0; n < report->maxfield; n++)
534 kfree(report->field[n]); 534 kfree(report->field[n]);
535 kfree(report); 535 kfree(report);
536 } 536 }
537 537
538 /* 538 /*
539 * Free a device structure, all reports, and all fields. 539 * Free a device structure, all reports, and all fields.
540 */ 540 */
541 541
542 static void hid_device_release(struct device *dev) 542 static void hid_device_release(struct device *dev)
543 { 543 {
544 struct hid_device *device = container_of(dev, struct hid_device, dev); 544 struct hid_device *device = container_of(dev, struct hid_device, dev);
545 unsigned i, j; 545 unsigned i, j;
546 546
547 for (i = 0; i < HID_REPORT_TYPES; i++) { 547 for (i = 0; i < HID_REPORT_TYPES; i++) {
548 struct hid_report_enum *report_enum = device->report_enum + i; 548 struct hid_report_enum *report_enum = device->report_enum + i;
549 549
550 for (j = 0; j < 256; j++) { 550 for (j = 0; j < 256; j++) {
551 struct hid_report *report = report_enum->report_id_hash[j]; 551 struct hid_report *report = report_enum->report_id_hash[j];
552 if (report) 552 if (report)
553 hid_free_report(report); 553 hid_free_report(report);
554 } 554 }
555 } 555 }
556 556
557 kfree(device->rdesc); 557 kfree(device->rdesc);
558 kfree(device->collection); 558 kfree(device->collection);
559 kfree(device); 559 kfree(device);
560 } 560 }
561 561
562 /* 562 /*
563 * Fetch a report description item from the data stream. We support long 563 * Fetch a report description item from the data stream. We support long
564 * items, though they are not used yet. 564 * items, though they are not used yet.
565 */ 565 */
566 566
567 static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) 567 static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
568 { 568 {
569 u8 b; 569 u8 b;
570 570
571 if ((end - start) <= 0) 571 if ((end - start) <= 0)
572 return NULL; 572 return NULL;
573 573
574 b = *start++; 574 b = *start++;
575 575
576 item->type = (b >> 2) & 3; 576 item->type = (b >> 2) & 3;
577 item->tag = (b >> 4) & 15; 577 item->tag = (b >> 4) & 15;
578 578
579 if (item->tag == HID_ITEM_TAG_LONG) { 579 if (item->tag == HID_ITEM_TAG_LONG) {
580 580
581 item->format = HID_ITEM_FORMAT_LONG; 581 item->format = HID_ITEM_FORMAT_LONG;
582 582
583 if ((end - start) < 2) 583 if ((end - start) < 2)
584 return NULL; 584 return NULL;
585 585
586 item->size = *start++; 586 item->size = *start++;
587 item->tag = *start++; 587 item->tag = *start++;
588 588
589 if ((end - start) < item->size) 589 if ((end - start) < item->size)
590 return NULL; 590 return NULL;
591 591
592 item->data.longdata = start; 592 item->data.longdata = start;
593 start += item->size; 593 start += item->size;
594 return start; 594 return start;
595 } 595 }
596 596
597 item->format = HID_ITEM_FORMAT_SHORT; 597 item->format = HID_ITEM_FORMAT_SHORT;
598 item->size = b & 3; 598 item->size = b & 3;
599 599
600 switch (item->size) { 600 switch (item->size) {
601 case 0: 601 case 0:
602 return start; 602 return start;
603 603
604 case 1: 604 case 1:
605 if ((end - start) < 1) 605 if ((end - start) < 1)
606 return NULL; 606 return NULL;
607 item->data.u8 = *start++; 607 item->data.u8 = *start++;
608 return start; 608 return start;
609 609
610 case 2: 610 case 2:
611 if ((end - start) < 2) 611 if ((end - start) < 2)
612 return NULL; 612 return NULL;
613 item->data.u16 = get_unaligned_le16(start); 613 item->data.u16 = get_unaligned_le16(start);
614 start = (__u8 *)((__le16 *)start + 1); 614 start = (__u8 *)((__le16 *)start + 1);
615 return start; 615 return start;
616 616
617 case 3: 617 case 3:
618 item->size++; 618 item->size++;
619 if ((end - start) < 4) 619 if ((end - start) < 4)
620 return NULL; 620 return NULL;
621 item->data.u32 = get_unaligned_le32(start); 621 item->data.u32 = get_unaligned_le32(start);
622 start = (__u8 *)((__le32 *)start + 1); 622 start = (__u8 *)((__le32 *)start + 1);
623 return start; 623 return start;
624 } 624 }
625 625
626 return NULL; 626 return NULL;
627 } 627 }
628 628
629 /** 629 /**
630 * hid_parse_report - parse device report 630 * hid_parse_report - parse device report
631 * 631 *
632 * @device: hid device 632 * @device: hid device
633 * @start: report start 633 * @start: report start
634 * @size: report size 634 * @size: report size
635 * 635 *
636 * Parse a report description into a hid_device structure. Reports are 636 * Parse a report description into a hid_device structure. Reports are
637 * enumerated, fields are attached to these reports. 637 * enumerated, fields are attached to these reports.
638 * 0 returned on success, otherwise nonzero error value. 638 * 0 returned on success, otherwise nonzero error value.
639 */ 639 */
640 int hid_parse_report(struct hid_device *device, __u8 *start, 640 int hid_parse_report(struct hid_device *device, __u8 *start,
641 unsigned size) 641 unsigned size)
642 { 642 {
643 struct hid_parser *parser; 643 struct hid_parser *parser;
644 struct hid_item item; 644 struct hid_item item;
645 __u8 *end; 645 __u8 *end;
646 int ret; 646 int ret;
647 static int (*dispatch_type[])(struct hid_parser *parser, 647 static int (*dispatch_type[])(struct hid_parser *parser,
648 struct hid_item *item) = { 648 struct hid_item *item) = {
649 hid_parser_main, 649 hid_parser_main,
650 hid_parser_global, 650 hid_parser_global,
651 hid_parser_local, 651 hid_parser_local,
652 hid_parser_reserved 652 hid_parser_reserved
653 }; 653 };
654 654
655 if (device->driver->report_fixup) 655 if (device->driver->report_fixup)
656 device->driver->report_fixup(device, start, size); 656 device->driver->report_fixup(device, start, size);
657 657
658 device->rdesc = kmalloc(size, GFP_KERNEL); 658 device->rdesc = kmalloc(size, GFP_KERNEL);
659 if (device->rdesc == NULL) 659 if (device->rdesc == NULL)
660 return -ENOMEM; 660 return -ENOMEM;
661 memcpy(device->rdesc, start, size); 661 memcpy(device->rdesc, start, size);
662 device->rsize = size; 662 device->rsize = size;
663 663
664 parser = vmalloc(sizeof(struct hid_parser)); 664 parser = vmalloc(sizeof(struct hid_parser));
665 if (!parser) { 665 if (!parser) {
666 ret = -ENOMEM; 666 ret = -ENOMEM;
667 goto err; 667 goto err;
668 } 668 }
669 669
670 memset(parser, 0, sizeof(struct hid_parser)); 670 memset(parser, 0, sizeof(struct hid_parser));
671 parser->device = device; 671 parser->device = device;
672 672
673 end = start + size; 673 end = start + size;
674 ret = -EINVAL; 674 ret = -EINVAL;
675 while ((start = fetch_item(start, end, &item)) != NULL) { 675 while ((start = fetch_item(start, end, &item)) != NULL) {
676 676
677 if (item.format != HID_ITEM_FORMAT_SHORT) { 677 if (item.format != HID_ITEM_FORMAT_SHORT) {
678 dbg_hid("unexpected long global item\n"); 678 dbg_hid("unexpected long global item\n");
679 goto err; 679 goto err;
680 } 680 }
681 681
682 if (dispatch_type[item.type](parser, &item)) { 682 if (dispatch_type[item.type](parser, &item)) {
683 dbg_hid("item %u %u %u %u parsing failed\n", 683 dbg_hid("item %u %u %u %u parsing failed\n",
684 item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag); 684 item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag);
685 goto err; 685 goto err;
686 } 686 }
687 687
688 if (start == end) { 688 if (start == end) {
689 if (parser->collection_stack_ptr) { 689 if (parser->collection_stack_ptr) {
690 dbg_hid("unbalanced collection at end of report description\n"); 690 dbg_hid("unbalanced collection at end of report description\n");
691 goto err; 691 goto err;
692 } 692 }
693 if (parser->local.delimiter_depth) { 693 if (parser->local.delimiter_depth) {
694 dbg_hid("unbalanced delimiter at end of report description\n"); 694 dbg_hid("unbalanced delimiter at end of report description\n");
695 goto err; 695 goto err;
696 } 696 }
697 vfree(parser); 697 vfree(parser);
698 return 0; 698 return 0;
699 } 699 }
700 } 700 }
701 701
702 dbg_hid("item fetching failed at offset %d\n", (int)(end - start)); 702 dbg_hid("item fetching failed at offset %d\n", (int)(end - start));
703 err: 703 err:
704 vfree(parser); 704 vfree(parser);
705 return ret; 705 return ret;
706 } 706 }
707 EXPORT_SYMBOL_GPL(hid_parse_report); 707 EXPORT_SYMBOL_GPL(hid_parse_report);
708 708
709 /* 709 /*
710 * Convert a signed n-bit integer to signed 32-bit integer. Common 710 * Convert a signed n-bit integer to signed 32-bit integer. Common
711 * cases are done through the compiler, the screwed things has to be 711 * cases are done through the compiler, the screwed things has to be
712 * done by hand. 712 * done by hand.
713 */ 713 */
714 714
715 static s32 snto32(__u32 value, unsigned n) 715 static s32 snto32(__u32 value, unsigned n)
716 { 716 {
717 switch (n) { 717 switch (n) {
718 case 8: return ((__s8)value); 718 case 8: return ((__s8)value);
719 case 16: return ((__s16)value); 719 case 16: return ((__s16)value);
720 case 32: return ((__s32)value); 720 case 32: return ((__s32)value);
721 } 721 }
722 return value & (1 << (n - 1)) ? value | (-1 << n) : value; 722 return value & (1 << (n - 1)) ? value | (-1 << n) : value;
723 } 723 }
724 724
725 /* 725 /*
726 * Convert a signed 32-bit integer to a signed n-bit integer. 726 * Convert a signed 32-bit integer to a signed n-bit integer.
727 */ 727 */
728 728
729 static u32 s32ton(__s32 value, unsigned n) 729 static u32 s32ton(__s32 value, unsigned n)
730 { 730 {
731 s32 a = value >> (n - 1); 731 s32 a = value >> (n - 1);
732 if (a && a != -1) 732 if (a && a != -1)
733 return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; 733 return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
734 return value & ((1 << n) - 1); 734 return value & ((1 << n) - 1);
735 } 735 }
736 736
737 /* 737 /*
738 * Extract/implement a data field from/to a little endian report (bit array). 738 * Extract/implement a data field from/to a little endian report (bit array).
739 * 739 *
740 * Code sort-of follows HID spec: 740 * Code sort-of follows HID spec:
741 * http://www.usb.org/developers/devclass_docs/HID1_11.pdf 741 * http://www.usb.org/developers/devclass_docs/HID1_11.pdf
742 * 742 *
743 * While the USB HID spec allows unlimited length bit fields in "report 743 * While the USB HID spec allows unlimited length bit fields in "report
744 * descriptors", most devices never use more than 16 bits. 744 * descriptors", most devices never use more than 16 bits.
745 * One model of UPS is claimed to report "LINEV" as a 32-bit field. 745 * One model of UPS is claimed to report "LINEV" as a 32-bit field.
746 * Search linux-kernel and linux-usb-devel archives for "hid-core extract". 746 * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
747 */ 747 */
748 748
749 static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) 749 static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
750 { 750 {
751 u64 x; 751 u64 x;
752 752
753 if (n > 32) 753 if (n > 32)
754 printk(KERN_WARNING "HID: extract() called with n (%d) > 32! (%s)\n", 754 printk(KERN_WARNING "HID: extract() called with n (%d) > 32! (%s)\n",
755 n, current->comm); 755 n, current->comm);
756 756
757 report += offset >> 3; /* adjust byte index */ 757 report += offset >> 3; /* adjust byte index */
758 offset &= 7; /* now only need bit offset into one byte */ 758 offset &= 7; /* now only need bit offset into one byte */
759 x = get_unaligned_le64(report); 759 x = get_unaligned_le64(report);
760 x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ 760 x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */
761 return (u32) x; 761 return (u32) x;
762 } 762 }
763 763
764 /* 764 /*
765 * "implement" : set bits in a little endian bit stream. 765 * "implement" : set bits in a little endian bit stream.
766 * Same concepts as "extract" (see comments above). 766 * Same concepts as "extract" (see comments above).
767 * The data mangled in the bit stream remains in little endian 767 * The data mangled in the bit stream remains in little endian
768 * order the whole time. It make more sense to talk about 768 * order the whole time. It make more sense to talk about
769 * endianness of register values by considering a register 769 * endianness of register values by considering a register
770 * a "cached" copy of the little endiad bit stream. 770 * a "cached" copy of the little endiad bit stream.
771 */ 771 */
772 static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) 772 static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value)
773 { 773 {
774 u64 x; 774 u64 x;
775 u64 m = (1ULL << n) - 1; 775 u64 m = (1ULL << n) - 1;
776 776
777 if (n > 32) 777 if (n > 32)
778 printk(KERN_WARNING "HID: implement() called with n (%d) > 32! (%s)\n", 778 printk(KERN_WARNING "HID: implement() called with n (%d) > 32! (%s)\n",
779 n, current->comm); 779 n, current->comm);
780 780
781 if (value > m) 781 if (value > m)
782 printk(KERN_WARNING "HID: implement() called with too large value %d! (%s)\n", 782 printk(KERN_WARNING "HID: implement() called with too large value %d! (%s)\n",
783 value, current->comm); 783 value, current->comm);
784 WARN_ON(value > m); 784 WARN_ON(value > m);
785 value &= m; 785 value &= m;
786 786
787 report += offset >> 3; 787 report += offset >> 3;
788 offset &= 7; 788 offset &= 7;
789 789
790 x = get_unaligned_le64(report); 790 x = get_unaligned_le64(report);
791 x &= ~(m << offset); 791 x &= ~(m << offset);
792 x |= ((u64)value) << offset; 792 x |= ((u64)value) << offset;
793 put_unaligned_le64(x, report); 793 put_unaligned_le64(x, report);
794 } 794 }
795 795
796 /* 796 /*
797 * Search an array for a value. 797 * Search an array for a value.
798 */ 798 */
799 799
800 static __inline__ int search(__s32 *array, __s32 value, unsigned n) 800 static __inline__ int search(__s32 *array, __s32 value, unsigned n)
801 { 801 {
802 while (n--) { 802 while (n--) {
803 if (*array++ == value) 803 if (*array++ == value)
804 return 0; 804 return 0;
805 } 805 }
806 return -1; 806 return -1;
807 } 807 }
808 808
809 /** 809 /**
810 * hid_match_report - check if driver's raw_event should be called 810 * hid_match_report - check if driver's raw_event should be called
811 * 811 *
812 * @hid: hid device 812 * @hid: hid device
813 * @report_type: type to match against 813 * @report_type: type to match against
814 * 814 *
815 * compare hid->driver->report_table->report_type to report->type 815 * compare hid->driver->report_table->report_type to report->type
816 */ 816 */
817 static int hid_match_report(struct hid_device *hid, struct hid_report *report) 817 static int hid_match_report(struct hid_device *hid, struct hid_report *report)
818 { 818 {
819 const struct hid_report_id *id = hid->driver->report_table; 819 const struct hid_report_id *id = hid->driver->report_table;
820 820
821 if (!id) /* NULL means all */ 821 if (!id) /* NULL means all */
822 return 1; 822 return 1;
823 823
824 for (; id->report_type != HID_TERMINATOR; id++) 824 for (; id->report_type != HID_TERMINATOR; id++)
825 if (id->report_type == HID_ANY_ID || 825 if (id->report_type == HID_ANY_ID ||
826 id->report_type == report->type) 826 id->report_type == report->type)
827 return 1; 827 return 1;
828 return 0; 828 return 0;
829 } 829 }
830 830
831 /** 831 /**
832 * hid_match_usage - check if driver's event should be called 832 * hid_match_usage - check if driver's event should be called
833 * 833 *
834 * @hid: hid device 834 * @hid: hid device
835 * @usage: usage to match against 835 * @usage: usage to match against
836 * 836 *
837 * compare hid->driver->usage_table->usage_{type,code} to 837 * compare hid->driver->usage_table->usage_{type,code} to
838 * usage->usage_{type,code} 838 * usage->usage_{type,code}
839 */ 839 */
840 static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage) 840 static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage)
841 { 841 {
842 const struct hid_usage_id *id = hid->driver->usage_table; 842 const struct hid_usage_id *id = hid->driver->usage_table;
843 843
844 if (!id) /* NULL means all */ 844 if (!id) /* NULL means all */
845 return 1; 845 return 1;
846 846
847 for (; id->usage_type != HID_ANY_ID - 1; id++) 847 for (; id->usage_type != HID_ANY_ID - 1; id++)
848 if ((id->usage_hid == HID_ANY_ID || 848 if ((id->usage_hid == HID_ANY_ID ||
849 id->usage_hid == usage->hid) && 849 id->usage_hid == usage->hid) &&
850 (id->usage_type == HID_ANY_ID || 850 (id->usage_type == HID_ANY_ID ||
851 id->usage_type == usage->type) && 851 id->usage_type == usage->type) &&
852 (id->usage_code == HID_ANY_ID || 852 (id->usage_code == HID_ANY_ID ||
853 id->usage_code == usage->code)) 853 id->usage_code == usage->code))
854 return 1; 854 return 1;
855 return 0; 855 return 0;
856 } 856 }
857 857
858 static void hid_process_event(struct hid_device *hid, struct hid_field *field, 858 static void hid_process_event(struct hid_device *hid, struct hid_field *field,
859 struct hid_usage *usage, __s32 value, int interrupt) 859 struct hid_usage *usage, __s32 value, int interrupt)
860 { 860 {
861 struct hid_driver *hdrv = hid->driver; 861 struct hid_driver *hdrv = hid->driver;
862 int ret; 862 int ret;
863 863
864 hid_dump_input(usage, value); 864 hid_dump_input(usage, value);
865 865
866 if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { 866 if (hdrv && hdrv->event && hid_match_usage(hid, usage)) {
867 ret = hdrv->event(hid, field, usage, value); 867 ret = hdrv->event(hid, field, usage, value);
868 if (ret != 0) { 868 if (ret != 0) {
869 if (ret < 0) 869 if (ret < 0)
870 dbg_hid("%s's event failed with %d\n", 870 dbg_hid("%s's event failed with %d\n",
871 hdrv->name, ret); 871 hdrv->name, ret);
872 return; 872 return;
873 } 873 }
874 } 874 }
875 875
876 if (hid->claimed & HID_CLAIMED_INPUT) 876 if (hid->claimed & HID_CLAIMED_INPUT)
877 hidinput_hid_event(hid, field, usage, value); 877 hidinput_hid_event(hid, field, usage, value);
878 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) 878 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event)
879 hid->hiddev_hid_event(hid, field, usage, value); 879 hid->hiddev_hid_event(hid, field, usage, value);
880 } 880 }
881 881
882 /* 882 /*
883 * Analyse a received field, and fetch the data from it. The field 883 * Analyse a received field, and fetch the data from it. The field
884 * content is stored for next report processing (we do differential 884 * content is stored for next report processing (we do differential
885 * reporting to the layer). 885 * reporting to the layer).
886 */ 886 */
887 887
888 static void hid_input_field(struct hid_device *hid, struct hid_field *field, 888 static void hid_input_field(struct hid_device *hid, struct hid_field *field,
889 __u8 *data, int interrupt) 889 __u8 *data, int interrupt)
890 { 890 {
891 unsigned n; 891 unsigned n;
892 unsigned count = field->report_count; 892 unsigned count = field->report_count;
893 unsigned offset = field->report_offset; 893 unsigned offset = field->report_offset;
894 unsigned size = field->report_size; 894 unsigned size = field->report_size;
895 __s32 min = field->logical_minimum; 895 __s32 min = field->logical_minimum;
896 __s32 max = field->logical_maximum; 896 __s32 max = field->logical_maximum;
897 __s32 *value; 897 __s32 *value;
898 898
899 if (!(value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC))) 899 if (!(value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC)))
900 return; 900 return;
901 901
902 for (n = 0; n < count; n++) { 902 for (n = 0; n < count; n++) {
903 903
904 value[n] = min < 0 ? snto32(extract(data, offset + n * size, size), size) : 904 value[n] = min < 0 ? snto32(extract(data, offset + n * size, size), size) :
905 extract(data, offset + n * size, size); 905 extract(data, offset + n * size, size);
906 906
907 if (!(field->flags & HID_MAIN_ITEM_VARIABLE) /* Ignore report if ErrorRollOver */ 907 if (!(field->flags & HID_MAIN_ITEM_VARIABLE) /* Ignore report if ErrorRollOver */
908 && value[n] >= min && value[n] <= max 908 && value[n] >= min && value[n] <= max
909 && field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) 909 && field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1)
910 goto exit; 910 goto exit;
911 } 911 }
912 912
913 for (n = 0; n < count; n++) { 913 for (n = 0; n < count; n++) {
914 914
915 if (HID_MAIN_ITEM_VARIABLE & field->flags) { 915 if (HID_MAIN_ITEM_VARIABLE & field->flags) {
916 hid_process_event(hid, field, &field->usage[n], value[n], interrupt); 916 hid_process_event(hid, field, &field->usage[n], value[n], interrupt);
917 continue; 917 continue;
918 } 918 }
919 919
920 if (field->value[n] >= min && field->value[n] <= max 920 if (field->value[n] >= min && field->value[n] <= max
921 && field->usage[field->value[n] - min].hid 921 && field->usage[field->value[n] - min].hid
922 && search(value, field->value[n], count)) 922 && search(value, field->value[n], count))
923 hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); 923 hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt);
924 924
925 if (value[n] >= min && value[n] <= max 925 if (value[n] >= min && value[n] <= max
926 && field->usage[value[n] - min].hid 926 && field->usage[value[n] - min].hid
927 && search(field->value, value[n], count)) 927 && search(field->value, value[n], count))
928 hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); 928 hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt);
929 } 929 }
930 930
931 memcpy(field->value, value, count * sizeof(__s32)); 931 memcpy(field->value, value, count * sizeof(__s32));
932 exit: 932 exit:
933 kfree(value); 933 kfree(value);
934 } 934 }
935 935
936 /* 936 /*
937 * Output the field into the report. 937 * Output the field into the report.
938 */ 938 */
939 939
940 static void hid_output_field(struct hid_field *field, __u8 *data) 940 static void hid_output_field(struct hid_field *field, __u8 *data)
941 { 941 {
942 unsigned count = field->report_count; 942 unsigned count = field->report_count;
943 unsigned offset = field->report_offset; 943 unsigned offset = field->report_offset;
944 unsigned size = field->report_size; 944 unsigned size = field->report_size;
945 unsigned bitsused = offset + count * size; 945 unsigned bitsused = offset + count * size;
946 unsigned n; 946 unsigned n;
947 947
948 /* make sure the unused bits in the last byte are zeros */ 948 /* make sure the unused bits in the last byte are zeros */
949 if (count > 0 && size > 0 && (bitsused % 8) != 0) 949 if (count > 0 && size > 0 && (bitsused % 8) != 0)
950 data[(bitsused-1)/8] &= (1 << (bitsused % 8)) - 1; 950 data[(bitsused-1)/8] &= (1 << (bitsused % 8)) - 1;
951 951
952 for (n = 0; n < count; n++) { 952 for (n = 0; n < count; n++) {
953 if (field->logical_minimum < 0) /* signed values */ 953 if (field->logical_minimum < 0) /* signed values */
954 implement(data, offset + n * size, size, s32ton(field->value[n], size)); 954 implement(data, offset + n * size, size, s32ton(field->value[n], size));
955 else /* unsigned values */ 955 else /* unsigned values */
956 implement(data, offset + n * size, size, field->value[n]); 956 implement(data, offset + n * size, size, field->value[n]);
957 } 957 }
958 } 958 }
959 959
960 /* 960 /*
961 * Create a report. 961 * Create a report.
962 */ 962 */
963 963
964 void hid_output_report(struct hid_report *report, __u8 *data) 964 void hid_output_report(struct hid_report *report, __u8 *data)
965 { 965 {
966 unsigned n; 966 unsigned n;
967 967
968 if (report->id > 0) 968 if (report->id > 0)
969 *data++ = report->id; 969 *data++ = report->id;
970 970
971 for (n = 0; n < report->maxfield; n++) 971 for (n = 0; n < report->maxfield; n++)
972 hid_output_field(report->field[n], data); 972 hid_output_field(report->field[n], data);
973 } 973 }
974 EXPORT_SYMBOL_GPL(hid_output_report); 974 EXPORT_SYMBOL_GPL(hid_output_report);
975 975
976 /* 976 /*
977 * Set a field value. The report this field belongs to has to be 977 * Set a field value. The report this field belongs to has to be
978 * created and transferred to the device, to set this value in the 978 * created and transferred to the device, to set this value in the
979 * device. 979 * device.
980 */ 980 */
981 981
982 int hid_set_field(struct hid_field *field, unsigned offset, __s32 value) 982 int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
983 { 983 {
984 unsigned size = field->report_size; 984 unsigned size = field->report_size;
985 985
986 hid_dump_input(field->usage + offset, value); 986 hid_dump_input(field->usage + offset, value);
987 987
988 if (offset >= field->report_count) { 988 if (offset >= field->report_count) {
989 dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count); 989 dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count);
990 hid_dump_field(field, 8); 990 hid_dump_field(field, 8);
991 return -1; 991 return -1;
992 } 992 }
993 if (field->logical_minimum < 0) { 993 if (field->logical_minimum < 0) {
994 if (value != snto32(s32ton(value, size), size)) { 994 if (value != snto32(s32ton(value, size), size)) {
995 dbg_hid("value %d is out of range\n", value); 995 dbg_hid("value %d is out of range\n", value);
996 return -1; 996 return -1;
997 } 997 }
998 } 998 }
999 field->value[offset] = value; 999 field->value[offset] = value;
1000 return 0; 1000 return 0;
1001 } 1001 }
1002 EXPORT_SYMBOL_GPL(hid_set_field); 1002 EXPORT_SYMBOL_GPL(hid_set_field);
1003 1003
1004 static struct hid_report *hid_get_report(struct hid_report_enum *report_enum, 1004 static struct hid_report *hid_get_report(struct hid_report_enum *report_enum,
1005 const u8 *data) 1005 const u8 *data)
1006 { 1006 {
1007 struct hid_report *report; 1007 struct hid_report *report;
1008 unsigned int n = 0; /* Normally report number is 0 */ 1008 unsigned int n = 0; /* Normally report number is 0 */
1009 1009
1010 /* Device uses numbered reports, data[0] is report number */ 1010 /* Device uses numbered reports, data[0] is report number */
1011 if (report_enum->numbered) 1011 if (report_enum->numbered)
1012 n = *data; 1012 n = *data;
1013 1013
1014 report = report_enum->report_id_hash[n]; 1014 report = report_enum->report_id_hash[n];
1015 if (report == NULL) 1015 if (report == NULL)
1016 dbg_hid("undefined report_id %u received\n", n); 1016 dbg_hid("undefined report_id %u received\n", n);
1017 1017
1018 return report; 1018 return report;
1019 } 1019 }
1020 1020
1021 void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, 1021 void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
1022 int interrupt) 1022 int interrupt)
1023 { 1023 {
1024 struct hid_report_enum *report_enum = hid->report_enum + type; 1024 struct hid_report_enum *report_enum = hid->report_enum + type;
1025 struct hid_report *report; 1025 struct hid_report *report;
1026 unsigned int a; 1026 unsigned int a;
1027 int rsize, csize = size; 1027 int rsize, csize = size;
1028 u8 *cdata = data; 1028 u8 *cdata = data;
1029 1029
1030 report = hid_get_report(report_enum, data); 1030 report = hid_get_report(report_enum, data);
1031 if (!report) 1031 if (!report)
1032 return; 1032 return;
1033 1033
1034 if (report_enum->numbered) { 1034 if (report_enum->numbered) {
1035 cdata++; 1035 cdata++;
1036 csize--; 1036 csize--;
1037 } 1037 }
1038 1038
1039 rsize = ((report->size - 1) >> 3) + 1; 1039 rsize = ((report->size - 1) >> 3) + 1;
1040 1040
1041 if (csize < rsize) { 1041 if (csize < rsize) {
1042 dbg_hid("report %d is too short, (%d < %d)\n", report->id, 1042 dbg_hid("report %d is too short, (%d < %d)\n", report->id,
1043 csize, rsize); 1043 csize, rsize);
1044 memset(cdata + csize, 0, rsize - csize); 1044 memset(cdata + csize, 0, rsize - csize);
1045 } 1045 }
1046 1046
1047 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) 1047 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
1048 hid->hiddev_report_event(hid, report); 1048 hid->hiddev_report_event(hid, report);
1049 if (hid->claimed & HID_CLAIMED_HIDRAW) { 1049 if (hid->claimed & HID_CLAIMED_HIDRAW) {
1050 /* numbered reports need to be passed with the report num */ 1050 /* numbered reports need to be passed with the report num */
1051 if (report_enum->numbered) 1051 if (report_enum->numbered)
1052 hidraw_report_event(hid, data - 1, size + 1); 1052 hidraw_report_event(hid, data - 1, size + 1);
1053 else 1053 else
1054 hidraw_report_event(hid, data, size); 1054 hidraw_report_event(hid, data, size);
1055 } 1055 }
1056 1056
1057 for (a = 0; a < report->maxfield; a++) 1057 for (a = 0; a < report->maxfield; a++)
1058 hid_input_field(hid, report->field[a], cdata, interrupt); 1058 hid_input_field(hid, report->field[a], cdata, interrupt);
1059 1059
1060 if (hid->claimed & HID_CLAIMED_INPUT) 1060 if (hid->claimed & HID_CLAIMED_INPUT)
1061 hidinput_report_event(hid, report); 1061 hidinput_report_event(hid, report);
1062 } 1062 }
1063 EXPORT_SYMBOL_GPL(hid_report_raw_event); 1063 EXPORT_SYMBOL_GPL(hid_report_raw_event);
1064 1064
1065 /** 1065 /**
1066 * hid_input_report - report data from lower layer (usb, bt...) 1066 * hid_input_report - report data from lower layer (usb, bt...)
1067 * 1067 *
1068 * @hid: hid device 1068 * @hid: hid device
1069 * @type: HID report type (HID_*_REPORT) 1069 * @type: HID report type (HID_*_REPORT)
1070 * @data: report contents 1070 * @data: report contents
1071 * @size: size of data parameter 1071 * @size: size of data parameter
1072 * @interrupt: called from atomic? 1072 * @interrupt: called from atomic?
1073 * 1073 *
1074 * This is data entry for lower layers. 1074 * This is data entry for lower layers.
1075 */ 1075 */
1076 int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) 1076 int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt)
1077 { 1077 {
1078 struct hid_report_enum *report_enum = hid->report_enum + type; 1078 struct hid_report_enum *report_enum = hid->report_enum + type;
1079 struct hid_driver *hdrv = hid->driver; 1079 struct hid_driver *hdrv = hid->driver;
1080 struct hid_report *report; 1080 struct hid_report *report;
1081 unsigned int i; 1081 unsigned int i;
1082 int ret; 1082 int ret;
1083 1083
1084 if (!hid || !hid->driver) 1084 if (!hid || !hid->driver)
1085 return -ENODEV; 1085 return -ENODEV;
1086 1086
1087 if (!size) { 1087 if (!size) {
1088 dbg_hid("empty report\n"); 1088 dbg_hid("empty report\n");
1089 return -1; 1089 return -1;
1090 } 1090 }
1091 1091
1092 dbg_hid("report (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un"); 1092 dbg_hid("report (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un");
1093 1093
1094 report = hid_get_report(report_enum, data); 1094 report = hid_get_report(report_enum, data);
1095 if (!report) 1095 if (!report)
1096 return -1; 1096 return -1;
1097 1097
1098 /* dump the report */ 1098 /* dump the report */
1099 dbg_hid("report %d (size %u) = ", report->id, size); 1099 dbg_hid("report %d (size %u) = ", report->id, size);
1100 for (i = 0; i < size; i++) 1100 for (i = 0; i < size; i++)
1101 dbg_hid_line(" %02x", data[i]); 1101 dbg_hid_line(" %02x", data[i]);
1102 dbg_hid_line("\n"); 1102 dbg_hid_line("\n");
1103 1103
1104 if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { 1104 if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) {
1105 ret = hdrv->raw_event(hid, report, data, size); 1105 ret = hdrv->raw_event(hid, report, data, size);
1106 if (ret != 0) 1106 if (ret != 0)
1107 return ret < 0 ? ret : 0; 1107 return ret < 0 ? ret : 0;
1108 } 1108 }
1109 1109
1110 hid_report_raw_event(hid, type, data, size, interrupt); 1110 hid_report_raw_event(hid, type, data, size, interrupt);
1111 1111
1112 return 0; 1112 return 0;
1113 } 1113 }
1114 EXPORT_SYMBOL_GPL(hid_input_report); 1114 EXPORT_SYMBOL_GPL(hid_input_report);
1115 1115
1116 static bool hid_match_one_id(struct hid_device *hdev, 1116 static bool hid_match_one_id(struct hid_device *hdev,
1117 const struct hid_device_id *id) 1117 const struct hid_device_id *id)
1118 { 1118 {
1119 return id->bus == hdev->bus && 1119 return id->bus == hdev->bus &&
1120 (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && 1120 (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) &&
1121 (id->product == HID_ANY_ID || id->product == hdev->product); 1121 (id->product == HID_ANY_ID || id->product == hdev->product);
1122 } 1122 }
1123 1123
1124 static const struct hid_device_id *hid_match_id(struct hid_device *hdev, 1124 static const struct hid_device_id *hid_match_id(struct hid_device *hdev,
1125 const struct hid_device_id *id) 1125 const struct hid_device_id *id)
1126 { 1126 {
1127 for (; id->bus; id++) 1127 for (; id->bus; id++)
1128 if (hid_match_one_id(hdev, id)) 1128 if (hid_match_one_id(hdev, id))
1129 return id; 1129 return id;
1130 1130
1131 return NULL; 1131 return NULL;
1132 } 1132 }
1133 1133
1134 static const struct hid_device_id hid_blacklist[] = { 1134 static const struct hid_device_id hid_blacklist[] = {
1135 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 1135 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
1136 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1136 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
1137 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, 1137 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
1138 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, 1138 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) },
1139 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 1139 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
1140 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 1140 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
1141 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 1141 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
1142 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 1142 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) },
1143 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 1143 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) },
1144 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 1144 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) },
1145 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 1145 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) },
1146 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 1146 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) },
1147 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 1147 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) },
1148 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 1148 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) },
1149 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1149 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) },
1150 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) }, 1150 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) },
1151 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) }, 1151 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) },
1152 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) }, 1152 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) },
1153 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 1153 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) },
1154 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 1154 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) },
1155 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1155 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) },
1156 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, 1156 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) },
1157 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, 1157 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) },
1158 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, 1158 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) },
1159 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 1159 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) },
1160 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 1160 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) },
1161 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 1161 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) },
1162 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1162 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
1163 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1163 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
1164 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1164 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
1165 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1165 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1166 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1166 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1167 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1167 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
1168 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 1168 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
1169 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1169 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
1170 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 1170 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
1171 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, 1171 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) },
1172 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, 1172 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
1173 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658) },
1173 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 1174 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
1174 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, 1175 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
1175 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 1176 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
1176 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, 1177 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) },
1177 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, 1178 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) },
1178 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, 1179 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) },
1179 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, 1180 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) },
1180 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, 1181 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) },
1181 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, 1182 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) },
1182 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, 1183 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) },
1183 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD) }, 1184 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD) },
1184 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, 1185 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) },
1185 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, 1186 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) },
1186 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_LX3) }, 1187 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_LX3) },
1187 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_V150) }, 1188 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_V150) },
1188 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, 1189 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) },
1189 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) }, 1190 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) },
1190 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, 1191 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
1191 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, 1192 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) },
1192 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, 1193 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
1193 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, 1194 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) },
1194 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 1195 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
1195 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 1196 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
1196 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 1197 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
1197 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1198 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
1198 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1199 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1199 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1200 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
1200 1201
1201 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) }, 1202 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) },
1202 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, 1203 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) },
1203 { } 1204 { }
1204 }; 1205 };
1205 1206
1206 static int hid_bus_match(struct device *dev, struct device_driver *drv) 1207 static int hid_bus_match(struct device *dev, struct device_driver *drv)
1207 { 1208 {
1208 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 1209 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
1209 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1210 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1210 1211
1211 if (!hid_match_id(hdev, hdrv->id_table)) 1212 if (!hid_match_id(hdev, hdrv->id_table))
1212 return 0; 1213 return 0;
1213 1214
1214 /* generic wants all non-blacklisted */ 1215 /* generic wants all non-blacklisted */
1215 if (!strncmp(hdrv->name, "generic-", 8)) 1216 if (!strncmp(hdrv->name, "generic-", 8))
1216 return !hid_match_id(hdev, hid_blacklist); 1217 return !hid_match_id(hdev, hid_blacklist);
1217 1218
1218 return 1; 1219 return 1;
1219 } 1220 }
1220 1221
1221 static int hid_device_probe(struct device *dev) 1222 static int hid_device_probe(struct device *dev)
1222 { 1223 {
1223 struct hid_driver *hdrv = container_of(dev->driver, 1224 struct hid_driver *hdrv = container_of(dev->driver,
1224 struct hid_driver, driver); 1225 struct hid_driver, driver);
1225 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1226 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1226 const struct hid_device_id *id; 1227 const struct hid_device_id *id;
1227 int ret = 0; 1228 int ret = 0;
1228 1229
1229 if (!hdev->driver) { 1230 if (!hdev->driver) {
1230 id = hid_match_id(hdev, hdrv->id_table); 1231 id = hid_match_id(hdev, hdrv->id_table);
1231 if (id == NULL) 1232 if (id == NULL)
1232 return -ENODEV; 1233 return -ENODEV;
1233 1234
1234 hdev->driver = hdrv; 1235 hdev->driver = hdrv;
1235 if (hdrv->probe) { 1236 if (hdrv->probe) {
1236 ret = hdrv->probe(hdev, id); 1237 ret = hdrv->probe(hdev, id);
1237 } else { /* default probe */ 1238 } else { /* default probe */
1238 ret = hid_parse(hdev); 1239 ret = hid_parse(hdev);
1239 if (!ret) 1240 if (!ret)
1240 ret = hid_hw_start(hdev); 1241 ret = hid_hw_start(hdev);
1241 } 1242 }
1242 if (ret) 1243 if (ret)
1243 hdev->driver = NULL; 1244 hdev->driver = NULL;
1244 } 1245 }
1245 return ret; 1246 return ret;
1246 } 1247 }
1247 1248
1248 static int hid_device_remove(struct device *dev) 1249 static int hid_device_remove(struct device *dev)
1249 { 1250 {
1250 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1251 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1251 struct hid_driver *hdrv = hdev->driver; 1252 struct hid_driver *hdrv = hdev->driver;
1252 1253
1253 if (hdrv) { 1254 if (hdrv) {
1254 if (hdrv->remove) 1255 if (hdrv->remove)
1255 hdrv->remove(hdev); 1256 hdrv->remove(hdev);
1256 else /* default remove */ 1257 else /* default remove */
1257 hid_hw_stop(hdev); 1258 hid_hw_stop(hdev);
1258 hdev->driver = NULL; 1259 hdev->driver = NULL;
1259 } 1260 }
1260 1261
1261 return 0; 1262 return 0;
1262 } 1263 }
1263 1264
1264 static int hid_uevent(struct device *dev, struct kobj_uevent_env *env) 1265 static int hid_uevent(struct device *dev, struct kobj_uevent_env *env)
1265 { 1266 {
1266 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1267 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1267 1268
1268 if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", 1269 if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X",
1269 hdev->bus, hdev->vendor, hdev->product)) 1270 hdev->bus, hdev->vendor, hdev->product))
1270 return -ENOMEM; 1271 return -ENOMEM;
1271 1272
1272 if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) 1273 if (add_uevent_var(env, "HID_NAME=%s", hdev->name))
1273 return -ENOMEM; 1274 return -ENOMEM;
1274 1275
1275 if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) 1276 if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys))
1276 return -ENOMEM; 1277 return -ENOMEM;
1277 1278
1278 if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) 1279 if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq))
1279 return -ENOMEM; 1280 return -ENOMEM;
1280 1281
1281 if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X", 1282 if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X",
1282 hdev->bus, hdev->vendor, hdev->product)) 1283 hdev->bus, hdev->vendor, hdev->product))
1283 return -ENOMEM; 1284 return -ENOMEM;
1284 1285
1285 return 0; 1286 return 0;
1286 } 1287 }
1287 1288
1288 static struct bus_type hid_bus_type = { 1289 static struct bus_type hid_bus_type = {
1289 .name = "hid", 1290 .name = "hid",
1290 .match = hid_bus_match, 1291 .match = hid_bus_match,
1291 .probe = hid_device_probe, 1292 .probe = hid_device_probe,
1292 .remove = hid_device_remove, 1293 .remove = hid_device_remove,
1293 .uevent = hid_uevent, 1294 .uevent = hid_uevent,
1294 }; 1295 };
1295 1296
1296 static const struct hid_device_id hid_ignore_list[] = { 1297 static const struct hid_device_id hid_ignore_list[] = {
1297 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, 1298 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) },
1298 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, 1299 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) },
1299 { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, 1300 { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) },
1300 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, 1301 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) },
1301 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, 1302 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) },
1302 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, 1303 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) },
1303 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, 1304 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) },
1304 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, 1305 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) },
1305 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, 1306 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) },
1306 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, 1307 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
1307 { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, 1308 { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
1308 { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, 1309 { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
1309 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)}, 1310 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)},
1310 { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, 1311 { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) },
1311 { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, 1312 { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) },
1312 { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, 1313 { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) },
1313 { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, 1314 { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) },
1314 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, 1315 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) },
1315 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, 1316 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) },
1316 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, 1317 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
1317 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 1318 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
1318 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 1319 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
1319 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, 1320 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) },
1320 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 1321 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) },
1321 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) }, 1322 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) },
1322 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, 1323 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) },
1323 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, 1324 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) },
1324 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, 1325 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) },
1325 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, 1326 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) },
1326 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, 1327 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) },
1327 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, 1328 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) },
1328 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, 1329 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) },
1329 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, 1330 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) },
1330 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, 1331 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) },
1331 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, 1332 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) },
1332 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, 1333 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) },
1333 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, 1334 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) },
1334 { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, 1335 { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) },
1335 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, 1336 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) },
1336 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, 1337 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) },
1337 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, 1338 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) },
1338 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, 1339 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) },
1339 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, 1340 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) },
1340 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, 1341 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) },
1341 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, 1342 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) },
1342 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, 1343 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) },
1343 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, 1344 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) },
1344 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, 1345 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) },
1345 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, 1346 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) },
1346 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, 1347 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) },
1347 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, 1348 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) },
1348 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, 1349 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) },
1349 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, 1350 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) },
1350 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, 1351 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) },
1351 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, 1352 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) },
1352 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, 1353 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) },
1353 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, 1354 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) },
1354 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, 1355 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) },
1355 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, 1356 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) },
1356 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, 1357 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) },
1357 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, 1358 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) },
1358 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, 1359 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) },
1359 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, 1360 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) },
1360 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, 1361 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) },
1361 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, 1362 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) },
1362 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, 1363 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) },
1363 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, 1364 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) },
1364 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, 1365 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) },
1365 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, 1366 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) },
1366 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, 1367 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) },
1367 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, 1368 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) },
1368 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, 1369 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) },
1369 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, 1370 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) },
1370 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, 1371 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) },
1371 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, 1372 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) },
1372 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, 1373 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) },
1373 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, 1374 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) },
1374 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, 1375 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) },
1375 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, 1376 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) },
1376 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, 1377 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) },
1377 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, 1378 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) },
1378 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, 1379 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) },
1379 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, 1380 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) },
1380 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, 1381 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) },
1381 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, 1382 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) },
1382 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, 1383 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
1383 { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, 1384 { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
1384 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, 1385 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
1385 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, 1386 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
1386 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, 1387 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) },
1387 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, 1388 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) },
1388 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, 1389 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) },
1389 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, 1390 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) },
1390 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, 1391 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) },
1391 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, 1392 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
1392 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY1) }, 1393 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY1) },
1393 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, 1394 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) },
1394 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, 1395 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) },
1395 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, 1396 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) },
1396 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, 1397 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) },
1397 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, 1398 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) },
1398 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, 1399 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) },
1399 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, 1400 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) },
1400 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, 1401 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) },
1401 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, 1402 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) },
1402 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, 1403 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) },
1403 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, 1404 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) },
1404 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, 1405 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) },
1405 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, 1406 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) },
1406 { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, 1407 { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) },
1407 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, 1408 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) },
1408 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, 1409 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) },
1409 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, 1410 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) },
1410 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, 1411 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) },
1411 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, 1412 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) },
1412 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, 1413 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) },
1413 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, 1414 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) },
1414 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, 1415 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) },
1415 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, 1416 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) },
1416 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, 1417 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) },
1417 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, 1418 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) },
1418 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, 1419 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) },
1419 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, 1420 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
1420 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, 1421 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
1421 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) }, 1422 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) },
1422 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, 1423 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
1423 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 1424 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
1424 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 1425 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
1425 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 1426 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
1426 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 1427 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
1427 { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, 1428 { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) },
1428 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, 1429 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) },
1429 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, 1430 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) },
1430 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, 1431 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) },
1431 { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, 1432 { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
1432 { } 1433 { }
1433 }; 1434 };
1434 1435
1435 static bool hid_ignore(struct hid_device *hdev) 1436 static bool hid_ignore(struct hid_device *hdev)
1436 { 1437 {
1437 switch (hdev->vendor) { 1438 switch (hdev->vendor) {
1438 case USB_VENDOR_ID_CODEMERCS: 1439 case USB_VENDOR_ID_CODEMERCS:
1439 /* ignore all Code Mercenaries IOWarrior devices */ 1440 /* ignore all Code Mercenaries IOWarrior devices */
1440 if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && 1441 if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST &&
1441 hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) 1442 hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST)
1442 return true; 1443 return true;
1443 break; 1444 break;
1444 case USB_VENDOR_ID_LOGITECH: 1445 case USB_VENDOR_ID_LOGITECH:
1445 if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && 1446 if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST &&
1446 hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) 1447 hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST)
1447 return true; 1448 return true;
1448 break; 1449 break;
1449 } 1450 }
1450 1451
1451 return !!hid_match_id(hdev, hid_ignore_list); 1452 return !!hid_match_id(hdev, hid_ignore_list);
1452 } 1453 }
1453 1454
1454 int hid_add_device(struct hid_device *hdev) 1455 int hid_add_device(struct hid_device *hdev)
1455 { 1456 {
1456 static atomic_t id = ATOMIC_INIT(0); 1457 static atomic_t id = ATOMIC_INIT(0);
1457 int ret; 1458 int ret;
1458 1459
1459 if (WARN_ON(hdev->status & HID_STAT_ADDED)) 1460 if (WARN_ON(hdev->status & HID_STAT_ADDED))
1460 return -EBUSY; 1461 return -EBUSY;
1461 1462
1462 /* we need to kill them here, otherwise they will stay allocated to 1463 /* we need to kill them here, otherwise they will stay allocated to
1463 * wait for coming driver */ 1464 * wait for coming driver */
1464 if (hid_ignore(hdev)) 1465 if (hid_ignore(hdev))
1465 return -ENODEV; 1466 return -ENODEV;
1466 1467
1467 /* XXX hack, any other cleaner solution < 20 bus_id bytes? */ 1468 /* XXX hack, any other cleaner solution < 20 bus_id bytes? */
1468 sprintf(hdev->dev.bus_id, "%04X:%04X:%04X.%04X", hdev->bus, 1469 sprintf(hdev->dev.bus_id, "%04X:%04X:%04X.%04X", hdev->bus,
1469 hdev->vendor, hdev->product, atomic_inc_return(&id)); 1470 hdev->vendor, hdev->product, atomic_inc_return(&id));
1470 1471
1471 ret = device_add(&hdev->dev); 1472 ret = device_add(&hdev->dev);
1472 if (!ret) 1473 if (!ret)
1473 hdev->status |= HID_STAT_ADDED; 1474 hdev->status |= HID_STAT_ADDED;
1474 1475
1475 return ret; 1476 return ret;
1476 } 1477 }
1477 EXPORT_SYMBOL_GPL(hid_add_device); 1478 EXPORT_SYMBOL_GPL(hid_add_device);
1478 1479
1479 /** 1480 /**
1480 * hid_allocate_device - allocate new hid device descriptor 1481 * hid_allocate_device - allocate new hid device descriptor
1481 * 1482 *
1482 * Allocate and initialize hid device, so that hid_destroy_device might be 1483 * Allocate and initialize hid device, so that hid_destroy_device might be
1483 * used to free it. 1484 * used to free it.
1484 * 1485 *
1485 * New hid_device pointer is returned on success, otherwise ERR_PTR encoded 1486 * New hid_device pointer is returned on success, otherwise ERR_PTR encoded
1486 * error value. 1487 * error value.
1487 */ 1488 */
1488 struct hid_device *hid_allocate_device(void) 1489 struct hid_device *hid_allocate_device(void)
1489 { 1490 {
1490 struct hid_device *hdev; 1491 struct hid_device *hdev;
1491 unsigned int i; 1492 unsigned int i;
1492 int ret = -ENOMEM; 1493 int ret = -ENOMEM;
1493 1494
1494 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); 1495 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
1495 if (hdev == NULL) 1496 if (hdev == NULL)
1496 return ERR_PTR(ret); 1497 return ERR_PTR(ret);
1497 1498
1498 device_initialize(&hdev->dev); 1499 device_initialize(&hdev->dev);
1499 hdev->dev.release = hid_device_release; 1500 hdev->dev.release = hid_device_release;
1500 hdev->dev.bus = &hid_bus_type; 1501 hdev->dev.bus = &hid_bus_type;
1501 1502
1502 hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, 1503 hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS,
1503 sizeof(struct hid_collection), GFP_KERNEL); 1504 sizeof(struct hid_collection), GFP_KERNEL);
1504 if (hdev->collection == NULL) 1505 if (hdev->collection == NULL)
1505 goto err; 1506 goto err;
1506 hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS; 1507 hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
1507 1508
1508 for (i = 0; i < HID_REPORT_TYPES; i++) 1509 for (i = 0; i < HID_REPORT_TYPES; i++)
1509 INIT_LIST_HEAD(&hdev->report_enum[i].report_list); 1510 INIT_LIST_HEAD(&hdev->report_enum[i].report_list);
1510 1511
1511 return hdev; 1512 return hdev;
1512 err: 1513 err:
1513 put_device(&hdev->dev); 1514 put_device(&hdev->dev);
1514 return ERR_PTR(ret); 1515 return ERR_PTR(ret);
1515 } 1516 }
1516 EXPORT_SYMBOL_GPL(hid_allocate_device); 1517 EXPORT_SYMBOL_GPL(hid_allocate_device);
1517 1518
1518 static void hid_remove_device(struct hid_device *hdev) 1519 static void hid_remove_device(struct hid_device *hdev)
1519 { 1520 {
1520 if (hdev->status & HID_STAT_ADDED) { 1521 if (hdev->status & HID_STAT_ADDED) {
1521 device_del(&hdev->dev); 1522 device_del(&hdev->dev);
1522 hdev->status &= ~HID_STAT_ADDED; 1523 hdev->status &= ~HID_STAT_ADDED;
1523 } 1524 }
1524 } 1525 }
1525 1526
1526 /** 1527 /**
1527 * hid_destroy_device - free previously allocated device 1528 * hid_destroy_device - free previously allocated device
1528 * 1529 *
1529 * @hdev: hid device 1530 * @hdev: hid device
1530 * 1531 *
1531 * If you allocate hid_device through hid_allocate_device, you should ever 1532 * If you allocate hid_device through hid_allocate_device, you should ever
1532 * free by this function. 1533 * free by this function.
1533 */ 1534 */
1534 void hid_destroy_device(struct hid_device *hdev) 1535 void hid_destroy_device(struct hid_device *hdev)
1535 { 1536 {
1536 hid_remove_device(hdev); 1537 hid_remove_device(hdev);
1537 put_device(&hdev->dev); 1538 put_device(&hdev->dev);
1538 } 1539 }
1539 EXPORT_SYMBOL_GPL(hid_destroy_device); 1540 EXPORT_SYMBOL_GPL(hid_destroy_device);
1540 1541
1541 int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, 1542 int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
1542 const char *mod_name) 1543 const char *mod_name)
1543 { 1544 {
1544 hdrv->driver.name = hdrv->name; 1545 hdrv->driver.name = hdrv->name;
1545 hdrv->driver.bus = &hid_bus_type; 1546 hdrv->driver.bus = &hid_bus_type;
1546 hdrv->driver.owner = owner; 1547 hdrv->driver.owner = owner;
1547 hdrv->driver.mod_name = mod_name; 1548 hdrv->driver.mod_name = mod_name;
1548 1549
1549 return driver_register(&hdrv->driver); 1550 return driver_register(&hdrv->driver);
1550 } 1551 }
1551 EXPORT_SYMBOL_GPL(__hid_register_driver); 1552 EXPORT_SYMBOL_GPL(__hid_register_driver);
1552 1553
1553 void hid_unregister_driver(struct hid_driver *hdrv) 1554 void hid_unregister_driver(struct hid_driver *hdrv)
1554 { 1555 {
1555 driver_unregister(&hdrv->driver); 1556 driver_unregister(&hdrv->driver);
1556 } 1557 }
1557 EXPORT_SYMBOL_GPL(hid_unregister_driver); 1558 EXPORT_SYMBOL_GPL(hid_unregister_driver);
1558 1559
1559 #ifdef CONFIG_HID_COMPAT 1560 #ifdef CONFIG_HID_COMPAT
1560 static void hid_compat_load(struct work_struct *ws) 1561 static void hid_compat_load(struct work_struct *ws)
1561 { 1562 {
1562 request_module("hid-dummy"); 1563 request_module("hid-dummy");
1563 } 1564 }
1564 static DECLARE_WORK(hid_compat_work, hid_compat_load); 1565 static DECLARE_WORK(hid_compat_work, hid_compat_load);
1565 #endif 1566 #endif
1566 1567
1567 static int __init hid_init(void) 1568 static int __init hid_init(void)
1568 { 1569 {
1569 int ret; 1570 int ret;
1570 1571
1571 ret = bus_register(&hid_bus_type); 1572 ret = bus_register(&hid_bus_type);
1572 if (ret) { 1573 if (ret) {
1573 printk(KERN_ERR "HID: can't register hid bus\n"); 1574 printk(KERN_ERR "HID: can't register hid bus\n");
1574 goto err; 1575 goto err;
1575 } 1576 }
1576 1577
1577 ret = hidraw_init(); 1578 ret = hidraw_init();
1578 if (ret) 1579 if (ret)
1579 goto err_bus; 1580 goto err_bus;
1580 1581
1581 #ifdef CONFIG_HID_COMPAT 1582 #ifdef CONFIG_HID_COMPAT
1582 schedule_work(&hid_compat_work); 1583 schedule_work(&hid_compat_work);
1583 #endif 1584 #endif
1584 1585
1585 return 0; 1586 return 0;
1586 err_bus: 1587 err_bus:
1587 bus_unregister(&hid_bus_type); 1588 bus_unregister(&hid_bus_type);
1588 err: 1589 err:
1589 return ret; 1590 return ret;
1590 } 1591 }
1591 1592
1592 static void __exit hid_exit(void) 1593 static void __exit hid_exit(void)
1593 { 1594 {
1594 hidraw_exit(); 1595 hidraw_exit();
1595 bus_unregister(&hid_bus_type); 1596 bus_unregister(&hid_bus_type);
1596 } 1597 }
1597 1598
1598 module_init(hid_init); 1599 module_init(hid_init);
1599 module_exit(hid_exit); 1600 module_exit(hid_exit);
1600 1601
1601 MODULE_LICENSE(DRIVER_LICENSE); 1602 MODULE_LICENSE(DRIVER_LICENSE);
1602 1603
1603 1604
drivers/hid/hid-dell.c
File was created 1 /*
2 * HID driver for some dell "special" devices
3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby
10 */
11
12 /*
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the Free
15 * Software Foundation; either version 2 of the License, or (at your option)
16 * any later version.
17 */
18
19 #include <linux/device.h>
20 #include <linux/hid.h>
21 #include <linux/module.h>
22
23 #include "hid-ids.h"
24
25 static int dell_probe(struct hid_device *hdev, const struct hid_device_id *id)
26 {
27 int ret;
28
29 hdev->quirks |= HID_QUIRK_RESET_LEDS;
30
31 ret = hid_parse(hdev);
32 if (ret) {
33 dev_err(&hdev->dev, "parse failed\n");
34 goto err_free;
35 }
36
37 ret = hid_hw_start(hdev);
38 if (ret) {
39 dev_err(&hdev->dev, "hw start failed\n");
40 goto err_free;
41 }
42
43 return 0;
44 err_free:
45 return ret;
46 }
47
48 static const struct hid_device_id dell_devices[] = {
49 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658) },
50 { }
51 };
52 MODULE_DEVICE_TABLE(hid, dell_devices);
53
54 static struct hid_driver dell_driver = {
55 .name = "dell",
56 .id_table = dell_devices,
57 .probe = dell_probe,
58 };
59
60 static int dell_init(void)
61 {
62 return hid_register_driver(&dell_driver);
63 }
64
65 static void dell_exit(void)
66 {
67 hid_unregister_driver(&dell_driver);
68 }
69
70 module_init(dell_init);
71 module_exit(dell_exit);
72 MODULE_LICENSE("GPL");
73
74 HID_COMPAT_LOAD_DRIVER(dell);
75
drivers/hid/hid-dummy.c
1 #include <linux/autoconf.h> 1 #include <linux/autoconf.h>
2 #include <linux/module.h> 2 #include <linux/module.h>
3 #include <linux/hid.h> 3 #include <linux/hid.h>
4 4
5 static int __init hid_dummy_init(void) 5 static int __init hid_dummy_init(void)
6 { 6 {
7 #ifdef CONFIG_HID_A4TECH_MODULE 7 #ifdef CONFIG_HID_A4TECH_MODULE
8 HID_COMPAT_CALL_DRIVER(a4tech); 8 HID_COMPAT_CALL_DRIVER(a4tech);
9 #endif 9 #endif
10 #ifdef CONFIG_HID_APPLE_MODULE 10 #ifdef CONFIG_HID_APPLE_MODULE
11 HID_COMPAT_CALL_DRIVER(apple); 11 HID_COMPAT_CALL_DRIVER(apple);
12 #endif 12 #endif
13 #ifdef CONFIG_HID_BELKIN_MODULE 13 #ifdef CONFIG_HID_BELKIN_MODULE
14 HID_COMPAT_CALL_DRIVER(belkin); 14 HID_COMPAT_CALL_DRIVER(belkin);
15 #endif 15 #endif
16 #ifdef CONFIG_HID_CHERRY_MODULE 16 #ifdef CONFIG_HID_CHERRY_MODULE
17 HID_COMPAT_CALL_DRIVER(cherry); 17 HID_COMPAT_CALL_DRIVER(cherry);
18 #endif 18 #endif
19 #ifdef CONFIG_HID_CHICONY_MODULE 19 #ifdef CONFIG_HID_CHICONY_MODULE
20 HID_COMPAT_CALL_DRIVER(chicony); 20 HID_COMPAT_CALL_DRIVER(chicony);
21 #endif 21 #endif
22 #ifdef CONFIG_HID_CYPRESS_MODULE 22 #ifdef CONFIG_HID_CYPRESS_MODULE
23 HID_COMPAT_CALL_DRIVER(cypress); 23 HID_COMPAT_CALL_DRIVER(cypress);
24 #endif 24 #endif
25 #ifdef CONFIG_HID_DELL_MODULE
26 HID_COMPAT_CALL_DRIVER(dell);
27 #endif
25 #ifdef CONFIG_HID_EZKEY_MODULE 28 #ifdef CONFIG_HID_EZKEY_MODULE
26 HID_COMPAT_CALL_DRIVER(ezkey); 29 HID_COMPAT_CALL_DRIVER(ezkey);
27 #endif 30 #endif
28 #ifdef CONFIG_HID_EZKEY_MODULE 31 #ifdef CONFIG_HID_EZKEY_MODULE
29 HID_COMPAT_CALL_DRIVER(gyration); 32 HID_COMPAT_CALL_DRIVER(gyration);
30 #endif 33 #endif
31 #ifdef CONFIG_HID_LOGITECH_MODULE 34 #ifdef CONFIG_HID_LOGITECH_MODULE
32 HID_COMPAT_CALL_DRIVER(logitech); 35 HID_COMPAT_CALL_DRIVER(logitech);
33 #endif 36 #endif
34 #ifdef CONFIG_HID_MICROSOFT_MODULE 37 #ifdef CONFIG_HID_MICROSOFT_MODULE
35 HID_COMPAT_CALL_DRIVER(microsoft); 38 HID_COMPAT_CALL_DRIVER(microsoft);
36 #endif 39 #endif
37 #ifdef CONFIG_HID_MONTEREY_MODULE 40 #ifdef CONFIG_HID_MONTEREY_MODULE
38 HID_COMPAT_CALL_DRIVER(monterey); 41 HID_COMPAT_CALL_DRIVER(monterey);
39 #endif 42 #endif
40 #ifdef CONFIG_HID_PETALYNX_MODULE 43 #ifdef CONFIG_HID_PETALYNX_MODULE
41 HID_COMPAT_CALL_DRIVER(petalynx); 44 HID_COMPAT_CALL_DRIVER(petalynx);
42 #endif 45 #endif
43 #ifdef CONFIG_HID_SAMSUNG_MODULE 46 #ifdef CONFIG_HID_SAMSUNG_MODULE
44 HID_COMPAT_CALL_DRIVER(samsung); 47 HID_COMPAT_CALL_DRIVER(samsung);
45 #endif 48 #endif
46 #ifdef CONFIG_HID_SONY_MODULE 49 #ifdef CONFIG_HID_SONY_MODULE
47 HID_COMPAT_CALL_DRIVER(sony); 50 HID_COMPAT_CALL_DRIVER(sony);
48 #endif 51 #endif
49 #ifdef CONFIG_HID_SUNPLUS_MODULE 52 #ifdef CONFIG_HID_SUNPLUS_MODULE
50 HID_COMPAT_CALL_DRIVER(sunplus); 53 HID_COMPAT_CALL_DRIVER(sunplus);
51 #endif 54 #endif
52 55
53 return -EIO; 56 return -EIO;
54 } 57 }
55 module_init(hid_dummy_init); 58 module_init(hid_dummy_init);
56 59
57 MODULE_LICENSE("GPL"); 60 MODULE_LICENSE("GPL");
58 61
drivers/hid/usbhid/hid-quirks.c
1 /* 1 /*
2 * USB HID quirks support for Linux 2 * USB HID quirks support for Linux
3 * 3 *
4 * Copyright (c) 1999 Andreas Gal 4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
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 */ 9 */
10 10
11 /* 11 /*
12 * This program is free software; you can redistribute it and/or modify it 12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the Free 13 * under the terms of the GNU General Public License as published by the Free
14 * Software Foundation; either version 2 of the License, or (at your option) 14 * Software Foundation; either version 2 of the License, or (at your option)
15 * any later version. 15 * any later version.
16 */ 16 */
17 17
18 #include <linux/hid.h> 18 #include <linux/hid.h>
19 19
20 #include "../hid-ids.h" 20 #include "../hid-ids.h"
21 21
22 /* 22 /*
23 * Alphabetically sorted blacklist by quirk type. 23 * Alphabetically sorted blacklist by quirk type.
24 */ 24 */
25 25
26 static const struct hid_blacklist { 26 static const struct hid_blacklist {
27 __u16 idVendor; 27 __u16 idVendor;
28 __u16 idProduct; 28 __u16 idProduct;
29 __u32 quirks; 29 __u32 quirks;
30 } hid_blacklist[] = { 30 } hid_blacklist[] = {
31 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD }, 31 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD },
32 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, 32 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD },
33 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, 33 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD },
34 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, 34 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD },
35 { USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR, HID_QUIRK_MULTI_INPUT }, 35 { USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR, HID_QUIRK_MULTI_INPUT },
36 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | 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_FLYING, 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_FIGHTING, 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_NATSU, USB_DEVICE_ID_NATSU_GAMEPAD, HID_QUIRK_BADPAD }, 39 { USB_VENDOR_ID_NATSU, USB_DEVICE_ID_NATSU_GAMEPAD, HID_QUIRK_BADPAD },
40 { USB_VENDOR_ID_NEC, USB_DEVICE_ID_NEC_USB_GAME_PAD, HID_QUIRK_BADPAD }, 40 { USB_VENDOR_ID_NEC, USB_DEVICE_ID_NEC_USB_GAME_PAD, HID_QUIRK_BADPAD },
41 { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD }, 41 { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD },
42 { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD }, 42 { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD },
43 43
44 { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL }, 44 { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL },
45 45
46 { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, 46 { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
47 { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT }, 47 { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT },
48 48
49 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET }, 49 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET },
50 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET }, 50 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET },
51 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, 51 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET },
52 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, 52 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET },
53 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, 53 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
54 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, 54 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
55 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 55 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
56 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, 56 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
57 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, 57 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
58 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, 58 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
59 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 59 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
60 60
61 { USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 61 { USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
62 62
63 { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS },
64
65 { 0, 0 } 63 { 0, 0 }
66 }; 64 };
67 65
68 /* Dynamic HID quirks list - specified at runtime */ 66 /* Dynamic HID quirks list - specified at runtime */
69 struct quirks_list_struct { 67 struct quirks_list_struct {
70 struct hid_blacklist hid_bl_item; 68 struct hid_blacklist hid_bl_item;
71 struct list_head node; 69 struct list_head node;
72 }; 70 };
73 71
74 static LIST_HEAD(dquirks_list); 72 static LIST_HEAD(dquirks_list);
75 static DECLARE_RWSEM(dquirks_rwsem); 73 static DECLARE_RWSEM(dquirks_rwsem);
76 74
77 /* Runtime ("dynamic") quirks manipulation functions */ 75 /* Runtime ("dynamic") quirks manipulation functions */
78 76
79 /** 77 /**
80 * usbhid_exists_dquirk: find any dynamic quirks for a USB HID device 78 * usbhid_exists_dquirk: find any dynamic quirks for a USB HID device
81 * @idVendor: the 16-bit USB vendor ID, in native byteorder 79 * @idVendor: the 16-bit USB vendor ID, in native byteorder
82 * @idProduct: the 16-bit USB product ID, in native byteorder 80 * @idProduct: the 16-bit USB product ID, in native byteorder
83 * 81 *
84 * Description: 82 * Description:
85 * Scans dquirks_list for a matching dynamic quirk and returns 83 * Scans dquirks_list for a matching dynamic quirk and returns
86 * the pointer to the relevant struct hid_blacklist if found. 84 * the pointer to the relevant struct hid_blacklist if found.
87 * Must be called with a read lock held on dquirks_rwsem. 85 * Must be called with a read lock held on dquirks_rwsem.
88 * 86 *
89 * Returns: NULL if no quirk found, struct hid_blacklist * if found. 87 * Returns: NULL if no quirk found, struct hid_blacklist * if found.
90 */ 88 */
91 static struct hid_blacklist *usbhid_exists_dquirk(const u16 idVendor, 89 static struct hid_blacklist *usbhid_exists_dquirk(const u16 idVendor,
92 const u16 idProduct) 90 const u16 idProduct)
93 { 91 {
94 struct quirks_list_struct *q; 92 struct quirks_list_struct *q;
95 struct hid_blacklist *bl_entry = NULL; 93 struct hid_blacklist *bl_entry = NULL;
96 94
97 list_for_each_entry(q, &dquirks_list, node) { 95 list_for_each_entry(q, &dquirks_list, node) {
98 if (q->hid_bl_item.idVendor == idVendor && 96 if (q->hid_bl_item.idVendor == idVendor &&
99 q->hid_bl_item.idProduct == idProduct) { 97 q->hid_bl_item.idProduct == idProduct) {
100 bl_entry = &q->hid_bl_item; 98 bl_entry = &q->hid_bl_item;
101 break; 99 break;
102 } 100 }
103 } 101 }
104 102
105 if (bl_entry != NULL) 103 if (bl_entry != NULL)
106 dbg_hid("Found dynamic quirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n", 104 dbg_hid("Found dynamic quirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n",
107 bl_entry->quirks, bl_entry->idVendor, 105 bl_entry->quirks, bl_entry->idVendor,
108 bl_entry->idProduct); 106 bl_entry->idProduct);
109 107
110 return bl_entry; 108 return bl_entry;
111 } 109 }
112 110
113 111
114 /** 112 /**
115 * usbhid_modify_dquirk: add/replace a HID quirk 113 * usbhid_modify_dquirk: add/replace a HID quirk
116 * @idVendor: the 16-bit USB vendor ID, in native byteorder 114 * @idVendor: the 16-bit USB vendor ID, in native byteorder
117 * @idProduct: the 16-bit USB product ID, in native byteorder 115 * @idProduct: the 16-bit USB product ID, in native byteorder
118 * @quirks: the u32 quirks value to add/replace 116 * @quirks: the u32 quirks value to add/replace
119 * 117 *
120 * Description: 118 * Description:
121 * If an dynamic quirk exists in memory for this (idVendor, 119 * If an dynamic quirk exists in memory for this (idVendor,
122 * idProduct) pair, replace its quirks value with what was 120 * idProduct) pair, replace its quirks value with what was
123 * provided. Otherwise, add the quirk to the dynamic quirks list. 121 * provided. Otherwise, add the quirk to the dynamic quirks list.
124 * 122 *
125 * Returns: 0 OK, -error on failure. 123 * Returns: 0 OK, -error on failure.
126 */ 124 */
127 static int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct, 125 static int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct,
128 const u32 quirks) 126 const u32 quirks)
129 { 127 {
130 struct quirks_list_struct *q_new, *q; 128 struct quirks_list_struct *q_new, *q;
131 int list_edited = 0; 129 int list_edited = 0;
132 130
133 if (!idVendor) { 131 if (!idVendor) {
134 dbg_hid("Cannot add a quirk with idVendor = 0\n"); 132 dbg_hid("Cannot add a quirk with idVendor = 0\n");
135 return -EINVAL; 133 return -EINVAL;
136 } 134 }
137 135
138 q_new = kmalloc(sizeof(struct quirks_list_struct), GFP_KERNEL); 136 q_new = kmalloc(sizeof(struct quirks_list_struct), GFP_KERNEL);
139 if (!q_new) { 137 if (!q_new) {
140 dbg_hid("Could not allocate quirks_list_struct\n"); 138 dbg_hid("Could not allocate quirks_list_struct\n");
141 return -ENOMEM; 139 return -ENOMEM;
142 } 140 }
143 141
144 q_new->hid_bl_item.idVendor = idVendor; 142 q_new->hid_bl_item.idVendor = idVendor;
145 q_new->hid_bl_item.idProduct = idProduct; 143 q_new->hid_bl_item.idProduct = idProduct;
146 q_new->hid_bl_item.quirks = quirks; 144 q_new->hid_bl_item.quirks = quirks;
147 145
148 down_write(&dquirks_rwsem); 146 down_write(&dquirks_rwsem);
149 147
150 list_for_each_entry(q, &dquirks_list, node) { 148 list_for_each_entry(q, &dquirks_list, node) {
151 149
152 if (q->hid_bl_item.idVendor == idVendor && 150 if (q->hid_bl_item.idVendor == idVendor &&
153 q->hid_bl_item.idProduct == idProduct) { 151 q->hid_bl_item.idProduct == idProduct) {
154 152
155 list_replace(&q->node, &q_new->node); 153 list_replace(&q->node, &q_new->node);
156 kfree(q); 154 kfree(q);
157 list_edited = 1; 155 list_edited = 1;
158 break; 156 break;
159 157
160 } 158 }
161 159
162 } 160 }
163 161
164 if (!list_edited) 162 if (!list_edited)
165 list_add_tail(&q_new->node, &dquirks_list); 163 list_add_tail(&q_new->node, &dquirks_list);
166 164
167 up_write(&dquirks_rwsem); 165 up_write(&dquirks_rwsem);
168 166
169 return 0; 167 return 0;
170 } 168 }
171 169
172 /** 170 /**
173 * usbhid_remove_all_dquirks: remove all runtime HID quirks from memory 171 * usbhid_remove_all_dquirks: remove all runtime HID quirks from memory
174 * 172 *
175 * Description: 173 * Description:
176 * Free all memory associated with dynamic quirks - called before 174 * Free all memory associated with dynamic quirks - called before
177 * module unload. 175 * module unload.
178 * 176 *
179 */ 177 */
180 static void usbhid_remove_all_dquirks(void) 178 static void usbhid_remove_all_dquirks(void)
181 { 179 {
182 struct quirks_list_struct *q, *temp; 180 struct quirks_list_struct *q, *temp;
183 181
184 down_write(&dquirks_rwsem); 182 down_write(&dquirks_rwsem);
185 list_for_each_entry_safe(q, temp, &dquirks_list, node) { 183 list_for_each_entry_safe(q, temp, &dquirks_list, node) {
186 list_del(&q->node); 184 list_del(&q->node);
187 kfree(q); 185 kfree(q);
188 } 186 }
189 up_write(&dquirks_rwsem); 187 up_write(&dquirks_rwsem);
190 188
191 } 189 }
192 190
193 /** 191 /**
194 * usbhid_quirks_init: apply USB HID quirks specified at module load time 192 * usbhid_quirks_init: apply USB HID quirks specified at module load time
195 */ 193 */
196 int usbhid_quirks_init(char **quirks_param) 194 int usbhid_quirks_init(char **quirks_param)
197 { 195 {
198 u16 idVendor, idProduct; 196 u16 idVendor, idProduct;
199 u32 quirks; 197 u32 quirks;
200 int n = 0, m; 198 int n = 0, m;
201 199
202 for (; quirks_param[n] && n < MAX_USBHID_BOOT_QUIRKS; n++) { 200 for (; quirks_param[n] && n < MAX_USBHID_BOOT_QUIRKS; n++) {
203 201
204 m = sscanf(quirks_param[n], "0x%hx:0x%hx:0x%x", 202 m = sscanf(quirks_param[n], "0x%hx:0x%hx:0x%x",
205 &idVendor, &idProduct, &quirks); 203 &idVendor, &idProduct, &quirks);
206 204
207 if (m != 3 || 205 if (m != 3 ||
208 usbhid_modify_dquirk(idVendor, idProduct, quirks) != 0) { 206 usbhid_modify_dquirk(idVendor, idProduct, quirks) != 0) {
209 printk(KERN_WARNING 207 printk(KERN_WARNING
210 "Could not parse HID quirk module param %s\n", 208 "Could not parse HID quirk module param %s\n",
211 quirks_param[n]); 209 quirks_param[n]);
212 } 210 }
213 } 211 }
214 212
215 return 0; 213 return 0;
216 } 214 }
217 215
218 /** 216 /**
219 * usbhid_quirks_exit: release memory associated with dynamic_quirks 217 * usbhid_quirks_exit: release memory associated with dynamic_quirks
220 * 218 *
221 * Description: 219 * Description:
222 * Release all memory associated with dynamic quirks. Called upon 220 * Release all memory associated with dynamic quirks. Called upon
223 * module unload. 221 * module unload.
224 * 222 *
225 * Returns: nothing 223 * Returns: nothing
226 */ 224 */
227 void usbhid_quirks_exit(void) 225 void usbhid_quirks_exit(void)
228 { 226 {
229 usbhid_remove_all_dquirks(); 227 usbhid_remove_all_dquirks();
230 } 228 }
231 229
232 /** 230 /**
233 * usbhid_exists_squirk: return any static quirks for a USB HID device 231 * usbhid_exists_squirk: return any static quirks for a USB HID device
234 * @idVendor: the 16-bit USB vendor ID, in native byteorder 232 * @idVendor: the 16-bit USB vendor ID, in native byteorder
235 * @idProduct: the 16-bit USB product ID, in native byteorder 233 * @idProduct: the 16-bit USB product ID, in native byteorder
236 * 234 *
237 * Description: 235 * Description:
238 * Given a USB vendor ID and product ID, return a pointer to 236 * Given a USB vendor ID and product ID, return a pointer to
239 * the hid_blacklist entry associated with that device. 237 * the hid_blacklist entry associated with that device.
240 * 238 *
241 * Returns: pointer if quirk found, or NULL if no quirks found. 239 * Returns: pointer if quirk found, or NULL if no quirks found.
242 */ 240 */
243 static const struct hid_blacklist *usbhid_exists_squirk(const u16 idVendor, 241 static const struct hid_blacklist *usbhid_exists_squirk(const u16 idVendor,
244 const u16 idProduct) 242 const u16 idProduct)
245 { 243 {
246 const struct hid_blacklist *bl_entry = NULL; 244 const struct hid_blacklist *bl_entry = NULL;
247 int n = 0; 245 int n = 0;
248 246
249 for (; hid_blacklist[n].idVendor; n++) 247 for (; hid_blacklist[n].idVendor; n++)
250 if (hid_blacklist[n].idVendor == idVendor && 248 if (hid_blacklist[n].idVendor == idVendor &&
251 hid_blacklist[n].idProduct == idProduct) 249 hid_blacklist[n].idProduct == idProduct)
252 bl_entry = &hid_blacklist[n]; 250 bl_entry = &hid_blacklist[n];
253 251
254 if (bl_entry != NULL) 252 if (bl_entry != NULL)
255 dbg_hid("Found squirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n", 253 dbg_hid("Found squirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n",
256 bl_entry->quirks, bl_entry->idVendor, 254 bl_entry->quirks, bl_entry->idVendor,
257 bl_entry->idProduct); 255 bl_entry->idProduct);
258 return bl_entry; 256 return bl_entry;
259 } 257 }
260 258
261 /** 259 /**
262 * usbhid_lookup_quirk: return any quirks associated with a USB HID device 260 * usbhid_lookup_quirk: return any quirks associated with a USB HID device
263 * @idVendor: the 16-bit USB vendor ID, in native byteorder 261 * @idVendor: the 16-bit USB vendor ID, in native byteorder
264 * @idProduct: the 16-bit USB product ID, in native byteorder 262 * @idProduct: the 16-bit USB product ID, in native byteorder
265 * 263 *
266 * Description: 264 * Description:
267 * Given a USB vendor ID and product ID, return any quirks associated 265 * Given a USB vendor ID and product ID, return any quirks associated
268 * with that device. 266 * with that device.
269 * 267 *
270 * Returns: a u32 quirks value. 268 * Returns: a u32 quirks value.
271 */ 269 */
272 u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct) 270 u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct)
273 { 271 {
274 u32 quirks = 0; 272 u32 quirks = 0;
275 const struct hid_blacklist *bl_entry = NULL; 273 const struct hid_blacklist *bl_entry = NULL;
276 274
277 /* NCR devices must not be queried for reports */ 275 /* NCR devices must not be queried for reports */
278 if (idVendor == USB_VENDOR_ID_NCR && 276 if (idVendor == USB_VENDOR_ID_NCR &&
279 idProduct >= USB_DEVICE_ID_NCR_FIRST && 277 idProduct >= USB_DEVICE_ID_NCR_FIRST &&
280 idProduct <= USB_DEVICE_ID_NCR_LAST) 278 idProduct <= USB_DEVICE_ID_NCR_LAST)
281 return HID_QUIRK_NOGET; 279 return HID_QUIRK_NOGET;
282 280
283 down_read(&dquirks_rwsem); 281 down_read(&dquirks_rwsem);
284 bl_entry = usbhid_exists_dquirk(idVendor, idProduct); 282 bl_entry = usbhid_exists_dquirk(idVendor, idProduct);
285 if (!bl_entry) 283 if (!bl_entry)
286 bl_entry = usbhid_exists_squirk(idVendor, idProduct); 284 bl_entry = usbhid_exists_squirk(idVendor, idProduct);
287 if (bl_entry) 285 if (bl_entry)
288 quirks = bl_entry->quirks; 286 quirks = bl_entry->quirks;
289 up_read(&dquirks_rwsem); 287 up_read(&dquirks_rwsem);
290 288
291 return quirks; 289 return quirks;
292 } 290 }
293 291
294 EXPORT_SYMBOL_GPL(usbhid_lookup_quirk); 292 EXPORT_SYMBOL_GPL(usbhid_lookup_quirk);
295 293