blob: 4da66b4b977c334df920200d1ee08d5ec6a1b164 [file] [log] [blame]
Jiri Kosinadde58452006-12-08 18:40:44 +01001/*
Jiri Kosina229695e2006-12-08 18:40:53 +01002 * HID support for Linux
Jiri Kosinadde58452006-12-08 18:40:44 +01003 *
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
Jiri Kosina6b1968d2012-03-09 13:55:43 +01007 * Copyright (c) 2006-2012 Jiri Kosina
Jiri Kosinadde58452006-12-08 18:40:44 +01008 */
9
10/*
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
13 * Software Foundation; either version 2 of the License, or (at your option)
14 * any later version.
15 */
16
Joe Perches4291ee32010-12-09 19:29:03 -080017#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
Jiri Kosinadde58452006-12-08 18:40:44 +010019#include <linux/module.h>
20#include <linux/slab.h>
21#include <linux/init.h>
22#include <linux/kernel.h>
Jiri Kosinadde58452006-12-08 18:40:44 +010023#include <linux/list.h>
24#include <linux/mm.h>
Jiri Kosinadde58452006-12-08 18:40:44 +010025#include <linux/spinlock.h>
26#include <asm/unaligned.h>
27#include <asm/byteorder.h>
28#include <linux/input.h>
29#include <linux/wait.h>
Jiri Kosina47a80ed2007-03-12 14:55:12 +010030#include <linux/vmalloc.h>
Jiri Kosinac4124c92007-11-30 11:12:58 +010031#include <linux/sched.h>
David Herrmann4ea54542011-08-10 14:02:07 +020032#include <linux/semaphore.h>
Jiri Kosinadde58452006-12-08 18:40:44 +010033
Jiri Kosinadde58452006-12-08 18:40:44 +010034#include <linux/hid.h>
35#include <linux/hiddev.h>
Jiri Kosinac080d892007-01-25 11:43:31 +010036#include <linux/hid-debug.h>
Jiri Kosina86166b72007-05-14 09:57:40 +020037#include <linux/hidraw.h>
Jiri Kosinadde58452006-12-08 18:40:44 +010038
Jiri Slaby5f22a792008-05-16 11:49:19 +020039#include "hid-ids.h"
40
Jiri Kosinadde58452006-12-08 18:40:44 +010041/*
42 * Version Information
43 */
44
Jiri Kosina53149802007-01-09 13:24:25 +010045#define DRIVER_DESC "HID core driver"
Jiri Kosinadde58452006-12-08 18:40:44 +010046#define DRIVER_LICENSE "GPL"
47
Jiri Kosina58037eb2007-05-30 15:07:13 +020048int hid_debug = 0;
Anssi Hannula377e10f2008-03-22 23:50:13 +010049module_param_named(debug, hid_debug, int, 0600);
Jiri Kosinacd667ce2009-06-12 15:20:57 +020050MODULE_PARM_DESC(debug, "toggle HID debugging messages");
Jiri Kosina58037eb2007-05-30 15:07:13 +020051EXPORT_SYMBOL_GPL(hid_debug);
Jiri Kosina58037eb2007-05-30 15:07:13 +020052
Jiri Kosina6b1968d2012-03-09 13:55:43 +010053static int hid_ignore_special_drivers = 0;
54module_param_named(ignore_special_drivers, hid_ignore_special_drivers, int, 0600);
55MODULE_PARM_DESC(debug, "Ignore any special drivers and handle all devices by generic driver");
56
Jiri Kosinadde58452006-12-08 18:40:44 +010057/*
Jiri Kosinadde58452006-12-08 18:40:44 +010058 * Register a new report for a device.
59 */
60
Michael Poole90a006a2010-01-24 22:32:29 -050061struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id)
Jiri Kosinadde58452006-12-08 18:40:44 +010062{
63 struct hid_report_enum *report_enum = device->report_enum + type;
64 struct hid_report *report;
65
66 if (report_enum->report_id_hash[id])
67 return report_enum->report_id_hash[id];
68
Joe Perchesa3789a12010-12-09 19:29:07 -080069 report = kzalloc(sizeof(struct hid_report), GFP_KERNEL);
70 if (!report)
Jiri Kosinadde58452006-12-08 18:40:44 +010071 return NULL;
72
73 if (id != 0)
74 report_enum->numbered = 1;
75
76 report->id = id;
77 report->type = type;
78 report->size = 0;
79 report->device = device;
80 report_enum->report_id_hash[id] = report;
81
82 list_add_tail(&report->list, &report_enum->report_list);
83
84 return report;
85}
Michael Poole90a006a2010-01-24 22:32:29 -050086EXPORT_SYMBOL_GPL(hid_register_report);
Jiri Kosinadde58452006-12-08 18:40:44 +010087
88/*
89 * Register a new field for this report.
90 */
91
92static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
93{
94 struct hid_field *field;
95
96 if (report->maxfield == HID_MAX_FIELDS) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +010097 hid_err(report->device, "too many fields in report\n");
Jiri Kosinadde58452006-12-08 18:40:44 +010098 return NULL;
99 }
100
Joe Perchesa3789a12010-12-09 19:29:07 -0800101 field = kzalloc((sizeof(struct hid_field) +
102 usages * sizeof(struct hid_usage) +
103 values * sizeof(unsigned)), GFP_KERNEL);
104 if (!field)
105 return NULL;
Jiri Kosinadde58452006-12-08 18:40:44 +0100106
107 field->index = report->maxfield++;
108 report->field[field->index] = field;
109 field->usage = (struct hid_usage *)(field + 1);
Jiri Slaby282bfd42008-03-28 17:06:41 +0100110 field->value = (s32 *)(field->usage + usages);
Jiri Kosinadde58452006-12-08 18:40:44 +0100111 field->report = report;
112
113 return field;
114}
115
116/*
117 * Open a collection. The type/usage is pushed on the stack.
118 */
119
120static int open_collection(struct hid_parser *parser, unsigned type)
121{
122 struct hid_collection *collection;
123 unsigned usage;
124
125 usage = parser->local.usage[0];
126
127 if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100128 hid_err(parser->device, "collection stack overflow\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100129 return -1;
130 }
131
132 if (parser->device->maxcollection == parser->device->collection_size) {
133 collection = kmalloc(sizeof(struct hid_collection) *
134 parser->device->collection_size * 2, GFP_KERNEL);
135 if (collection == NULL) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100136 hid_err(parser->device, "failed to reallocate collection array\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100137 return -1;
138 }
139 memcpy(collection, parser->device->collection,
140 sizeof(struct hid_collection) *
141 parser->device->collection_size);
142 memset(collection + parser->device->collection_size, 0,
143 sizeof(struct hid_collection) *
144 parser->device->collection_size);
145 kfree(parser->device->collection);
146 parser->device->collection = collection;
147 parser->device->collection_size *= 2;
148 }
149
150 parser->collection_stack[parser->collection_stack_ptr++] =
151 parser->device->maxcollection;
152
153 collection = parser->device->collection +
154 parser->device->maxcollection++;
155 collection->type = type;
156 collection->usage = usage;
157 collection->level = parser->collection_stack_ptr - 1;
158
159 if (type == HID_COLLECTION_APPLICATION)
160 parser->device->maxapplication++;
161
162 return 0;
163}
164
165/*
166 * Close a collection.
167 */
168
169static int close_collection(struct hid_parser *parser)
170{
171 if (!parser->collection_stack_ptr) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100172 hid_err(parser->device, "collection stack underflow\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100173 return -1;
174 }
175 parser->collection_stack_ptr--;
176 return 0;
177}
178
179/*
180 * Climb up the stack, search for the specified collection type
181 * and return the usage.
182 */
183
184static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
185{
Joe Perches504499f2010-12-09 19:29:08 -0800186 struct hid_collection *collection = parser->device->collection;
Jiri Kosinadde58452006-12-08 18:40:44 +0100187 int n;
Joe Perches504499f2010-12-09 19:29:08 -0800188
189 for (n = parser->collection_stack_ptr - 1; n >= 0; n--) {
190 unsigned index = parser->collection_stack[n];
191 if (collection[index].type == type)
192 return collection[index].usage;
193 }
Jiri Kosinadde58452006-12-08 18:40:44 +0100194 return 0; /* we know nothing about this usage type */
195}
196
197/*
198 * Add a usage to the temporary parser table.
199 */
200
201static int hid_add_usage(struct hid_parser *parser, unsigned usage)
202{
203 if (parser->local.usage_index >= HID_MAX_USAGES) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100204 hid_err(parser->device, "usage index exceeded\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100205 return -1;
206 }
207 parser->local.usage[parser->local.usage_index] = usage;
208 parser->local.collection_index[parser->local.usage_index] =
209 parser->collection_stack_ptr ?
210 parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
211 parser->local.usage_index++;
212 return 0;
213}
214
215/*
216 * Register a new field for this report.
217 */
218
219static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags)
220{
221 struct hid_report *report;
222 struct hid_field *field;
223 int usages;
224 unsigned offset;
225 int i;
226
Joe Perchesa3789a12010-12-09 19:29:07 -0800227 report = hid_register_report(parser->device, report_type, parser->global.report_id);
228 if (!report) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100229 hid_err(parser->device, "hid_register_report failed\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100230 return -1;
231 }
232
233 if (parser->global.logical_maximum < parser->global.logical_minimum) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100234 hid_err(parser->device, "logical range invalid %d %d\n",
235 parser->global.logical_minimum, parser->global.logical_maximum);
Jiri Kosinadde58452006-12-08 18:40:44 +0100236 return -1;
237 }
238
239 offset = report->size;
240 report->size += parser->global.report_size * parser->global.report_count;
241
242 if (!parser->local.usage_index) /* Ignore padding fields */
243 return 0;
244
245 usages = max_t(int, parser->local.usage_index, parser->global.report_count);
246
Joe Perchesa3789a12010-12-09 19:29:07 -0800247 field = hid_register_field(report, usages, parser->global.report_count);
248 if (!field)
Jiri Kosinadde58452006-12-08 18:40:44 +0100249 return 0;
250
251 field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL);
252 field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL);
253 field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION);
254
255 for (i = 0; i < usages; i++) {
256 int j = i;
257 /* Duplicate the last usage we parsed if we have excess values */
258 if (i >= parser->local.usage_index)
259 j = parser->local.usage_index - 1;
260 field->usage[i].hid = parser->local.usage[j];
261 field->usage[i].collection_index =
262 parser->local.collection_index[j];
263 }
264
265 field->maxusage = usages;
266 field->flags = flags;
267 field->report_offset = offset;
268 field->report_type = report_type;
269 field->report_size = parser->global.report_size;
270 field->report_count = parser->global.report_count;
271 field->logical_minimum = parser->global.logical_minimum;
272 field->logical_maximum = parser->global.logical_maximum;
273 field->physical_minimum = parser->global.physical_minimum;
274 field->physical_maximum = parser->global.physical_maximum;
275 field->unit_exponent = parser->global.unit_exponent;
276 field->unit = parser->global.unit;
277
278 return 0;
279}
280
281/*
282 * Read data value from item.
283 */
284
285static u32 item_udata(struct hid_item *item)
286{
287 switch (item->size) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200288 case 1: return item->data.u8;
289 case 2: return item->data.u16;
290 case 4: return item->data.u32;
Jiri Kosinadde58452006-12-08 18:40:44 +0100291 }
292 return 0;
293}
294
295static s32 item_sdata(struct hid_item *item)
296{
297 switch (item->size) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200298 case 1: return item->data.s8;
299 case 2: return item->data.s16;
300 case 4: return item->data.s32;
Jiri Kosinadde58452006-12-08 18:40:44 +0100301 }
302 return 0;
303}
304
305/*
306 * Process a global item.
307 */
308
309static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
310{
311 switch (item->tag) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200312 case HID_GLOBAL_ITEM_TAG_PUSH:
Jiri Kosinadde58452006-12-08 18:40:44 +0100313
Jiri Slaby880d29f2008-06-18 23:55:41 +0200314 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100315 hid_err(parser->device, "global environment stack overflow\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100316 return -1;
Jiri Slaby880d29f2008-06-18 23:55:41 +0200317 }
318
319 memcpy(parser->global_stack + parser->global_stack_ptr++,
320 &parser->global, sizeof(struct hid_global));
321 return 0;
322
323 case HID_GLOBAL_ITEM_TAG_POP:
324
325 if (!parser->global_stack_ptr) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100326 hid_err(parser->device, "global environment stack underflow\n");
Jiri Slaby880d29f2008-06-18 23:55:41 +0200327 return -1;
328 }
329
330 memcpy(&parser->global, parser->global_stack +
331 --parser->global_stack_ptr, sizeof(struct hid_global));
332 return 0;
333
334 case HID_GLOBAL_ITEM_TAG_USAGE_PAGE:
335 parser->global.usage_page = item_udata(item);
336 return 0;
337
338 case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM:
339 parser->global.logical_minimum = item_sdata(item);
340 return 0;
341
342 case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM:
343 if (parser->global.logical_minimum < 0)
344 parser->global.logical_maximum = item_sdata(item);
345 else
346 parser->global.logical_maximum = item_udata(item);
347 return 0;
348
349 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM:
350 parser->global.physical_minimum = item_sdata(item);
351 return 0;
352
353 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM:
354 if (parser->global.physical_minimum < 0)
355 parser->global.physical_maximum = item_sdata(item);
356 else
357 parser->global.physical_maximum = item_udata(item);
358 return 0;
359
360 case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT:
361 parser->global.unit_exponent = item_sdata(item);
362 return 0;
363
364 case HID_GLOBAL_ITEM_TAG_UNIT:
365 parser->global.unit = item_udata(item);
366 return 0;
367
368 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
369 parser->global.report_size = item_udata(item);
Chase Douglase46e9272011-11-07 11:08:05 -0800370 if (parser->global.report_size > 96) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100371 hid_err(parser->device, "invalid report_size %d\n",
Jiri Slaby880d29f2008-06-18 23:55:41 +0200372 parser->global.report_size);
373 return -1;
374 }
375 return 0;
376
377 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT:
378 parser->global.report_count = item_udata(item);
379 if (parser->global.report_count > HID_MAX_USAGES) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100380 hid_err(parser->device, "invalid report_count %d\n",
Jiri Slaby880d29f2008-06-18 23:55:41 +0200381 parser->global.report_count);
382 return -1;
383 }
384 return 0;
385
386 case HID_GLOBAL_ITEM_TAG_REPORT_ID:
387 parser->global.report_id = item_udata(item);
388 if (parser->global.report_id == 0) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100389 hid_err(parser->device, "report_id 0 is invalid\n");
Jiri Slaby880d29f2008-06-18 23:55:41 +0200390 return -1;
391 }
392 return 0;
393
394 default:
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100395 hid_err(parser->device, "unknown global tag 0x%x\n", item->tag);
Jiri Slaby880d29f2008-06-18 23:55:41 +0200396 return -1;
Jiri Kosinadde58452006-12-08 18:40:44 +0100397 }
398}
399
400/*
401 * Process a local item.
402 */
403
404static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
405{
406 __u32 data;
407 unsigned n;
408
Jiri Kosinadde58452006-12-08 18:40:44 +0100409 data = item_udata(item);
410
411 switch (item->tag) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200412 case HID_LOCAL_ITEM_TAG_DELIMITER:
Jiri Kosinadde58452006-12-08 18:40:44 +0100413
Jiri Slaby880d29f2008-06-18 23:55:41 +0200414 if (data) {
415 /*
416 * We treat items before the first delimiter
417 * as global to all usage sets (branch 0).
418 * In the moment we process only these global
419 * items and the first delimiter set.
420 */
421 if (parser->local.delimiter_depth != 0) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100422 hid_err(parser->device, "nested delimiters\n");
Jiri Slaby880d29f2008-06-18 23:55:41 +0200423 return -1;
Jiri Kosinadde58452006-12-08 18:40:44 +0100424 }
Jiri Slaby880d29f2008-06-18 23:55:41 +0200425 parser->local.delimiter_depth++;
426 parser->local.delimiter_branch++;
427 } else {
428 if (parser->local.delimiter_depth < 1) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100429 hid_err(parser->device, "bogus close delimiter\n");
Jiri Slaby880d29f2008-06-18 23:55:41 +0200430 return -1;
Jiri Kosinadde58452006-12-08 18:40:44 +0100431 }
Jiri Slaby880d29f2008-06-18 23:55:41 +0200432 parser->local.delimiter_depth--;
433 }
434 return 1;
Jiri Kosinadde58452006-12-08 18:40:44 +0100435
Jiri Slaby880d29f2008-06-18 23:55:41 +0200436 case HID_LOCAL_ITEM_TAG_USAGE:
Jiri Kosinadde58452006-12-08 18:40:44 +0100437
Jiri Slaby880d29f2008-06-18 23:55:41 +0200438 if (parser->local.delimiter_branch > 1) {
439 dbg_hid("alternative usage ignored\n");
Jiri Kosinadde58452006-12-08 18:40:44 +0100440 return 0;
Jiri Slaby880d29f2008-06-18 23:55:41 +0200441 }
Jiri Kosinadde58452006-12-08 18:40:44 +0100442
Jiri Slaby880d29f2008-06-18 23:55:41 +0200443 if (item->size <= 2)
444 data = (parser->global.usage_page << 16) + data;
Jiri Kosinadde58452006-12-08 18:40:44 +0100445
Jiri Slaby880d29f2008-06-18 23:55:41 +0200446 return hid_add_usage(parser, data);
447
448 case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
449
450 if (parser->local.delimiter_branch > 1) {
451 dbg_hid("alternative usage ignored\n");
452 return 0;
453 }
454
455 if (item->size <= 2)
456 data = (parser->global.usage_page << 16) + data;
457
458 parser->local.usage_minimum = data;
459 return 0;
460
461 case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
462
463 if (parser->local.delimiter_branch > 1) {
464 dbg_hid("alternative usage ignored\n");
465 return 0;
466 }
467
468 if (item->size <= 2)
469 data = (parser->global.usage_page << 16) + data;
470
471 for (n = parser->local.usage_minimum; n <= data; n++)
472 if (hid_add_usage(parser, n)) {
473 dbg_hid("hid_add_usage failed\n");
474 return -1;
Jiri Kosinadde58452006-12-08 18:40:44 +0100475 }
Jiri Slaby880d29f2008-06-18 23:55:41 +0200476 return 0;
Jiri Kosinadde58452006-12-08 18:40:44 +0100477
Jiri Slaby880d29f2008-06-18 23:55:41 +0200478 default:
Jiri Kosinadde58452006-12-08 18:40:44 +0100479
Jiri Slaby880d29f2008-06-18 23:55:41 +0200480 dbg_hid("unknown local item tag 0x%x\n", item->tag);
481 return 0;
Jiri Kosinadde58452006-12-08 18:40:44 +0100482 }
483 return 0;
484}
485
486/*
487 * Process a main item.
488 */
489
490static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
491{
492 __u32 data;
493 int ret;
494
495 data = item_udata(item);
496
497 switch (item->tag) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200498 case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION:
499 ret = open_collection(parser, data & 0xff);
500 break;
501 case HID_MAIN_ITEM_TAG_END_COLLECTION:
502 ret = close_collection(parser);
503 break;
504 case HID_MAIN_ITEM_TAG_INPUT:
505 ret = hid_add_field(parser, HID_INPUT_REPORT, data);
506 break;
507 case HID_MAIN_ITEM_TAG_OUTPUT:
508 ret = hid_add_field(parser, HID_OUTPUT_REPORT, data);
509 break;
510 case HID_MAIN_ITEM_TAG_FEATURE:
511 ret = hid_add_field(parser, HID_FEATURE_REPORT, data);
512 break;
513 default:
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100514 hid_err(parser->device, "unknown main item tag 0x%x\n", item->tag);
Jiri Slaby880d29f2008-06-18 23:55:41 +0200515 ret = 0;
Jiri Kosinadde58452006-12-08 18:40:44 +0100516 }
517
518 memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */
519
520 return ret;
521}
522
523/*
524 * Process a reserved item.
525 */
526
527static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item)
528{
Jiri Kosina58037eb2007-05-30 15:07:13 +0200529 dbg_hid("reserved item type, tag 0x%x\n", item->tag);
Jiri Kosinadde58452006-12-08 18:40:44 +0100530 return 0;
531}
532
533/*
534 * Free a report and all registered fields. The field->usage and
535 * field->value table's are allocated behind the field, so we need
536 * only to free(field) itself.
537 */
538
539static void hid_free_report(struct hid_report *report)
540{
541 unsigned n;
542
543 for (n = 0; n < report->maxfield; n++)
544 kfree(report->field[n]);
545 kfree(report);
546}
547
548/*
549 * Free a device structure, all reports, and all fields.
550 */
551
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200552static void hid_device_release(struct device *dev)
Jiri Kosinadde58452006-12-08 18:40:44 +0100553{
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200554 struct hid_device *device = container_of(dev, struct hid_device, dev);
555 unsigned i, j;
Jiri Kosinadde58452006-12-08 18:40:44 +0100556
557 for (i = 0; i < HID_REPORT_TYPES; i++) {
558 struct hid_report_enum *report_enum = device->report_enum + i;
559
560 for (j = 0; j < 256; j++) {
561 struct hid_report *report = report_enum->report_id_hash[j];
562 if (report)
563 hid_free_report(report);
564 }
565 }
566
567 kfree(device->rdesc);
Jiri Kosina767fe782007-01-24 23:05:07 +0100568 kfree(device->collection);
Jiri Kosinadde58452006-12-08 18:40:44 +0100569 kfree(device);
570}
571
572/*
573 * Fetch a report description item from the data stream. We support long
574 * items, though they are not used yet.
575 */
576
577static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
578{
579 u8 b;
580
581 if ((end - start) <= 0)
582 return NULL;
583
584 b = *start++;
585
586 item->type = (b >> 2) & 3;
587 item->tag = (b >> 4) & 15;
588
589 if (item->tag == HID_ITEM_TAG_LONG) {
590
591 item->format = HID_ITEM_FORMAT_LONG;
592
593 if ((end - start) < 2)
594 return NULL;
595
596 item->size = *start++;
597 item->tag = *start++;
598
599 if ((end - start) < item->size)
600 return NULL;
601
602 item->data.longdata = start;
603 start += item->size;
604 return start;
605 }
606
607 item->format = HID_ITEM_FORMAT_SHORT;
608 item->size = b & 3;
609
610 switch (item->size) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200611 case 0:
612 return start;
Jiri Kosinadde58452006-12-08 18:40:44 +0100613
Jiri Slaby880d29f2008-06-18 23:55:41 +0200614 case 1:
615 if ((end - start) < 1)
616 return NULL;
617 item->data.u8 = *start++;
618 return start;
Jiri Kosinadde58452006-12-08 18:40:44 +0100619
Jiri Slaby880d29f2008-06-18 23:55:41 +0200620 case 2:
621 if ((end - start) < 2)
622 return NULL;
623 item->data.u16 = get_unaligned_le16(start);
624 start = (__u8 *)((__le16 *)start + 1);
625 return start;
Jiri Kosinadde58452006-12-08 18:40:44 +0100626
Jiri Slaby880d29f2008-06-18 23:55:41 +0200627 case 3:
628 item->size++;
629 if ((end - start) < 4)
630 return NULL;
631 item->data.u32 = get_unaligned_le32(start);
632 start = (__u8 *)((__le32 *)start + 1);
633 return start;
Jiri Kosinadde58452006-12-08 18:40:44 +0100634 }
635
636 return NULL;
637}
638
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200639/**
640 * hid_parse_report - parse device report
641 *
642 * @device: hid device
643 * @start: report start
644 * @size: report size
645 *
Jiri Kosinadde58452006-12-08 18:40:44 +0100646 * Parse a report description into a hid_device structure. Reports are
647 * enumerated, fields are attached to these reports.
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200648 * 0 returned on success, otherwise nonzero error value.
Jiri Kosinadde58452006-12-08 18:40:44 +0100649 */
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200650int hid_parse_report(struct hid_device *device, __u8 *start,
651 unsigned size)
Jiri Kosinadde58452006-12-08 18:40:44 +0100652{
Jiri Kosinadde58452006-12-08 18:40:44 +0100653 struct hid_parser *parser;
654 struct hid_item item;
655 __u8 *end;
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200656 int ret;
Jiri Kosinadde58452006-12-08 18:40:44 +0100657 static int (*dispatch_type[])(struct hid_parser *parser,
658 struct hid_item *item) = {
659 hid_parser_main,
660 hid_parser_global,
661 hid_parser_local,
662 hid_parser_reserved
663 };
664
Jiri Slabyc500c972008-05-16 11:49:16 +0200665 if (device->driver->report_fixup)
Nikolai Kondrashov73e40082010-08-06 23:03:06 +0400666 start = device->driver->report_fixup(device, start, &size);
Jiri Slabyc500c972008-05-16 11:49:16 +0200667
Julia Lawall1721a232010-05-15 23:19:30 +0200668 device->rdesc = kmemdup(start, size, GFP_KERNEL);
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200669 if (device->rdesc == NULL)
670 return -ENOMEM;
Jiri Kosinadde58452006-12-08 18:40:44 +0100671 device->rsize = size;
672
Joe Perchesfe258022010-12-09 19:29:04 -0800673 parser = vzalloc(sizeof(struct hid_parser));
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200674 if (!parser) {
675 ret = -ENOMEM;
676 goto err;
Jiri Kosinadde58452006-12-08 18:40:44 +0100677 }
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200678
Jiri Kosinadde58452006-12-08 18:40:44 +0100679 parser->device = device;
680
681 end = start + size;
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200682 ret = -EINVAL;
Jiri Kosinadde58452006-12-08 18:40:44 +0100683 while ((start = fetch_item(start, end, &item)) != NULL) {
684
685 if (item.format != HID_ITEM_FORMAT_SHORT) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100686 hid_err(device, "unexpected long global item\n");
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200687 goto err;
Jiri Kosinadde58452006-12-08 18:40:44 +0100688 }
689
690 if (dispatch_type[item.type](parser, &item)) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100691 hid_err(device, "item %u %u %u %u parsing failed\n",
Joe Perches4291ee32010-12-09 19:29:03 -0800692 item.format, (unsigned)item.size,
693 (unsigned)item.type, (unsigned)item.tag);
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200694 goto err;
Jiri Kosinadde58452006-12-08 18:40:44 +0100695 }
696
697 if (start == end) {
698 if (parser->collection_stack_ptr) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100699 hid_err(device, "unbalanced collection at end of report description\n");
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200700 goto err;
Jiri Kosinadde58452006-12-08 18:40:44 +0100701 }
702 if (parser->local.delimiter_depth) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100703 hid_err(device, "unbalanced delimiter at end of report description\n");
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200704 goto err;
Jiri Kosinadde58452006-12-08 18:40:44 +0100705 }
Jiri Kosina47a80ed2007-03-12 14:55:12 +0100706 vfree(parser);
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200707 return 0;
Jiri Kosinadde58452006-12-08 18:40:44 +0100708 }
709 }
710
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100711 hid_err(device, "item fetching failed at offset %d\n", (int)(end - start));
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200712err:
Jiri Kosina47a80ed2007-03-12 14:55:12 +0100713 vfree(parser);
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200714 return ret;
Jiri Kosinadde58452006-12-08 18:40:44 +0100715}
Jiri Kosina229695e2006-12-08 18:40:53 +0100716EXPORT_SYMBOL_GPL(hid_parse_report);
Jiri Kosinadde58452006-12-08 18:40:44 +0100717
718/*
719 * Convert a signed n-bit integer to signed 32-bit integer. Common
720 * cases are done through the compiler, the screwed things has to be
721 * done by hand.
722 */
723
724static s32 snto32(__u32 value, unsigned n)
725{
726 switch (n) {
Jiri Slaby880d29f2008-06-18 23:55:41 +0200727 case 8: return ((__s8)value);
728 case 16: return ((__s16)value);
729 case 32: return ((__s32)value);
Jiri Kosinadde58452006-12-08 18:40:44 +0100730 }
731 return value & (1 << (n - 1)) ? value | (-1 << n) : value;
732}
733
734/*
735 * Convert a signed 32-bit integer to a signed n-bit integer.
736 */
737
738static u32 s32ton(__s32 value, unsigned n)
739{
740 s32 a = value >> (n - 1);
741 if (a && a != -1)
742 return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
743 return value & ((1 << n) - 1);
744}
745
746/*
747 * Extract/implement a data field from/to a little endian report (bit array).
748 *
749 * Code sort-of follows HID spec:
750 * http://www.usb.org/developers/devclass_docs/HID1_11.pdf
751 *
752 * While the USB HID spec allows unlimited length bit fields in "report
753 * descriptors", most devices never use more than 16 bits.
754 * One model of UPS is claimed to report "LINEV" as a 32-bit field.
755 * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
756 */
757
Joe Perches16ee4cc2010-12-09 19:29:05 -0800758static __u32 extract(const struct hid_device *hid, __u8 *report,
759 unsigned offset, unsigned n)
Jiri Kosinadde58452006-12-08 18:40:44 +0100760{
761 u64 x;
762
Jiri Kosinac4124c92007-11-30 11:12:58 +0100763 if (n > 32)
Joe Perches4291ee32010-12-09 19:29:03 -0800764 hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n",
765 n, current->comm);
Jiri Kosinadde58452006-12-08 18:40:44 +0100766
767 report += offset >> 3; /* adjust byte index */
Jiri Kosina229695e2006-12-08 18:40:53 +0100768 offset &= 7; /* now only need bit offset into one byte */
Harvey Harrisonc1050682008-04-29 01:03:31 -0700769 x = get_unaligned_le64(report);
Jiri Kosina229695e2006-12-08 18:40:53 +0100770 x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */
Jiri Kosinadde58452006-12-08 18:40:44 +0100771 return (u32) x;
772}
773
774/*
775 * "implement" : set bits in a little endian bit stream.
776 * Same concepts as "extract" (see comments above).
777 * The data mangled in the bit stream remains in little endian
778 * order the whole time. It make more sense to talk about
779 * endianness of register values by considering a register
780 * a "cached" copy of the little endiad bit stream.
781 */
Joe Perches16ee4cc2010-12-09 19:29:05 -0800782static void implement(const struct hid_device *hid, __u8 *report,
783 unsigned offset, unsigned n, __u32 value)
Jiri Kosinadde58452006-12-08 18:40:44 +0100784{
Harvey Harrison6f0168d2008-05-16 11:00:23 +0200785 u64 x;
Jiri Kosinadde58452006-12-08 18:40:44 +0100786 u64 m = (1ULL << n) - 1;
787
Jiri Kosinac4124c92007-11-30 11:12:58 +0100788 if (n > 32)
Joe Perches4291ee32010-12-09 19:29:03 -0800789 hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n",
790 __func__, n, current->comm);
Jiri Kosinadde58452006-12-08 18:40:44 +0100791
Jiri Kosinac4124c92007-11-30 11:12:58 +0100792 if (value > m)
Joe Perches4291ee32010-12-09 19:29:03 -0800793 hid_warn(hid, "%s() called with too large value %d! (%s)\n",
794 __func__, value, current->comm);
Jiri Kosinadde58452006-12-08 18:40:44 +0100795 WARN_ON(value > m);
796 value &= m;
797
798 report += offset >> 3;
799 offset &= 7;
800
Harvey Harrison6f0168d2008-05-16 11:00:23 +0200801 x = get_unaligned_le64(report);
802 x &= ~(m << offset);
803 x |= ((u64)value) << offset;
804 put_unaligned_le64(x, report);
Jiri Kosinadde58452006-12-08 18:40:44 +0100805}
806
807/*
808 * Search an array for a value.
809 */
810
Joe Perches16ee4cc2010-12-09 19:29:05 -0800811static int search(__s32 *array, __s32 value, unsigned n)
Jiri Kosinadde58452006-12-08 18:40:44 +0100812{
813 while (n--) {
814 if (*array++ == value)
815 return 0;
816 }
817 return -1;
818}
819
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200820/**
821 * hid_match_report - check if driver's raw_event should be called
822 *
823 * @hid: hid device
824 * @report_type: type to match against
825 *
826 * compare hid->driver->report_table->report_type to report->type
827 */
828static int hid_match_report(struct hid_device *hid, struct hid_report *report)
Jiri Kosinadde58452006-12-08 18:40:44 +0100829{
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200830 const struct hid_report_id *id = hid->driver->report_table;
831
832 if (!id) /* NULL means all */
833 return 1;
834
835 for (; id->report_type != HID_TERMINATOR; id++)
836 if (id->report_type == HID_ANY_ID ||
837 id->report_type == report->type)
838 return 1;
839 return 0;
840}
841
842/**
843 * hid_match_usage - check if driver's event should be called
844 *
845 * @hid: hid device
846 * @usage: usage to match against
847 *
848 * compare hid->driver->usage_table->usage_{type,code} to
849 * usage->usage_{type,code}
850 */
851static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage)
852{
853 const struct hid_usage_id *id = hid->driver->usage_table;
854
855 if (!id) /* NULL means all */
856 return 1;
857
858 for (; id->usage_type != HID_ANY_ID - 1; id++)
859 if ((id->usage_hid == HID_ANY_ID ||
860 id->usage_hid == usage->hid) &&
861 (id->usage_type == HID_ANY_ID ||
862 id->usage_type == usage->type) &&
863 (id->usage_code == HID_ANY_ID ||
864 id->usage_code == usage->code))
865 return 1;
866 return 0;
867}
868
869static void hid_process_event(struct hid_device *hid, struct hid_field *field,
870 struct hid_usage *usage, __s32 value, int interrupt)
871{
872 struct hid_driver *hdrv = hid->driver;
873 int ret;
874
Jiri Kosinacd667ce2009-06-12 15:20:57 +0200875 hid_dump_input(hid, usage, value);
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200876
877 if (hdrv && hdrv->event && hid_match_usage(hid, usage)) {
878 ret = hdrv->event(hid, field, usage, value);
879 if (ret != 0) {
880 if (ret < 0)
Jiri Kosina8c3d52f2011-12-15 11:00:38 +0100881 hid_err(hid, "%s's event failed with %d\n",
Jiri Slaby85cdaf52008-05-16 11:49:15 +0200882 hdrv->name, ret);
883 return;
884 }
885 }
886
Jiri Kosinadde58452006-12-08 18:40:44 +0100887 if (hid->claimed & HID_CLAIMED_INPUT)
888 hidinput_hid_event(hid, field, usage, value);
Jiri Kosinaaa938f72006-12-08 18:41:10 +0100889 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event)
890 hid->hiddev_hid_event(hid, field, usage, value);
Jiri Kosinadde58452006-12-08 18:40:44 +0100891}
892
893/*
894 * Analyse a received field, and fetch the data from it. The field
895 * content is stored for next report processing (we do differential
896 * reporting to the layer).
897 */
898
Adrian Bunkabdff0f2008-03-31 01:53:56 +0200899static void hid_input_field(struct hid_device *hid, struct hid_field *field,
900 __u8 *data, int interrupt)
Jiri Kosinadde58452006-12-08 18:40:44 +0100901{
902 unsigned n;
903 unsigned count = field->report_count;
904 unsigned offset = field->report_offset;
905 unsigned size = field->report_size;
906 __s32 min = field->logical_minimum;
907 __s32 max = field->logical_maximum;
908 __s32 *value;
909
Joe Perchesa3789a12010-12-09 19:29:07 -0800910 value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC);
911 if (!value)
Jiri Kosinadde58452006-12-08 18:40:44 +0100912 return;
913
914 for (n = 0; n < count; n++) {
915
Joe Perches4291ee32010-12-09 19:29:03 -0800916 value[n] = min < 0 ?
917 snto32(extract(hid, data, offset + n * size, size),
918 size) :
919 extract(hid, data, offset + n * size, size);
Jiri Kosinadde58452006-12-08 18:40:44 +0100920
Joe Perches4291ee32010-12-09 19:29:03 -0800921 /* Ignore report if ErrorRollOver */
922 if (!(field->flags & HID_MAIN_ITEM_VARIABLE) &&
923 value[n] >= min && value[n] <= max &&
924 field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1)
925 goto exit;
Jiri Kosinadde58452006-12-08 18:40:44 +0100926 }
927
928 for (n = 0; n < count; n++) {
929
930 if (HID_MAIN_ITEM_VARIABLE & field->flags) {
931 hid_process_event(hid, field, &field->usage[n], value[n], interrupt);
932 continue;
933 }
934
935 if (field->value[n] >= min && field->value[n] <= max
936 && field->usage[field->value[n] - min].hid
937 && search(value, field->value[n], count))
938 hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt);
939
940 if (value[n] >= min && value[n] <= max
941 && field->usage[value[n] - min].hid
942 && search(field->value, value[n], count))
943 hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt);
944 }
945
946 memcpy(field->value, value, count * sizeof(__s32));
947exit:
948 kfree(value);
949}
Jiri Kosinadde58452006-12-08 18:40:44 +0100950
951/*
952 * Output the field into the report.
953 */
954
Joe Perches4291ee32010-12-09 19:29:03 -0800955static void hid_output_field(const struct hid_device *hid,
956 struct hid_field *field, __u8 *data)
Jiri Kosinadde58452006-12-08 18:40:44 +0100957{
958 unsigned count = field->report_count;
959 unsigned offset = field->report_offset;
960 unsigned size = field->report_size;
961 unsigned n;
962
963 for (n = 0; n < count; n++) {
964 if (field->logical_minimum < 0) /* signed values */
Joe Perches4291ee32010-12-09 19:29:03 -0800965 implement(hid, data, offset + n * size, size,
966 s32ton(field->value[n], size));
Jiri Kosinadde58452006-12-08 18:40:44 +0100967 else /* unsigned values */
Joe Perches4291ee32010-12-09 19:29:03 -0800968 implement(hid, data, offset + n * size, size,
969 field->value[n]);
Jiri Kosinadde58452006-12-08 18:40:44 +0100970 }
971}
972
973/*
974 * Create a report.
975 */
976
Jiri Kosina229695e2006-12-08 18:40:53 +0100977void hid_output_report(struct hid_report *report, __u8 *data)
Jiri Kosinadde58452006-12-08 18:40:44 +0100978{
979 unsigned n;
980
981 if (report->id > 0)
982 *data++ = report->id;
983
Pete Zaitcev75c28df2010-04-12 12:16:11 -0600984 memset(data, 0, ((report->size - 1) >> 3) + 1);
Jiri Kosinadde58452006-12-08 18:40:44 +0100985 for (n = 0; n < report->maxfield; n++)
Joe Perches4291ee32010-12-09 19:29:03 -0800986 hid_output_field(report->device, report->field[n], data);
Jiri Kosinadde58452006-12-08 18:40:44 +0100987}
Jiri Kosina229695e2006-12-08 18:40:53 +0100988EXPORT_SYMBOL_GPL(hid_output_report);
Jiri Kosinadde58452006-12-08 18:40:44 +0100989
990/*
991 * Set a field value. The report this field belongs to has to be
992 * created and transferred to the device, to set this value in the
993 * device.
994 */
995
996int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
997{
998 unsigned size = field->report_size;
999
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001000 hid_dump_input(field->report->device, field->usage + offset, value);
Jiri Kosinadde58452006-12-08 18:40:44 +01001001
1002 if (offset >= field->report_count) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +01001003 hid_err(field->report->device, "offset (%d) exceeds report_count (%d)\n",
1004 offset, field->report_count);
Jiri Kosinadde58452006-12-08 18:40:44 +01001005 return -1;
1006 }
1007 if (field->logical_minimum < 0) {
1008 if (value != snto32(s32ton(value, size), size)) {
Jiri Kosina8c3d52f2011-12-15 11:00:38 +01001009 hid_err(field->report->device, "value %d is out of range\n", value);
Jiri Kosinadde58452006-12-08 18:40:44 +01001010 return -1;
1011 }
1012 }
1013 field->value[offset] = value;
1014 return 0;
1015}
Jiri Kosina229695e2006-12-08 18:40:53 +01001016EXPORT_SYMBOL_GPL(hid_set_field);
Jiri Kosinadde58452006-12-08 18:40:44 +01001017
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001018static struct hid_report *hid_get_report(struct hid_report_enum *report_enum,
1019 const u8 *data)
1020{
1021 struct hid_report *report;
1022 unsigned int n = 0; /* Normally report number is 0 */
1023
1024 /* Device uses numbered reports, data[0] is report number */
1025 if (report_enum->numbered)
1026 n = *data;
1027
1028 report = report_enum->report_id_hash[n];
1029 if (report == NULL)
1030 dbg_hid("undefined report_id %u received\n", n);
1031
1032 return report;
1033}
1034
1035void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
1036 int interrupt)
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001037{
1038 struct hid_report_enum *report_enum = hid->report_enum + type;
1039 struct hid_report *report;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001040 unsigned int a;
1041 int rsize, csize = size;
1042 u8 *cdata = data;
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001043
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001044 report = hid_get_report(report_enum, data);
1045 if (!report)
1046 return;
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001047
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001048 if (report_enum->numbered) {
1049 cdata++;
1050 csize--;
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001051 }
1052
1053 rsize = ((report->size - 1) >> 3) + 1;
1054
Armando Visconti966922f2011-05-19 21:41:22 +02001055 if (rsize > HID_MAX_BUFFER_SIZE)
1056 rsize = HID_MAX_BUFFER_SIZE;
1057
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001058 if (csize < rsize) {
1059 dbg_hid("report %d is too short, (%d < %d)\n", report->id,
1060 csize, rsize);
1061 memset(cdata + csize, 0, rsize - csize);
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001062 }
1063
1064 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
1065 hid->hiddev_report_event(hid, report);
Alan Ott5a38f2c2010-04-26 18:34:46 -04001066 if (hid->claimed & HID_CLAIMED_HIDRAW)
1067 hidraw_report_event(hid, data, size);
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001068
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001069 for (a = 0; a < report->maxfield; a++)
1070 hid_input_field(hid, report->field[a], cdata, interrupt);
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001071
1072 if (hid->claimed & HID_CLAIMED_INPUT)
1073 hidinput_report_event(hid, report);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001074}
1075EXPORT_SYMBOL_GPL(hid_report_raw_event);
1076
1077/**
1078 * hid_input_report - report data from lower layer (usb, bt...)
1079 *
1080 * @hid: hid device
1081 * @type: HID report type (HID_*_REPORT)
1082 * @data: report contents
1083 * @size: size of data parameter
Jiri Kosinaff9b00a2009-10-01 16:03:13 +02001084 * @interrupt: distinguish between interrupt and control transfers
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001085 *
1086 * This is data entry for lower layers.
1087 */
1088int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt)
1089{
Julia Lawall76c317d2009-07-19 17:26:13 +02001090 struct hid_report_enum *report_enum;
1091 struct hid_driver *hdrv;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001092 struct hid_report *report;
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001093 char *buf;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001094 unsigned int i;
Jiri Kosina45dc1ac2011-08-10 14:02:59 +02001095 int ret = 0;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001096
David Herrmann4ea54542011-08-10 14:02:07 +02001097 if (!hid)
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001098 return -ENODEV;
David Herrmann4ea54542011-08-10 14:02:07 +02001099
1100 if (down_trylock(&hid->driver_lock))
1101 return -EBUSY;
1102
1103 if (!hid->driver) {
1104 ret = -ENODEV;
1105 goto unlock;
1106 }
Julia Lawall76c317d2009-07-19 17:26:13 +02001107 report_enum = hid->report_enum + type;
1108 hdrv = hid->driver;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001109
1110 if (!size) {
1111 dbg_hid("empty report\n");
David Herrmann4ea54542011-08-10 14:02:07 +02001112 ret = -1;
1113 goto unlock;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001114 }
1115
Jiri Kosinad1ff6522009-09-15 11:59:49 +02001116 buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001117
Jiri Kosinaf77e3472010-03-18 14:11:53 +01001118 if (!buf)
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001119 goto nomem;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001120
1121 /* dump the report */
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001122 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
Jiri Kosina1caea612010-03-18 12:09:53 +01001123 "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un");
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001124 hid_debug_event(hid, buf);
Jiri Kosina1caea612010-03-18 12:09:53 +01001125
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001126 for (i = 0; i < size; i++) {
1127 snprintf(buf, HID_DEBUG_BUFSIZE - 1,
1128 " %02x", data[i]);
1129 hid_debug_event(hid, buf);
1130 }
1131 hid_debug_event(hid, "\n");
Jiri Kosinacd667ce2009-06-12 15:20:57 +02001132 kfree(buf);
1133
1134nomem:
Jiri Kosinaf77e3472010-03-18 14:11:53 +01001135 report = hid_get_report(report_enum, data);
1136
David Herrmann4ea54542011-08-10 14:02:07 +02001137 if (!report) {
1138 ret = -1;
1139 goto unlock;
1140 }
Jiri Kosinaf77e3472010-03-18 14:11:53 +01001141
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001142 if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) {
1143 ret = hdrv->raw_event(hid, report, data, size);
David Herrmann4ea54542011-08-10 14:02:07 +02001144 if (ret != 0) {
1145 ret = ret < 0 ? ret : 0;
1146 goto unlock;
1147 }
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001148 }
1149
1150 hid_report_raw_event(hid, type, data, size, interrupt);
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001151
David Herrmann4ea54542011-08-10 14:02:07 +02001152unlock:
1153 up(&hid->driver_lock);
Jiri Kosina45dc1ac2011-08-10 14:02:59 +02001154 return ret;
Jiri Kosinaaa8de2f2006-12-08 18:41:17 +01001155}
1156EXPORT_SYMBOL_GPL(hid_input_report);
1157
Jiri Kosina0f37cd02008-08-20 19:13:52 +02001158static bool hid_match_one_id(struct hid_device *hdev,
1159 const struct hid_device_id *id)
1160{
1161 return id->bus == hdev->bus &&
1162 (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) &&
1163 (id->product == HID_ANY_ID || id->product == hdev->product);
1164}
1165
Jeremy Fitzhardingebbc21cf2011-12-02 11:12:36 -08001166const struct hid_device_id *hid_match_id(struct hid_device *hdev,
Jiri Kosina0f37cd02008-08-20 19:13:52 +02001167 const struct hid_device_id *id)
1168{
1169 for (; id->bus; id++)
1170 if (hid_match_one_id(hdev, id))
1171 return id;
1172
1173 return NULL;
1174}
1175
1176static const struct hid_device_id hid_hiddev_list[] = {
Richard Hughesc0bd6a42008-08-27 11:19:37 +02001177 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) },
1178 { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) },
Jiri Kosina0f37cd02008-08-20 19:13:52 +02001179 { }
1180};
1181
1182static bool hid_hiddev(struct hid_device *hdev)
1183{
1184 return !!hid_match_id(hdev, hid_hiddev_list);
1185}
1186
Alan Ott6d3bfb72011-01-23 22:50:18 -05001187
1188static ssize_t
1189read_report_descriptor(struct file *filp, struct kobject *kobj,
1190 struct bin_attribute *attr,
1191 char *buf, loff_t off, size_t count)
1192{
1193 struct device *dev = container_of(kobj, struct device, kobj);
1194 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1195
1196 if (off >= hdev->rsize)
1197 return 0;
1198
1199 if (off + count > hdev->rsize)
1200 count = hdev->rsize - off;
1201
1202 memcpy(buf, hdev->rdesc + off, count);
1203
1204 return count;
1205}
1206
1207static struct bin_attribute dev_bin_attr_report_desc = {
1208 .attr = { .name = "report_descriptor", .mode = 0444 },
1209 .read = read_report_descriptor,
1210 .size = HID_MAX_DESCRIPTOR_SIZE,
1211};
1212
Jiri Slaby93c10132008-06-27 00:04:24 +02001213int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
1214{
1215 static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
1216 "Joystick", "Gamepad", "Keyboard", "Keypad",
1217 "Multi-Axis Controller"
1218 };
1219 const char *type, *bus;
1220 char buf[64];
1221 unsigned int i;
1222 int len;
Alan Ott6d3bfb72011-01-23 22:50:18 -05001223 int ret;
Jiri Slaby93c10132008-06-27 00:04:24 +02001224
Bastien Nocerab5e5a372010-04-16 17:19:50 +01001225 if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE)
1226 connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV);
Daniel Mack3a343ee2010-07-12 19:28:27 +02001227 if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE)
1228 connect_mask |= HID_CONNECT_HIDINPUT_FORCE;
Jiri Slaby93c10132008-06-27 00:04:24 +02001229 if (hdev->bus != BUS_USB)
1230 connect_mask &= ~HID_CONNECT_HIDDEV;
Jiri Kosina0f37cd02008-08-20 19:13:52 +02001231 if (hid_hiddev(hdev))
1232 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
Jiri Slaby93c10132008-06-27 00:04:24 +02001233
1234 if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev,
1235 connect_mask & HID_CONNECT_HIDINPUT_FORCE))
1236 hdev->claimed |= HID_CLAIMED_INPUT;
Benjamin Tissoiresb77c3922011-09-21 16:56:54 +02001237 if (hdev->quirks & HID_QUIRK_MULTITOUCH) {
1238 /* this device should be handled by hid-multitouch, skip it */
Benjamin Tissoiresb77c3922011-09-21 16:56:54 +02001239 return -ENODEV;
1240 }
1241
Jiri Slaby93c10132008-06-27 00:04:24 +02001242 if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect &&
1243 !hdev->hiddev_connect(hdev,
1244 connect_mask & HID_CONNECT_HIDDEV_FORCE))
1245 hdev->claimed |= HID_CLAIMED_HIDDEV;
1246 if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev))
1247 hdev->claimed |= HID_CLAIMED_HIDRAW;
1248
1249 if (!hdev->claimed) {
Joe Perches4291ee32010-12-09 19:29:03 -08001250 hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n");
Jiri Slaby93c10132008-06-27 00:04:24 +02001251 return -ENODEV;
1252 }
1253
1254 if ((hdev->claimed & HID_CLAIMED_INPUT) &&
1255 (connect_mask & HID_CONNECT_FF) && hdev->ff_init)
1256 hdev->ff_init(hdev);
1257
1258 len = 0;
1259 if (hdev->claimed & HID_CLAIMED_INPUT)
1260 len += sprintf(buf + len, "input");
1261 if (hdev->claimed & HID_CLAIMED_HIDDEV)
1262 len += sprintf(buf + len, "%shiddev%d", len ? "," : "",
1263 hdev->minor);
1264 if (hdev->claimed & HID_CLAIMED_HIDRAW)
1265 len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
1266 ((struct hidraw *)hdev->hidraw)->minor);
1267
1268 type = "Device";
1269 for (i = 0; i < hdev->maxcollection; i++) {
1270 struct hid_collection *col = &hdev->collection[i];
1271 if (col->type == HID_COLLECTION_APPLICATION &&
1272 (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK &&
1273 (col->usage & 0xffff) < ARRAY_SIZE(types)) {
1274 type = types[col->usage & 0xffff];
1275 break;
1276 }
1277 }
1278
1279 switch (hdev->bus) {
1280 case BUS_USB:
1281 bus = "USB";
1282 break;
1283 case BUS_BLUETOOTH:
1284 bus = "BLUETOOTH";
1285 break;
1286 default:
1287 bus = "<UNKNOWN>";
1288 }
1289
Alan Ott6d3bfb72011-01-23 22:50:18 -05001290 ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
1291 if (ret)
1292 hid_warn(hdev,
1293 "can't create sysfs report descriptor attribute err: %d\n", ret);
1294
Joe Perches4291ee32010-12-09 19:29:03 -08001295 hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
1296 buf, bus, hdev->version >> 8, hdev->version & 0xff,
1297 type, hdev->name, hdev->phys);
Jiri Slaby93c10132008-06-27 00:04:24 +02001298
1299 return 0;
1300}
1301EXPORT_SYMBOL_GPL(hid_connect);
1302
Jiri Kosinac4c259b2009-09-15 16:27:45 +02001303void hid_disconnect(struct hid_device *hdev)
1304{
Alan Ott6d3bfb72011-01-23 22:50:18 -05001305 device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
Jiri Kosinac4c259b2009-09-15 16:27:45 +02001306 if (hdev->claimed & HID_CLAIMED_INPUT)
1307 hidinput_disconnect(hdev);
1308 if (hdev->claimed & HID_CLAIMED_HIDDEV)
1309 hdev->hiddev_disconnect(hdev);
1310 if (hdev->claimed & HID_CLAIMED_HIDRAW)
1311 hidraw_disconnect(hdev);
1312}
1313EXPORT_SYMBOL_GPL(hid_disconnect);
1314
Jiri Kosinabae7eb32009-01-28 23:06:37 +01001315/* a list of devices for which there is a specialized driver on HID bus */
Dmitry Torokhovce06b9d2010-11-28 16:37:14 +01001316static const struct hid_device_id hid_have_special_driver[] = {
Stephane Chattyb6353f42009-12-22 23:04:17 +01001317 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) },
Stephane Chatty6dec1432010-04-11 14:51:24 +02001318 { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) },
Jiri Slaby14a21cd2008-06-23 23:31:09 +02001319 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
1320 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
Lech Perczakb7e1b202010-09-16 23:19:33 +02001321 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) },
Sergei Kolzunc0dbcc32010-07-19 12:13:23 +02001322 { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) },
Benjamin Tissoirese6aac342011-05-19 14:18:13 +02001323 { HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR, USB_DEVICE_ID_ACTIONSTAR_1011) },
Jiri Kosinadf9bcac2008-10-14 22:45:40 +02001324 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001325 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
1326 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) },
Michael Poole128537c2010-02-06 12:24:36 -05001327 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) },
Chase Douglasa4622302010-08-31 21:56:23 -04001328 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001329 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
1330 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
1331 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
1332 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) },
1333 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) },
1334 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) },
1335 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) },
1336 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) },
1337 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) },
1338 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) },
1339 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) },
Ryan Finniefef3f572009-03-05 10:18:01 +01001340 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI) },
1341 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO) },
1342 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001343 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) },
1344 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) },
1345 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) },
1346 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) },
1347 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) },
1348 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) },
Jan Scholzee8a1a02008-11-26 15:33:45 +01001349 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) },
1350 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) },
1351 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001352 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) },
1353 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) },
1354 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) },
1355 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
1356 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
1357 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
Henrik Rydberga96d6ef2008-11-04 20:03:45 +01001358 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
1359 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
1360 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
Edgar (gimli) Hucek99b9f752010-11-03 10:36:18 -04001361 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) },
1362 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) },
1363 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) },
1364 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) },
1365 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) },
1366 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) },
Andy Botting47340bd2011-03-12 20:27:22 -08001367 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
1368 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
1369 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
Gökçen Eraslan213f9da2011-10-22 22:39:06 +03001370 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
1371 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
1372 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
Dan Bastone4a4c8792011-07-31 07:40:49 -04001373 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) },
1374 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) },
1375 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) },
Jiri Kosinaf6f554f2011-08-10 14:12:52 +02001376 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) },
1377 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) },
1378 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) },
Jiri Kosinab3aec7b2011-10-25 09:59:04 +02001379 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
1380 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
1381 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
Christian Schuerer-Waldheim23aeb612010-01-06 14:49:57 +01001382 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
1383 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
1384 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
Andreas Kristad734bc2011-10-28 18:50:39 +02001385 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001386 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1387 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
Jiri Kosinaeaca1382010-09-08 14:31:47 +02001388 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) },
Roland Baumcec15a02010-09-08 14:27:55 +02001389 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) },
Jiri Slabyb5635b12008-06-24 23:24:57 +02001390 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
Wayne Thomasbf280622010-04-29 00:45:01 +02001391 { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) },
Jiri Kosinac3dc66d2010-08-30 15:43:25 +02001392 { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) },
Benjamin Tissoires5519cab2011-01-07 23:45:50 +01001393 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) },
Stephane Chatty36213e12010-04-15 00:28:11 +02001394 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) },
Benjamin Tissoiresbc5ab082011-01-08 12:15:41 +01001395 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) },
Stephane Chattyba4d8ab2010-04-22 23:24:36 +02001396 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) },
François Jaouen272036e2010-10-13 10:47:32 +02001397 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) },
Jiri Slaby3b239cd2008-06-24 20:42:25 +02001398 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
Raphaël Doursenaud1ce31b22010-04-08 13:40:52 +02001399 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) },
Jiri Slabyfcfacfd2008-06-24 22:48:52 +02001400 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
Dennis Küglerb9e4b1e2010-11-23 21:40:09 +01001401 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) },
Keng-Yu Lin3596bb92012-02-02 10:31:26 +01001402 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
Austin Zhang942fd422011-05-28 02:03:47 +08001403 { HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) },
Don Prince3a370ca2010-05-12 15:18:59 +02001404 { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
Benjamin Tissoires79603dc2011-05-19 14:18:14 +02001405 { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, USB_DEVICE_ID_CVTOUCH_SCREEN) },
Jiri Slaby0f221322008-06-23 22:54:08 +02001406 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
1407 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) },
Jiri Kosinae8d0eab2009-12-02 22:54:11 +01001408 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) },
Jiri Slaby0f221322008-06-23 22:54:08 +02001409 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
Benjamin Tissoiresa3b5e572011-01-07 23:46:30 +01001410 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) },
Richard Walmsley3f866fb2009-03-04 22:12:04 +13001411 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) },
Nikolai Kondrashove05eefb2011-01-28 14:50:52 +03001412 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) },
Benjamin Tissoirese36f6902011-11-23 10:54:31 +01001413 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) },
1414 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) },
1415 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) },
Benjamin Tissoiresfd1d1522012-03-06 10:53:47 +01001416 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) },
1417 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) },
Benjamin Tissoirese36f6902011-11-23 10:54:31 +01001418 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) },
1419 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) },
Marek Vasutbb9ff212011-11-23 10:54:32 +01001420 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) },
Benjamin Tissoirese36f6902011-11-23 10:54:31 +01001421 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) },
Richard Nauber64b386e2010-06-28 18:54:25 +02001422 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
Benjamin Tissoiresc04abee2011-05-19 11:37:29 +02001423 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2515) },
Ignaz Forster04561c52010-11-01 15:13:37 -04001424 { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) },
Jiri Slaby1f243e32008-06-24 21:11:21 +02001425 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
Andreas Nielsen4d5df5d2012-03-19 15:41:03 +01001426 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_FRUCTEL, USB_DEVICE_ID_GAMETEL_MT_MODE) },
Jiri Kosina5181e592008-11-17 01:44:38 +01001427 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
Jiri Kosina578f3a32008-11-20 15:55:38 +01001428 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) },
Benjamin Tissoires5572da02011-01-07 23:47:27 +01001429 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) },
Benjamin Tissoiresee0fbd12011-05-19 14:18:15 +02001430 { HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, USB_DEVICE_ID_GOODTOUCH_000f) },
Jiri Kosina5181e592008-11-17 01:44:38 +01001431 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
Lukasz Lubojanski42859e02008-12-11 22:07:59 +01001432 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) },
Jiri Slaby949f8fe2008-07-24 23:35:13 +02001433 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
Jiri Kosina1e093202008-10-17 11:52:23 +02001434 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) },
Cory Maccarronec2fd1a42010-05-22 13:00:28 -07001435 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) },
Benjamin Tissoires5519cab2011-01-07 23:45:50 +01001436 { HID_USB_DEVICE(USB_VENDOR_ID_HANVON, USB_DEVICE_ID_HANVON_MULTITOUCH) },
Benjamin Tissoires54580362011-11-29 13:13:12 +01001437 { HID_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) },
Stephane Chattya062cc52011-09-17 22:27:30 +02001438 { HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM, USB_DEVICE_ID_IDEACOM_IDC6650) },
Anssi Hannulad946e652011-06-27 00:07:31 +03001439 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) },
Austin Zhang4e61f0d2011-05-09 23:54:14 +08001440 { HID_USB_DEVICE(USB_VENDOR_ID_ILITEK, USB_DEVICE_ID_ILITEK_MULTITOUCH) },
Benjamin Tissoiresb2e76172011-02-15 15:33:48 +01001441 { HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS, USB_DEVICE_ID_IRTOUCH_INFRARED_USB) },
Jiri Kosinafdf93aa2009-03-04 16:09:40 +01001442 { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) },
Jiri Kosina177900e2011-02-17 15:12:45 +01001443 { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) },
Jiri Kosina79422742009-03-11 11:43:27 +01001444 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) },
Nikolai Kondrashov22ca20b22012-02-28 13:01:46 +02001445 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) },
1446 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) },
1447 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) },
Jiri Slabyb5635b12008-06-24 23:24:57 +02001448 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
Chris Schlund75b07022011-02-03 16:41:47 +01001449 { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) },
Jeff Brownc50bb1a2011-08-15 21:12:09 -07001450 { HID_USB_DEVICE(USB_VENDOR_ID_LG, USB_DEVICE_ID_LG_MULTITOUCH) },
Jiri Slaby5f22a792008-05-16 11:49:19 +02001451 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) },
1452 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) },
1453 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) },
1454 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) },
1455 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) },
1456 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) },
1457 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) },
Jiri Slaby5f22a792008-05-16 11:49:19 +02001458 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) },
1459 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) },
Jiri Slaby5f22a792008-05-16 11:49:19 +02001460 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) },
1461 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) },
Hendrik Iben2c6118e2010-10-04 15:39:49 +02001462 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) },
Jiri Slaby606bd0a2008-07-04 23:06:45 +02001463 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) },
1464 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) },
1465 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) },
Jiri Kosinafd30ea82009-06-23 12:11:31 +02001466 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) },
Jiri Slaby606bd0a2008-07-04 23:06:45 +02001467 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) },
Gary Stein74f292c2010-01-13 00:25:58 +01001468 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) },
Jiri Slaby606bd0a2008-07-04 23:06:45 +02001469 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) },
1470 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) },
Jiri Kosina5623a242011-03-17 00:43:23 +01001471 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL) },
Michal Malýe00ddc92011-09-10 21:28:23 +02001472 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL) },
Christophe Borivant243b7062009-04-17 11:39:39 +02001473 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) },
Peter Gundermannfdc68072011-05-03 10:15:03 +02001474 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G27_WHEEL) },
Konstantin Khlebnikov0944e962012-02-13 14:13:03 +04001475#if IS_ENABLED(CONFIG_HID_LOGITECH_DJ)
Nestor Lopez Casado534a7b82011-09-15 11:34:49 +02001476 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER) },
1477 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2) },
Konstantin Khlebnikov0944e962012-02-13 14:13:03 +04001478#endif
Simon Wood32c88cb2010-09-22 13:19:42 +02001479 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) },
Jiri Slaby606bd0a2008-07-04 23:06:45 +02001480 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) },
Jiri Kosina24985cf2009-11-13 10:45:53 +01001481 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) },
1482 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) },
Benjamin Tissoiresdf167c42011-05-18 15:27:24 +02001483 { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH) },
Benjamin Tissoiresc3ead6d2011-06-21 15:01:55 +02001484 { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH_DUAL) },
Bruno Prémont236db472010-03-30 22:33:50 +02001485 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) },
1486 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) },
Jiri Kosinab5801692011-07-22 12:11:15 +02001487 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) },
Jiri Slaby78a849a682008-06-20 21:26:11 +02001488 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
1489 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) },
1490 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
1491 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) },
Jiri Kosinaf3b83d72011-06-13 23:08:18 +03001492 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) },
Jiri Slaby78a849a682008-06-20 21:26:11 +02001493 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
Jiri Slaby3b8006e2008-06-25 00:07:50 +02001494 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
Rafi Rubin94011f92008-11-19 15:54:46 +01001495 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
micki6e328192010-06-19 11:37:29 +03001496 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) },
1497 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) },
1498 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) },
1499 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) },
1500 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) },
1501 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) },
1502 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) },
1503 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) },
1504 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) },
1505 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) },
1506 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) },
1507 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) },
1508 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) },
1509 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) },
1510 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) },
1511 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) },
1512 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) },
1513 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) },
Herton Ronaldo Krzesinski270fdc02011-03-16 14:13:53 -03001514 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) },
Johnathon Harriscd9ec302010-01-21 14:36:52 +00001515 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },
Denis Kovalev2258e862012-02-14 00:50:33 -08001516 { HID_USB_DEVICE(USB_VENDOR_ID_PANASONIC, USB_DEVICE_ID_PANABOARD_UBT780) },
1517 { HID_USB_DEVICE(USB_VENDOR_ID_PANASONIC, USB_DEVICE_ID_PANABOARD_UBT880) },
John Sung6ab3a9a2011-04-21 16:21:52 +02001518 { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_PCI) },
Jiri Slaby1e762532008-06-24 23:46:21 +02001519 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
Aaron Tianb7ea95f2011-12-15 11:09:06 +08001520 { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) },
1521 { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) },
1522 { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) },
Terry Lambertf6a04602011-10-14 17:18:54 -07001523 { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) },
Stephane Chatty49e47392010-01-13 00:29:16 +01001524 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
Alex Neblettf54405d2010-02-02 21:16:03 -08001525 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) },
Stefan Achatz14bf62c2010-03-18 16:19:43 +01001526 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) },
Stefan Achatze68cc6032011-01-06 09:00:34 +01001527 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) },
Stefan Achatzd41c2a72011-11-24 17:46:24 +01001528 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) },
Stefan Achatz47dbdbff2010-11-26 19:57:42 +00001529 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) },
Stefan Achatz0e70f972011-01-30 13:38:24 +01001530 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) },
Stefan Achatzcb7cf3d2010-08-29 12:30:18 +02001531 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
Stefan Achatz3fce2242011-03-23 18:11:36 +01001532 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) },
Andreas Hübner1e936742012-02-22 02:10:06 +01001533 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000) },
Jiri Slaby980a3da2008-06-25 22:31:48 +02001534 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
Don Princeb3558502010-05-17 11:42:39 +01001535 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
Jiri Kosinad586dca2011-03-21 13:54:22 +01001536 { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
Jiri Slabybd28ce02008-06-25 23:47:04 +02001537 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
Jiri Kosina35dca5b2011-04-28 15:43:13 +02001538 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
Bastien Noceraf9ce7c22010-01-20 12:01:53 +00001539 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
Jiri Kosinacc6e0bb2008-10-23 12:58:38 +02001540 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
Stephane Chattyd3fb5452010-01-04 12:04:08 +01001541 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) },
Pascal Auriel - Stantumb6dc7992010-10-01 16:01:28 +02001542 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) },
1543 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) },
Jiri Slaby90231e72008-06-23 21:56:07 +02001544 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
Anssi Hannuladaedb3d2009-02-14 11:45:05 +02001545 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
1546 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) },
Ruben Aos Garralda7a84b132009-06-29 09:41:29 +02001547 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) },
1548 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) },
Anssi Hannuladaedb3d2009-02-14 11:45:05 +02001549 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
Markus Rathgeb3ee8f0a2010-03-13 17:29:43 +01001550 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) },
Anssi Hannuladaedb3d2009-02-14 11:45:05 +02001551 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
Simon Woodd65c3762010-11-29 17:41:23 +01001552 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) },
Jiri Kosina740363f2012-03-13 09:36:05 +01001553 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_BT) },
Jarod Wilson44ea35c2011-10-14 16:57:42 -04001554 { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE) },
Lev Babievf14f5262009-01-04 00:36:56 +01001555 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
Kees Bakker54001082010-07-13 22:50:51 +02001556 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) },
Benjamin Tissoires5e74e562011-05-19 14:18:16 +02001557 { HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) },
Bruno Premont711a6802009-07-13 14:19:58 +02001558 { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) },
Benjamin Tissoiresc64f6f92011-01-08 12:15:42 +01001559 { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) },
Nikolai Kondrashov41fa9232010-08-23 15:09:01 +04001560 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) },
Nikolai Kondrashovf8a489c2010-08-09 20:44:17 +04001561 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) },
1562 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) },
1563 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) },
Nikolai Kondrashov6be914f2011-07-06 09:23:41 +03001564 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) },
Benjamin Tissoires617b64f2011-05-19 14:18:17 +02001565 { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) },
1566 { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) },
Jussi Kivilinnafac733f2009-05-13 11:54:38 +03001567 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) },
Sean Young42fc04e2012-02-18 12:53:44 +00001568 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SUPER_JOY_BOX_3) },
Sean Youngad395cc2011-08-14 20:42:05 +01001569 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) },
Sean Young1bcc2062011-10-20 21:26:21 +01001570 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) },
1571 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) },
1572 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
Bastien Noceraca2dcd42009-05-11 17:18:12 +02001573 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
Przemo Firszt78761ff2011-11-05 11:28:22 +00001574 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) },
Nikolai Kondrashov72a46342010-08-20 19:21:11 +04001575 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
Nikolai Kondrashov00e7f962010-09-25 23:16:58 +04001576 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
Nikolai Kondrashov4fdc18d2012-02-06 22:54:20 +02001577 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_Q_PAD) },
Nikolai Kondrashova786e832012-03-06 09:54:24 +02001578 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_PID_0038) },
Nikolai Kondrashov72a46342010-08-20 19:21:11 +04001579 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
Nikolai Kondrashov8f1acc32010-08-30 14:06:36 +04001580 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
ice chienbc8a2a92011-07-15 16:58:06 +08001581 { HID_USB_DEVICE(USB_VENDOR_ID_XAT, USB_DEVICE_ID_XAT_CSR) },
Masatoshi Hoshikawa11576c62012-01-05 11:53:46 +09001582 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX) },
1583 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX) },
1584 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR) },
1585 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX1) },
1586 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX1) },
1587 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR1) },
1588 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX2) },
1589 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX2) },
1590 { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR2) },
Stefan Kriwanek74bc6952011-05-27 18:40:29 +02001591 { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) },
Anssi Hannuladaedb3d2009-02-14 11:45:05 +02001592 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
1593 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
Don Princea9885c82010-05-14 17:30:59 +01001594 { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
Jiri Slaby8c19a512008-06-18 23:36:49 +02001595
Jiri Slaby78a849a682008-06-20 21:26:11 +02001596 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) },
David Herrmann02fb72a2011-07-05 13:45:09 +02001597 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) },
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001598 { }
1599};
1600
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01001601struct hid_dynid {
1602 struct list_head list;
1603 struct hid_device_id id;
1604};
1605
1606/**
1607 * store_new_id - add a new HID device ID to this driver and re-probe devices
1608 * @driver: target device driver
1609 * @buf: buffer for scanning device ID data
1610 * @count: input size
1611 *
1612 * Adds a new dynamic hid device ID to this driver,
1613 * and causes the driver to probe for all devices again.
1614 */
1615static ssize_t store_new_id(struct device_driver *drv, const char *buf,
1616 size_t count)
1617{
1618 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
1619 struct hid_dynid *dynid;
1620 __u32 bus, vendor, product;
1621 unsigned long driver_data = 0;
1622 int ret;
1623
1624 ret = sscanf(buf, "%x %x %x %lx",
1625 &bus, &vendor, &product, &driver_data);
1626 if (ret < 3)
1627 return -EINVAL;
1628
1629 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
1630 if (!dynid)
1631 return -ENOMEM;
1632
1633 dynid->id.bus = bus;
1634 dynid->id.vendor = vendor;
1635 dynid->id.product = product;
1636 dynid->id.driver_data = driver_data;
1637
1638 spin_lock(&hdrv->dyn_lock);
1639 list_add_tail(&dynid->list, &hdrv->dyn_list);
1640 spin_unlock(&hdrv->dyn_lock);
1641
Alan Sterncef9bc52012-01-24 13:34:41 -05001642 ret = driver_attach(&hdrv->driver);
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01001643
1644 return ret ? : count;
1645}
1646static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
1647
1648static void hid_free_dynids(struct hid_driver *hdrv)
1649{
1650 struct hid_dynid *dynid, *n;
1651
1652 spin_lock(&hdrv->dyn_lock);
1653 list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) {
1654 list_del(&dynid->list);
1655 kfree(dynid);
1656 }
1657 spin_unlock(&hdrv->dyn_lock);
1658}
1659
1660static const struct hid_device_id *hid_match_device(struct hid_device *hdev,
1661 struct hid_driver *hdrv)
1662{
1663 struct hid_dynid *dynid;
1664
1665 spin_lock(&hdrv->dyn_lock);
1666 list_for_each_entry(dynid, &hdrv->dyn_list, list) {
1667 if (hid_match_one_id(hdev, &dynid->id)) {
1668 spin_unlock(&hdrv->dyn_lock);
1669 return &dynid->id;
1670 }
1671 }
1672 spin_unlock(&hdrv->dyn_lock);
1673
1674 return hid_match_id(hdev, hdrv->id_table);
1675}
1676
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001677static int hid_bus_match(struct device *dev, struct device_driver *drv)
1678{
1679 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
1680 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1681
Benjamin Tissoires8d179a92012-03-06 17:57:04 +01001682 if ((hdev->quirks & HID_QUIRK_MULTITOUCH) &&
1683 !strncmp(hdrv->name, "hid-multitouch", 14))
1684 return 1;
1685
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01001686 if (!hid_match_device(hdev, hdrv))
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001687 return 0;
1688
Dmitry Torokhovce06b9d2010-11-28 16:37:14 +01001689 /* generic wants all that don't have specialized driver */
Jiri Kosina6b1968d2012-03-09 13:55:43 +01001690 if (!strncmp(hdrv->name, "generic-", 8) && !hid_ignore_special_drivers)
Dmitry Torokhovce06b9d2010-11-28 16:37:14 +01001691 return !hid_match_id(hdev, hid_have_special_driver);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001692
1693 return 1;
1694}
1695
1696static int hid_device_probe(struct device *dev)
1697{
1698 struct hid_driver *hdrv = container_of(dev->driver,
1699 struct hid_driver, driver);
1700 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1701 const struct hid_device_id *id;
1702 int ret = 0;
1703
David Herrmann4ea54542011-08-10 14:02:07 +02001704 if (down_interruptible(&hdev->driver_lock))
1705 return -EINTR;
1706
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001707 if (!hdev->driver) {
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01001708 id = hid_match_device(hdev, hdrv);
Dan Carpenterba623a72011-08-24 14:27:46 +03001709 if (id == NULL) {
Benjamin Tissoires8d179a92012-03-06 17:57:04 +01001710 if (!((hdev->quirks & HID_QUIRK_MULTITOUCH) &&
1711 !strncmp(hdrv->name, "hid-multitouch", 14))) {
1712 ret = -ENODEV;
1713 goto unlock;
1714 }
Dan Carpenterba623a72011-08-24 14:27:46 +03001715 }
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001716
Jiri Slabyc500c972008-05-16 11:49:16 +02001717 hdev->driver = hdrv;
1718 if (hdrv->probe) {
1719 ret = hdrv->probe(hdev, id);
1720 } else { /* default probe */
1721 ret = hid_parse(hdev);
1722 if (!ret)
Jiri Slaby93c10132008-06-27 00:04:24 +02001723 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001724 }
Jiri Slabyc500c972008-05-16 11:49:16 +02001725 if (ret)
1726 hdev->driver = NULL;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001727 }
Dan Carpenterba623a72011-08-24 14:27:46 +03001728unlock:
David Herrmann4ea54542011-08-10 14:02:07 +02001729 up(&hdev->driver_lock);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001730 return ret;
1731}
1732
1733static int hid_device_remove(struct device *dev)
1734{
1735 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
David Herrmann4ea54542011-08-10 14:02:07 +02001736 struct hid_driver *hdrv;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001737
David Herrmann4ea54542011-08-10 14:02:07 +02001738 if (down_interruptible(&hdev->driver_lock))
1739 return -EINTR;
1740
1741 hdrv = hdev->driver;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001742 if (hdrv) {
1743 if (hdrv->remove)
1744 hdrv->remove(hdev);
Jiri Slabyc500c972008-05-16 11:49:16 +02001745 else /* default remove */
1746 hid_hw_stop(hdev);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001747 hdev->driver = NULL;
1748 }
1749
David Herrmann4ea54542011-08-10 14:02:07 +02001750 up(&hdev->driver_lock);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02001751 return 0;
1752}
1753
1754static int hid_uevent(struct device *dev, struct kobj_uevent_env *env)
1755{
1756 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1757
1758 if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X",
1759 hdev->bus, hdev->vendor, hdev->product))
1760 return -ENOMEM;
1761
1762 if (add_uevent_var(env, "HID_NAME=%s", hdev->name))
1763 return -ENOMEM;
1764
1765 if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys))
1766 return -ENOMEM;
1767
1768 if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq))
1769 return -ENOMEM;
1770
1771 if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X",
1772 hdev->bus, hdev->vendor, hdev->product))
1773 return -ENOMEM;
1774
1775 return 0;
1776}
1777
1778static struct bus_type hid_bus_type = {
1779 .name = "hid",
1780 .match = hid_bus_match,
1781 .probe = hid_device_probe,
1782 .remove = hid_device_remove,
1783 .uevent = hid_uevent,
1784};
1785
Jiri Kosinabae7eb32009-01-28 23:06:37 +01001786/* a list of devices that shouldn't be handled by HID core at all */
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001787static const struct hid_device_id hid_ignore_list[] = {
1788 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) },
1789 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) },
1790 { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) },
1791 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) },
1792 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) },
1793 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) },
1794 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) },
1795 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) },
1796 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) },
1797 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
1798 { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
1799 { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
Stephane Chatty77f720b2010-02-06 15:17:13 +01001800 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)},
1801 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)},
Alexey Klimov62a56582008-11-13 05:44:50 +03001802 { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001803 { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) },
1804 { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) },
1805 { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) },
1806 { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) },
1807 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) },
1808 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) },
Alexey Klimov5f6108c2008-12-08 12:40:14 +01001809 { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001810 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
1811 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
Melchior FRANZ73bc7d32010-12-22 02:04:33 +01001812 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) },
Dan Delaney789aaa22011-11-20 10:21:30 +01001813 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x000a) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001814 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
Petr Å tetiar70c66562009-12-09 22:09:53 +01001815 { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) },
Petr Å tetiardf506f22010-06-28 09:38:54 -07001816 { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) },
Benjamin Tissoiresb1807712011-11-16 11:39:52 +01001817 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001818 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001819 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) },
1820 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) },
1821 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) },
1822 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) },
1823 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) },
1824 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) },
1825 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) },
1826 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) },
1827 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) },
1828 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) },
1829 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) },
1830 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) },
1831 { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) },
1832 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) },
1833 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) },
1834 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) },
1835 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) },
1836 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) },
1837 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) },
1838 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) },
1839 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) },
1840 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) },
1841 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) },
1842 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) },
1843 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) },
1844 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) },
1845 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) },
1846 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) },
1847 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) },
1848 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) },
1849 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) },
1850 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) },
1851 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) },
1852 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) },
1853 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) },
1854 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) },
1855 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) },
1856 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) },
1857 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) },
1858 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) },
1859 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) },
1860 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) },
1861 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) },
1862 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) },
1863 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) },
1864 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) },
1865 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) },
1866 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) },
1867 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) },
1868 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) },
1869 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) },
1870 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) },
1871 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) },
1872 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) },
1873 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) },
1874 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) },
1875 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) },
1876 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) },
1877 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) },
1878 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) },
1879 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
1880 { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
1881 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
Alexey Klimovc91c21c2008-11-13 10:36:11 +01001882 { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001883 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
Lamarque Vieira Souzaeb8141c2009-10-02 15:04:44 +02001884 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001885 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) },
Michael Hundce97cac2011-05-03 10:12:00 -07001886 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001887 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) },
Michael Hundce97cac2011-05-03 10:12:00 -07001888 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001889 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) },
Michael Hundce97cac2011-05-03 10:12:00 -07001890 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) },
1891 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) },
1892 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) },
1893 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) },
1894 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) },
1895 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001896 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) },
1897 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) },
1898 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
Michael Hundce97cac2011-05-03 10:12:00 -07001899 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) },
1900 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) },
1901 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001902 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) },
1903 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) },
Michael Hundce97cac2011-05-03 10:12:00 -07001904 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001905 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) },
1906 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) },
1907 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) },
1908 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) },
1909 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) },
Michael Hundce97cac2011-05-03 10:12:00 -07001910 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) },
1911 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) },
1912 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) },
1913 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) },
1914 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) },
1915 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) },
1916 { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001917 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) },
1918 { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) },
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001919 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) },
1920 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) },
1921 { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) },
1922 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) },
1923 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) },
1924 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) },
1925 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) },
1926 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) },
1927 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) },
1928 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) },
1929 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) },
1930 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) },
1931 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) },
1932 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) },
1933 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) },
1934 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
1935 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
Henning Glawe4cfae3e2009-08-02 22:18:12 +02001936 { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) },
Michael Tokarev35cfd1d2009-02-01 16:11:04 +01001937 { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
Jan Steinhoff8491ee12012-02-03 00:21:31 -08001938#if defined(CONFIG_MOUSE_SYNAPTICS_USB) || defined(CONFIG_MOUSE_SYNAPTICS_USB_MODULE)
1939 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP) },
1940 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_INT_TP) },
1941 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_CPAD) },
1942 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_STICK) },
1943 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WP) },
1944 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_COMP_TP) },
1945 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WTP) },
1946 { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DPAD) },
1947#endif
Jiri Slabyd458a9d2008-05-16 11:49:20 +02001948 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
1949 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
1950 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
1951 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
1952 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
1953 { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) },
1954 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) },
1955 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) },
1956 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) },
1957 { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
1958 { }
1959};
1960
Jiri Slabyb4d8e472008-10-22 14:47:18 +02001961/**
1962 * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer
1963 *
1964 * There are composite devices for which we want to ignore only a certain
1965 * interface. This is a list of devices for which only the mouse interface will
1966 * be ignored. This allows a dedicated driver to take care of the interface.
1967 */
1968static const struct hid_device_id hid_mouse_ignore_list[] = {
1969 /* appletouch driver */
1970 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
1971 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
1972 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
1973 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) },
1974 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) },
1975 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) },
1976 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) },
1977 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) },
1978 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) },
1979 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) },
1980 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) },
1981 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) },
1982 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) },
1983 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) },
1984 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) },
1985 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) },
1986 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) },
1987 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
1988 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
1989 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
Jiri Kosinaac26fca2008-11-20 11:27:02 +01001990 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
1991 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
1992 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
Edgar (gimli) Hucek99b9f752010-11-03 10:36:18 -04001993 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) },
1994 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) },
1995 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) },
1996 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) },
1997 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) },
1998 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) },
Andy Botting47340bd2011-03-12 20:27:22 -08001999 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
2000 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
2001 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
Gökçen Eraslan213f9da2011-10-22 22:39:06 +03002002 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
2003 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
2004 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
Jiri Kosina4b086912011-10-04 14:01:12 +02002005 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) },
2006 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) },
2007 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) },
2008 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
2009 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
2010 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
Jiri Slabyb4d8e472008-10-22 14:47:18 +02002011 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
2012 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
2013 { }
2014};
2015
Jiri Slabyd458a9d2008-05-16 11:49:20 +02002016static bool hid_ignore(struct hid_device *hdev)
2017{
2018 switch (hdev->vendor) {
2019 case USB_VENDOR_ID_CODEMERCS:
2020 /* ignore all Code Mercenaries IOWarrior devices */
2021 if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST &&
2022 hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST)
2023 return true;
2024 break;
2025 case USB_VENDOR_ID_LOGITECH:
2026 if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST &&
2027 hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST)
2028 return true;
Hans Verkuil65dd3b62012-01-13 11:15:22 -03002029 /*
2030 * The Keene FM transmitter USB device has the same USB ID as
2031 * the Logitech AudioHub Speaker, but it should ignore the hid.
2032 * Check if the name is that of the Keene device.
2033 * For reference: the name of the AudioHub is
2034 * "HOLTEK AudioHub Speaker".
2035 */
2036 if (hdev->product == USB_DEVICE_ID_LOGITECH_AUDIOHUB &&
2037 !strcmp(hdev->name, "HOLTEK B-LINK USB Audio "))
2038 return true;
Jiri Slabyd458a9d2008-05-16 11:49:20 +02002039 break;
Jarod Wilson31f7fd72009-07-31 10:56:36 -04002040 case USB_VENDOR_ID_SOUNDGRAPH:
2041 if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST &&
2042 hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST)
2043 return true;
2044 break;
Xing Weibba53942010-09-01 23:25:35 -07002045 case USB_VENDOR_ID_HANWANG:
2046 if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST &&
2047 hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST)
2048 return true;
2049 break;
Tomoki Sekiyama6dc14182011-05-23 15:45:44 -07002050 case USB_VENDOR_ID_JESS:
2051 if (hdev->product == USB_DEVICE_ID_JESS_YUREX &&
2052 hdev->type == HID_TYPE_USBNONE)
2053 return true;
2054 break;
Jiri Slabyd458a9d2008-05-16 11:49:20 +02002055 }
2056
Jiri Slabyb4d8e472008-10-22 14:47:18 +02002057 if (hdev->type == HID_TYPE_USBMOUSE &&
2058 hid_match_id(hdev, hid_mouse_ignore_list))
2059 return true;
2060
Jiri Slabyd458a9d2008-05-16 11:49:20 +02002061 return !!hid_match_id(hdev, hid_ignore_list);
2062}
2063
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002064int hid_add_device(struct hid_device *hdev)
2065{
2066 static atomic_t id = ATOMIC_INIT(0);
2067 int ret;
2068
2069 if (WARN_ON(hdev->status & HID_STAT_ADDED))
2070 return -EBUSY;
2071
Jiri Slabyd458a9d2008-05-16 11:49:20 +02002072 /* we need to kill them here, otherwise they will stay allocated to
2073 * wait for coming driver */
Jindrich Makovickae5a2a042010-06-03 12:50:42 +02002074 if (!(hdev->quirks & HID_QUIRK_NO_IGNORE)
2075 && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE)))
Jiri Slabyd458a9d2008-05-16 11:49:20 +02002076 return -ENODEV;
2077
Kay Sievers6bbe5862008-10-31 00:12:32 +01002078 /* XXX hack, any other cleaner solution after the driver core
2079 * is converted to allow more than 20 bytes as the device name? */
2080 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
2081 hdev->vendor, hdev->product, atomic_inc_return(&id));
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002082
Bruno Prémont4da361b2010-03-15 14:55:40 +01002083 hid_debug_register(hdev, dev_name(&hdev->dev));
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002084 ret = device_add(&hdev->dev);
2085 if (!ret)
2086 hdev->status |= HID_STAT_ADDED;
Bruno Prémont4da361b2010-03-15 14:55:40 +01002087 else
2088 hid_debug_unregister(hdev);
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002089
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002090 return ret;
2091}
2092EXPORT_SYMBOL_GPL(hid_add_device);
2093
2094/**
2095 * hid_allocate_device - allocate new hid device descriptor
2096 *
2097 * Allocate and initialize hid device, so that hid_destroy_device might be
2098 * used to free it.
2099 *
2100 * New hid_device pointer is returned on success, otherwise ERR_PTR encoded
2101 * error value.
2102 */
2103struct hid_device *hid_allocate_device(void)
2104{
2105 struct hid_device *hdev;
2106 unsigned int i;
2107 int ret = -ENOMEM;
2108
2109 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
2110 if (hdev == NULL)
2111 return ERR_PTR(ret);
2112
2113 device_initialize(&hdev->dev);
2114 hdev->dev.release = hid_device_release;
2115 hdev->dev.bus = &hid_bus_type;
2116
2117 hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS,
2118 sizeof(struct hid_collection), GFP_KERNEL);
2119 if (hdev->collection == NULL)
2120 goto err;
2121 hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
2122
2123 for (i = 0; i < HID_REPORT_TYPES; i++)
2124 INIT_LIST_HEAD(&hdev->report_enum[i].report_list);
2125
Jiri Kosinacd667ce2009-06-12 15:20:57 +02002126 init_waitqueue_head(&hdev->debug_wait);
2127 INIT_LIST_HEAD(&hdev->debug_list);
David Herrmann4ea54542011-08-10 14:02:07 +02002128 sema_init(&hdev->driver_lock, 1);
Jiri Kosinacd667ce2009-06-12 15:20:57 +02002129
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002130 return hdev;
2131err:
2132 put_device(&hdev->dev);
2133 return ERR_PTR(ret);
2134}
2135EXPORT_SYMBOL_GPL(hid_allocate_device);
2136
2137static void hid_remove_device(struct hid_device *hdev)
2138{
2139 if (hdev->status & HID_STAT_ADDED) {
2140 device_del(&hdev->dev);
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002141 hid_debug_unregister(hdev);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002142 hdev->status &= ~HID_STAT_ADDED;
2143 }
2144}
2145
2146/**
2147 * hid_destroy_device - free previously allocated device
2148 *
2149 * @hdev: hid device
2150 *
2151 * If you allocate hid_device through hid_allocate_device, you should ever
2152 * free by this function.
2153 */
2154void hid_destroy_device(struct hid_device *hdev)
2155{
2156 hid_remove_device(hdev);
2157 put_device(&hdev->dev);
2158}
2159EXPORT_SYMBOL_GPL(hid_destroy_device);
2160
2161int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
2162 const char *mod_name)
2163{
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01002164 int ret;
2165
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002166 hdrv->driver.name = hdrv->name;
2167 hdrv->driver.bus = &hid_bus_type;
2168 hdrv->driver.owner = owner;
2169 hdrv->driver.mod_name = mod_name;
2170
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01002171 INIT_LIST_HEAD(&hdrv->dyn_list);
2172 spin_lock_init(&hdrv->dyn_lock);
2173
2174 ret = driver_register(&hdrv->driver);
2175 if (ret)
2176 return ret;
2177
2178 ret = driver_create_file(&hdrv->driver, &driver_attr_new_id);
2179 if (ret)
2180 driver_unregister(&hdrv->driver);
2181
2182 return ret;
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002183}
2184EXPORT_SYMBOL_GPL(__hid_register_driver);
2185
2186void hid_unregister_driver(struct hid_driver *hdrv)
2187{
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01002188 driver_remove_file(&hdrv->driver, &driver_attr_new_id);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002189 driver_unregister(&hdrv->driver);
Jiri Slaby3a6f82f2008-11-24 16:20:09 +01002190 hid_free_dynids(hdrv);
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002191}
2192EXPORT_SYMBOL_GPL(hid_unregister_driver);
2193
Oliver Neukum0361a282008-12-17 15:38:03 +01002194int hid_check_keys_pressed(struct hid_device *hid)
2195{
2196 struct hid_input *hidinput;
2197 int i;
2198
Jiri Kosinae5288eb2009-05-02 00:02:57 +02002199 if (!(hid->claimed & HID_CLAIMED_INPUT))
2200 return 0;
2201
Oliver Neukum0361a282008-12-17 15:38:03 +01002202 list_for_each_entry(hidinput, &hid->inputs, list) {
2203 for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++)
2204 if (hidinput->input->key[i])
2205 return 1;
2206 }
2207
2208 return 0;
2209}
2210
2211EXPORT_SYMBOL_GPL(hid_check_keys_pressed);
2212
Jiri Kosina86166b72007-05-14 09:57:40 +02002213static int __init hid_init(void)
2214{
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002215 int ret;
2216
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002217 if (hid_debug)
Joe Perches4291ee32010-12-09 19:29:03 -08002218 pr_warn("hid_debug is now used solely for parser and driver debugging.\n"
2219 "debugfs is now used for inspecting the device (report descriptor, reports)\n");
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002220
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002221 ret = bus_register(&hid_bus_type);
2222 if (ret) {
Joe Perches4291ee32010-12-09 19:29:03 -08002223 pr_err("can't register hid bus\n");
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002224 goto err;
2225 }
2226
2227 ret = hidraw_init();
2228 if (ret)
2229 goto err_bus;
2230
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002231 hid_debug_init();
2232
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002233 return 0;
2234err_bus:
2235 bus_unregister(&hid_bus_type);
2236err:
2237 return ret;
Jiri Kosina86166b72007-05-14 09:57:40 +02002238}
2239
2240static void __exit hid_exit(void)
2241{
Jiri Kosinaa635f9d2009-06-12 15:20:55 +02002242 hid_debug_exit();
Jiri Kosina86166b72007-05-14 09:57:40 +02002243 hidraw_exit();
Jiri Slaby85cdaf52008-05-16 11:49:15 +02002244 bus_unregister(&hid_bus_type);
Jiri Kosina86166b72007-05-14 09:57:40 +02002245}
2246
2247module_init(hid_init);
2248module_exit(hid_exit);
2249
Jiri Kosina88adb722009-10-02 18:29:34 +02002250MODULE_AUTHOR("Andreas Gal");
2251MODULE_AUTHOR("Vojtech Pavlik");
2252MODULE_AUTHOR("Jiri Kosina");
Jiri Kosinaaa938f72006-12-08 18:41:10 +01002253MODULE_LICENSE(DRIVER_LICENSE);
2254