2 * HID support for Linux
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2010 Jiri Kosina
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)
17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19 #include <linux/module.h>
20 #include <linux/slab.h>
21 #include <linux/init.h>
22 #include <linux/kernel.h>
23 #include <linux/list.h>
25 #include <linux/spinlock.h>
26 #include <asm/unaligned.h>
27 #include <asm/byteorder.h>
28 #include <linux/input.h>
29 #include <linux/wait.h>
30 #include <linux/vmalloc.h>
31 #include <linux/sched.h>
33 #include <linux/hid.h>
34 #include <linux/hiddev.h>
35 #include <linux/hid-debug.h>
36 #include <linux/hidraw.h>
44 #define DRIVER_DESC "HID core driver"
45 #define DRIVER_LICENSE "GPL"
48 module_param_named(debug
, hid_debug
, int, 0600);
49 MODULE_PARM_DESC(debug
, "toggle HID debugging messages");
50 EXPORT_SYMBOL_GPL(hid_debug
);
53 * Register a new report for a device.
56 struct hid_report
*hid_register_report(struct hid_device
*device
, unsigned type
, unsigned id
)
58 struct hid_report_enum
*report_enum
= device
->report_enum
+ type
;
59 struct hid_report
*report
;
61 if (report_enum
->report_id_hash
[id
])
62 return report_enum
->report_id_hash
[id
];
64 report
= kzalloc(sizeof(struct hid_report
), GFP_KERNEL
);
69 report_enum
->numbered
= 1;
74 report
->device
= device
;
75 report_enum
->report_id_hash
[id
] = report
;
77 list_add_tail(&report
->list
, &report_enum
->report_list
);
81 EXPORT_SYMBOL_GPL(hid_register_report
);
84 * Register a new field for this report.
87 static struct hid_field
*hid_register_field(struct hid_report
*report
, unsigned usages
, unsigned values
)
89 struct hid_field
*field
;
91 if (report
->maxfield
== HID_MAX_FIELDS
) {
92 dbg_hid("too many fields in report\n");
96 field
= kzalloc((sizeof(struct hid_field
) +
97 usages
* sizeof(struct hid_usage
) +
98 values
* sizeof(unsigned)), GFP_KERNEL
);
102 field
->index
= report
->maxfield
++;
103 report
->field
[field
->index
] = field
;
104 field
->usage
= (struct hid_usage
*)(field
+ 1);
105 field
->value
= (s32
*)(field
->usage
+ usages
);
106 field
->report
= report
;
112 * Open a collection. The type/usage is pushed on the stack.
115 static int open_collection(struct hid_parser
*parser
, unsigned type
)
117 struct hid_collection
*collection
;
120 usage
= parser
->local
.usage
[0];
122 if (parser
->collection_stack_ptr
== HID_COLLECTION_STACK_SIZE
) {
123 dbg_hid("collection stack overflow\n");
127 if (parser
->device
->maxcollection
== parser
->device
->collection_size
) {
128 collection
= kmalloc(sizeof(struct hid_collection
) *
129 parser
->device
->collection_size
* 2, GFP_KERNEL
);
130 if (collection
== NULL
) {
131 dbg_hid("failed to reallocate collection array\n");
134 memcpy(collection
, parser
->device
->collection
,
135 sizeof(struct hid_collection
) *
136 parser
->device
->collection_size
);
137 memset(collection
+ parser
->device
->collection_size
, 0,
138 sizeof(struct hid_collection
) *
139 parser
->device
->collection_size
);
140 kfree(parser
->device
->collection
);
141 parser
->device
->collection
= collection
;
142 parser
->device
->collection_size
*= 2;
145 parser
->collection_stack
[parser
->collection_stack_ptr
++] =
146 parser
->device
->maxcollection
;
148 collection
= parser
->device
->collection
+
149 parser
->device
->maxcollection
++;
150 collection
->type
= type
;
151 collection
->usage
= usage
;
152 collection
->level
= parser
->collection_stack_ptr
- 1;
154 if (type
== HID_COLLECTION_APPLICATION
)
155 parser
->device
->maxapplication
++;
161 * Close a collection.
164 static int close_collection(struct hid_parser
*parser
)
166 if (!parser
->collection_stack_ptr
) {
167 dbg_hid("collection stack underflow\n");
170 parser
->collection_stack_ptr
--;
175 * Climb up the stack, search for the specified collection type
176 * and return the usage.
179 static unsigned hid_lookup_collection(struct hid_parser
*parser
, unsigned type
)
181 struct hid_collection
*collection
= parser
->device
->collection
;
184 for (n
= parser
->collection_stack_ptr
- 1; n
>= 0; n
--) {
185 unsigned index
= parser
->collection_stack
[n
];
186 if (collection
[index
].type
== type
)
187 return collection
[index
].usage
;
189 return 0; /* we know nothing about this usage type */
193 * Add a usage to the temporary parser table.
196 static int hid_add_usage(struct hid_parser
*parser
, unsigned usage
)
198 if (parser
->local
.usage_index
>= HID_MAX_USAGES
) {
199 dbg_hid("usage index exceeded\n");
202 parser
->local
.usage
[parser
->local
.usage_index
] = usage
;
203 parser
->local
.collection_index
[parser
->local
.usage_index
] =
204 parser
->collection_stack_ptr
?
205 parser
->collection_stack
[parser
->collection_stack_ptr
- 1] : 0;
206 parser
->local
.usage_index
++;
211 * Register a new field for this report.
214 static int hid_add_field(struct hid_parser
*parser
, unsigned report_type
, unsigned flags
)
216 struct hid_report
*report
;
217 struct hid_field
*field
;
222 report
= hid_register_report(parser
->device
, report_type
, parser
->global
.report_id
);
224 dbg_hid("hid_register_report failed\n");
228 if (parser
->global
.logical_maximum
< parser
->global
.logical_minimum
) {
229 dbg_hid("logical range invalid %d %d\n", parser
->global
.logical_minimum
, parser
->global
.logical_maximum
);
233 offset
= report
->size
;
234 report
->size
+= parser
->global
.report_size
* parser
->global
.report_count
;
236 if (!parser
->local
.usage_index
) /* Ignore padding fields */
239 usages
= max_t(int, parser
->local
.usage_index
, parser
->global
.report_count
);
241 field
= hid_register_field(report
, usages
, parser
->global
.report_count
);
245 field
->physical
= hid_lookup_collection(parser
, HID_COLLECTION_PHYSICAL
);
246 field
->logical
= hid_lookup_collection(parser
, HID_COLLECTION_LOGICAL
);
247 field
->application
= hid_lookup_collection(parser
, HID_COLLECTION_APPLICATION
);
249 for (i
= 0; i
< usages
; i
++) {
251 /* Duplicate the last usage we parsed if we have excess values */
252 if (i
>= parser
->local
.usage_index
)
253 j
= parser
->local
.usage_index
- 1;
254 field
->usage
[i
].hid
= parser
->local
.usage
[j
];
255 field
->usage
[i
].collection_index
=
256 parser
->local
.collection_index
[j
];
259 field
->maxusage
= usages
;
260 field
->flags
= flags
;
261 field
->report_offset
= offset
;
262 field
->report_type
= report_type
;
263 field
->report_size
= parser
->global
.report_size
;
264 field
->report_count
= parser
->global
.report_count
;
265 field
->logical_minimum
= parser
->global
.logical_minimum
;
266 field
->logical_maximum
= parser
->global
.logical_maximum
;
267 field
->physical_minimum
= parser
->global
.physical_minimum
;
268 field
->physical_maximum
= parser
->global
.physical_maximum
;
269 field
->unit_exponent
= parser
->global
.unit_exponent
;
270 field
->unit
= parser
->global
.unit
;
276 * Read data value from item.
279 static u32
item_udata(struct hid_item
*item
)
281 switch (item
->size
) {
282 case 1: return item
->data
.u8
;
283 case 2: return item
->data
.u16
;
284 case 4: return item
->data
.u32
;
289 static s32
item_sdata(struct hid_item
*item
)
291 switch (item
->size
) {
292 case 1: return item
->data
.s8
;
293 case 2: return item
->data
.s16
;
294 case 4: return item
->data
.s32
;
300 * Process a global item.
303 static int hid_parser_global(struct hid_parser
*parser
, struct hid_item
*item
)
306 case HID_GLOBAL_ITEM_TAG_PUSH
:
308 if (parser
->global_stack_ptr
== HID_GLOBAL_STACK_SIZE
) {
309 dbg_hid("global environment stack overflow\n");
313 memcpy(parser
->global_stack
+ parser
->global_stack_ptr
++,
314 &parser
->global
, sizeof(struct hid_global
));
317 case HID_GLOBAL_ITEM_TAG_POP
:
319 if (!parser
->global_stack_ptr
) {
320 dbg_hid("global environment stack underflow\n");
324 memcpy(&parser
->global
, parser
->global_stack
+
325 --parser
->global_stack_ptr
, sizeof(struct hid_global
));
328 case HID_GLOBAL_ITEM_TAG_USAGE_PAGE
:
329 parser
->global
.usage_page
= item_udata(item
);
332 case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM
:
333 parser
->global
.logical_minimum
= item_sdata(item
);
336 case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM
:
337 if (parser
->global
.logical_minimum
< 0)
338 parser
->global
.logical_maximum
= item_sdata(item
);
340 parser
->global
.logical_maximum
= item_udata(item
);
343 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM
:
344 parser
->global
.physical_minimum
= item_sdata(item
);
347 case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM
:
348 if (parser
->global
.physical_minimum
< 0)
349 parser
->global
.physical_maximum
= item_sdata(item
);
351 parser
->global
.physical_maximum
= item_udata(item
);
354 case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT
:
355 parser
->global
.unit_exponent
= item_sdata(item
);
358 case HID_GLOBAL_ITEM_TAG_UNIT
:
359 parser
->global
.unit
= item_udata(item
);
362 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE
:
363 parser
->global
.report_size
= item_udata(item
);
364 if (parser
->global
.report_size
> 32) {
365 dbg_hid("invalid report_size %d\n",
366 parser
->global
.report_size
);
371 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT
:
372 parser
->global
.report_count
= item_udata(item
);
373 if (parser
->global
.report_count
> HID_MAX_USAGES
) {
374 dbg_hid("invalid report_count %d\n",
375 parser
->global
.report_count
);
380 case HID_GLOBAL_ITEM_TAG_REPORT_ID
:
381 parser
->global
.report_id
= item_udata(item
);
382 if (parser
->global
.report_id
== 0) {
383 dbg_hid("report_id 0 is invalid\n");
389 dbg_hid("unknown global tag 0x%x\n", item
->tag
);
395 * Process a local item.
398 static int hid_parser_local(struct hid_parser
*parser
, struct hid_item
*item
)
403 data
= item_udata(item
);
406 case HID_LOCAL_ITEM_TAG_DELIMITER
:
410 * We treat items before the first delimiter
411 * as global to all usage sets (branch 0).
412 * In the moment we process only these global
413 * items and the first delimiter set.
415 if (parser
->local
.delimiter_depth
!= 0) {
416 dbg_hid("nested delimiters\n");
419 parser
->local
.delimiter_depth
++;
420 parser
->local
.delimiter_branch
++;
422 if (parser
->local
.delimiter_depth
< 1) {
423 dbg_hid("bogus close delimiter\n");
426 parser
->local
.delimiter_depth
--;
430 case HID_LOCAL_ITEM_TAG_USAGE
:
432 if (parser
->local
.delimiter_branch
> 1) {
433 dbg_hid("alternative usage ignored\n");
438 data
= (parser
->global
.usage_page
<< 16) + data
;
440 return hid_add_usage(parser
, data
);
442 case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM
:
444 if (parser
->local
.delimiter_branch
> 1) {
445 dbg_hid("alternative usage ignored\n");
450 data
= (parser
->global
.usage_page
<< 16) + data
;
452 parser
->local
.usage_minimum
= data
;
455 case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM
:
457 if (parser
->local
.delimiter_branch
> 1) {
458 dbg_hid("alternative usage ignored\n");
463 data
= (parser
->global
.usage_page
<< 16) + data
;
465 for (n
= parser
->local
.usage_minimum
; n
<= data
; n
++)
466 if (hid_add_usage(parser
, n
)) {
467 dbg_hid("hid_add_usage failed\n");
474 dbg_hid("unknown local item tag 0x%x\n", item
->tag
);
481 * Process a main item.
484 static int hid_parser_main(struct hid_parser
*parser
, struct hid_item
*item
)
489 data
= item_udata(item
);
492 case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION
:
493 ret
= open_collection(parser
, data
& 0xff);
495 case HID_MAIN_ITEM_TAG_END_COLLECTION
:
496 ret
= close_collection(parser
);
498 case HID_MAIN_ITEM_TAG_INPUT
:
499 ret
= hid_add_field(parser
, HID_INPUT_REPORT
, data
);
501 case HID_MAIN_ITEM_TAG_OUTPUT
:
502 ret
= hid_add_field(parser
, HID_OUTPUT_REPORT
, data
);
504 case HID_MAIN_ITEM_TAG_FEATURE
:
505 ret
= hid_add_field(parser
, HID_FEATURE_REPORT
, data
);
508 dbg_hid("unknown main item tag 0x%x\n", item
->tag
);
512 memset(&parser
->local
, 0, sizeof(parser
->local
)); /* Reset the local parser environment */
518 * Process a reserved item.
521 static int hid_parser_reserved(struct hid_parser
*parser
, struct hid_item
*item
)
523 dbg_hid("reserved item type, tag 0x%x\n", item
->tag
);
528 * Free a report and all registered fields. The field->usage and
529 * field->value table's are allocated behind the field, so we need
530 * only to free(field) itself.
533 static void hid_free_report(struct hid_report
*report
)
537 for (n
= 0; n
< report
->maxfield
; n
++)
538 kfree(report
->field
[n
]);
543 * Free a device structure, all reports, and all fields.
546 static void hid_device_release(struct device
*dev
)
548 struct hid_device
*device
= container_of(dev
, struct hid_device
, dev
);
551 for (i
= 0; i
< HID_REPORT_TYPES
; i
++) {
552 struct hid_report_enum
*report_enum
= device
->report_enum
+ i
;
554 for (j
= 0; j
< 256; j
++) {
555 struct hid_report
*report
= report_enum
->report_id_hash
[j
];
557 hid_free_report(report
);
561 kfree(device
->rdesc
);
562 kfree(device
->collection
);
567 * Fetch a report description item from the data stream. We support long
568 * items, though they are not used yet.
571 static u8
*fetch_item(__u8
*start
, __u8
*end
, struct hid_item
*item
)
575 if ((end
- start
) <= 0)
580 item
->type
= (b
>> 2) & 3;
581 item
->tag
= (b
>> 4) & 15;
583 if (item
->tag
== HID_ITEM_TAG_LONG
) {
585 item
->format
= HID_ITEM_FORMAT_LONG
;
587 if ((end
- start
) < 2)
590 item
->size
= *start
++;
591 item
->tag
= *start
++;
593 if ((end
- start
) < item
->size
)
596 item
->data
.longdata
= start
;
601 item
->format
= HID_ITEM_FORMAT_SHORT
;
604 switch (item
->size
) {
609 if ((end
- start
) < 1)
611 item
->data
.u8
= *start
++;
615 if ((end
- start
) < 2)
617 item
->data
.u16
= get_unaligned_le16(start
);
618 start
= (__u8
*)((__le16
*)start
+ 1);
623 if ((end
- start
) < 4)
625 item
->data
.u32
= get_unaligned_le32(start
);
626 start
= (__u8
*)((__le32
*)start
+ 1);
634 * hid_parse_report - parse device report
636 * @device: hid device
637 * @start: report start
640 * Parse a report description into a hid_device structure. Reports are
641 * enumerated, fields are attached to these reports.
642 * 0 returned on success, otherwise nonzero error value.
644 int hid_parse_report(struct hid_device
*device
, __u8
*start
,
647 struct hid_parser
*parser
;
648 struct hid_item item
;
651 static int (*dispatch_type
[])(struct hid_parser
*parser
,
652 struct hid_item
*item
) = {
659 if (device
->driver
->report_fixup
)
660 start
= device
->driver
->report_fixup(device
, start
, &size
);
662 device
->rdesc
= kmemdup(start
, size
, GFP_KERNEL
);
663 if (device
->rdesc
== NULL
)
665 device
->rsize
= size
;
667 parser
= vzalloc(sizeof(struct hid_parser
));
673 parser
->device
= device
;
677 while ((start
= fetch_item(start
, end
, &item
)) != NULL
) {
679 if (item
.format
!= HID_ITEM_FORMAT_SHORT
) {
680 dbg_hid("unexpected long global item\n");
684 if (dispatch_type
[item
.type
](parser
, &item
)) {
685 dbg_hid("item %u %u %u %u parsing failed\n",
686 item
.format
, (unsigned)item
.size
,
687 (unsigned)item
.type
, (unsigned)item
.tag
);
692 if (parser
->collection_stack_ptr
) {
693 dbg_hid("unbalanced collection at end of report description\n");
696 if (parser
->local
.delimiter_depth
) {
697 dbg_hid("unbalanced delimiter at end of report description\n");
705 dbg_hid("item fetching failed at offset %d\n", (int)(end
- start
));
710 EXPORT_SYMBOL_GPL(hid_parse_report
);
713 * Convert a signed n-bit integer to signed 32-bit integer. Common
714 * cases are done through the compiler, the screwed things has to be
718 static s32
snto32(__u32 value
, unsigned n
)
721 case 8: return ((__s8
)value
);
722 case 16: return ((__s16
)value
);
723 case 32: return ((__s32
)value
);
725 return value
& (1 << (n
- 1)) ? value
| (-1 << n
) : value
;
729 * Convert a signed 32-bit integer to a signed n-bit integer.
732 static u32
s32ton(__s32 value
, unsigned n
)
734 s32 a
= value
>> (n
- 1);
736 return value
< 0 ? 1 << (n
- 1) : (1 << (n
- 1)) - 1;
737 return value
& ((1 << n
) - 1);
741 * Extract/implement a data field from/to a little endian report (bit array).
743 * Code sort-of follows HID spec:
744 * http://www.usb.org/developers/devclass_docs/HID1_11.pdf
746 * While the USB HID spec allows unlimited length bit fields in "report
747 * descriptors", most devices never use more than 16 bits.
748 * One model of UPS is claimed to report "LINEV" as a 32-bit field.
749 * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
752 static __u32
extract(const struct hid_device
*hid
, __u8
*report
,
753 unsigned offset
, unsigned n
)
758 hid_warn(hid
, "extract() called with n (%d) > 32! (%s)\n",
761 report
+= offset
>> 3; /* adjust byte index */
762 offset
&= 7; /* now only need bit offset into one byte */
763 x
= get_unaligned_le64(report
);
764 x
= (x
>> offset
) & ((1ULL << n
) - 1); /* extract bit field */
769 * "implement" : set bits in a little endian bit stream.
770 * Same concepts as "extract" (see comments above).
771 * The data mangled in the bit stream remains in little endian
772 * order the whole time. It make more sense to talk about
773 * endianness of register values by considering a register
774 * a "cached" copy of the little endiad bit stream.
776 static void implement(const struct hid_device
*hid
, __u8
*report
,
777 unsigned offset
, unsigned n
, __u32 value
)
780 u64 m
= (1ULL << n
) - 1;
783 hid_warn(hid
, "%s() called with n (%d) > 32! (%s)\n",
784 __func__
, n
, current
->comm
);
787 hid_warn(hid
, "%s() called with too large value %d! (%s)\n",
788 __func__
, value
, current
->comm
);
792 report
+= offset
>> 3;
795 x
= get_unaligned_le64(report
);
797 x
|= ((u64
)value
) << offset
;
798 put_unaligned_le64(x
, report
);
802 * Search an array for a value.
805 static int search(__s32
*array
, __s32 value
, unsigned n
)
808 if (*array
++ == value
)
815 * hid_match_report - check if driver's raw_event should be called
818 * @report_type: type to match against
820 * compare hid->driver->report_table->report_type to report->type
822 static int hid_match_report(struct hid_device
*hid
, struct hid_report
*report
)
824 const struct hid_report_id
*id
= hid
->driver
->report_table
;
826 if (!id
) /* NULL means all */
829 for (; id
->report_type
!= HID_TERMINATOR
; id
++)
830 if (id
->report_type
== HID_ANY_ID
||
831 id
->report_type
== report
->type
)
837 * hid_match_usage - check if driver's event should be called
840 * @usage: usage to match against
842 * compare hid->driver->usage_table->usage_{type,code} to
843 * usage->usage_{type,code}
845 static int hid_match_usage(struct hid_device
*hid
, struct hid_usage
*usage
)
847 const struct hid_usage_id
*id
= hid
->driver
->usage_table
;
849 if (!id
) /* NULL means all */
852 for (; id
->usage_type
!= HID_ANY_ID
- 1; id
++)
853 if ((id
->usage_hid
== HID_ANY_ID
||
854 id
->usage_hid
== usage
->hid
) &&
855 (id
->usage_type
== HID_ANY_ID
||
856 id
->usage_type
== usage
->type
) &&
857 (id
->usage_code
== HID_ANY_ID
||
858 id
->usage_code
== usage
->code
))
863 static void hid_process_event(struct hid_device
*hid
, struct hid_field
*field
,
864 struct hid_usage
*usage
, __s32 value
, int interrupt
)
866 struct hid_driver
*hdrv
= hid
->driver
;
869 hid_dump_input(hid
, usage
, value
);
871 if (hdrv
&& hdrv
->event
&& hid_match_usage(hid
, usage
)) {
872 ret
= hdrv
->event(hid
, field
, usage
, value
);
875 dbg_hid("%s's event failed with %d\n",
881 if (hid
->claimed
& HID_CLAIMED_INPUT
)
882 hidinput_hid_event(hid
, field
, usage
, value
);
883 if (hid
->claimed
& HID_CLAIMED_HIDDEV
&& interrupt
&& hid
->hiddev_hid_event
)
884 hid
->hiddev_hid_event(hid
, field
, usage
, value
);
888 * Analyse a received field, and fetch the data from it. The field
889 * content is stored for next report processing (we do differential
890 * reporting to the layer).
893 static void hid_input_field(struct hid_device
*hid
, struct hid_field
*field
,
894 __u8
*data
, int interrupt
)
897 unsigned count
= field
->report_count
;
898 unsigned offset
= field
->report_offset
;
899 unsigned size
= field
->report_size
;
900 __s32 min
= field
->logical_minimum
;
901 __s32 max
= field
->logical_maximum
;
904 value
= kmalloc(sizeof(__s32
) * count
, GFP_ATOMIC
);
908 for (n
= 0; n
< count
; n
++) {
911 snto32(extract(hid
, data
, offset
+ n
* size
, size
),
913 extract(hid
, data
, offset
+ n
* size
, size
);
915 /* Ignore report if ErrorRollOver */
916 if (!(field
->flags
& HID_MAIN_ITEM_VARIABLE
) &&
917 value
[n
] >= min
&& value
[n
] <= max
&&
918 field
->usage
[value
[n
] - min
].hid
== HID_UP_KEYBOARD
+ 1)
922 for (n
= 0; n
< count
; n
++) {
924 if (HID_MAIN_ITEM_VARIABLE
& field
->flags
) {
925 hid_process_event(hid
, field
, &field
->usage
[n
], value
[n
], interrupt
);
929 if (field
->value
[n
] >= min
&& field
->value
[n
] <= max
930 && field
->usage
[field
->value
[n
] - min
].hid
931 && search(value
, field
->value
[n
], count
))
932 hid_process_event(hid
, field
, &field
->usage
[field
->value
[n
] - min
], 0, interrupt
);
934 if (value
[n
] >= min
&& value
[n
] <= max
935 && field
->usage
[value
[n
] - min
].hid
936 && search(field
->value
, value
[n
], count
))
937 hid_process_event(hid
, field
, &field
->usage
[value
[n
] - min
], 1, interrupt
);
940 memcpy(field
->value
, value
, count
* sizeof(__s32
));
946 * Output the field into the report.
949 static void hid_output_field(const struct hid_device
*hid
,
950 struct hid_field
*field
, __u8
*data
)
952 unsigned count
= field
->report_count
;
953 unsigned offset
= field
->report_offset
;
954 unsigned size
= field
->report_size
;
957 for (n
= 0; n
< count
; n
++) {
958 if (field
->logical_minimum
< 0) /* signed values */
959 implement(hid
, data
, offset
+ n
* size
, size
,
960 s32ton(field
->value
[n
], size
));
961 else /* unsigned values */
962 implement(hid
, data
, offset
+ n
* size
, size
,
971 void hid_output_report(struct hid_report
*report
, __u8
*data
)
976 *data
++ = report
->id
;
978 memset(data
, 0, ((report
->size
- 1) >> 3) + 1);
979 for (n
= 0; n
< report
->maxfield
; n
++)
980 hid_output_field(report
->device
, report
->field
[n
], data
);
982 EXPORT_SYMBOL_GPL(hid_output_report
);
985 * Set a field value. The report this field belongs to has to be
986 * created and transferred to the device, to set this value in the
990 int hid_set_field(struct hid_field
*field
, unsigned offset
, __s32 value
)
992 unsigned size
= field
->report_size
;
994 hid_dump_input(field
->report
->device
, field
->usage
+ offset
, value
);
996 if (offset
>= field
->report_count
) {
997 dbg_hid("offset (%d) exceeds report_count (%d)\n", offset
, field
->report_count
);
1000 if (field
->logical_minimum
< 0) {
1001 if (value
!= snto32(s32ton(value
, size
), size
)) {
1002 dbg_hid("value %d is out of range\n", value
);
1006 field
->value
[offset
] = value
;
1009 EXPORT_SYMBOL_GPL(hid_set_field
);
1011 static struct hid_report
*hid_get_report(struct hid_report_enum
*report_enum
,
1014 struct hid_report
*report
;
1015 unsigned int n
= 0; /* Normally report number is 0 */
1017 /* Device uses numbered reports, data[0] is report number */
1018 if (report_enum
->numbered
)
1021 report
= report_enum
->report_id_hash
[n
];
1023 dbg_hid("undefined report_id %u received\n", n
);
1028 void hid_report_raw_event(struct hid_device
*hid
, int type
, u8
*data
, int size
,
1031 struct hid_report_enum
*report_enum
= hid
->report_enum
+ type
;
1032 struct hid_report
*report
;
1034 int rsize
, csize
= size
;
1037 report
= hid_get_report(report_enum
, data
);
1041 if (report_enum
->numbered
) {
1046 rsize
= ((report
->size
- 1) >> 3) + 1;
1048 if (rsize
> HID_MAX_BUFFER_SIZE
)
1049 rsize
= HID_MAX_BUFFER_SIZE
;
1051 if (csize
< rsize
) {
1052 dbg_hid("report %d is too short, (%d < %d)\n", report
->id
,
1054 memset(cdata
+ csize
, 0, rsize
- csize
);
1057 if ((hid
->claimed
& HID_CLAIMED_HIDDEV
) && hid
->hiddev_report_event
)
1058 hid
->hiddev_report_event(hid
, report
);
1059 if (hid
->claimed
& HID_CLAIMED_HIDRAW
)
1060 hidraw_report_event(hid
, data
, size
);
1062 for (a
= 0; a
< report
->maxfield
; a
++)
1063 hid_input_field(hid
, report
->field
[a
], cdata
, interrupt
);
1065 if (hid
->claimed
& HID_CLAIMED_INPUT
)
1066 hidinput_report_event(hid
, report
);
1068 EXPORT_SYMBOL_GPL(hid_report_raw_event
);
1071 * hid_input_report - report data from lower layer (usb, bt...)
1074 * @type: HID report type (HID_*_REPORT)
1075 * @data: report contents
1076 * @size: size of data parameter
1077 * @interrupt: distinguish between interrupt and control transfers
1079 * This is data entry for lower layers.
1081 int hid_input_report(struct hid_device
*hid
, int type
, u8
*data
, int size
, int interrupt
)
1083 struct hid_report_enum
*report_enum
;
1084 struct hid_driver
*hdrv
;
1085 struct hid_report
*report
;
1090 if (!hid
|| !hid
->driver
)
1092 report_enum
= hid
->report_enum
+ type
;
1096 dbg_hid("empty report\n");
1100 buf
= kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE
, GFP_ATOMIC
);
1105 /* dump the report */
1106 snprintf(buf
, HID_DEBUG_BUFSIZE
- 1,
1107 "\nreport (size %u) (%snumbered) = ", size
, report_enum
->numbered
? "" : "un");
1108 hid_debug_event(hid
, buf
);
1110 for (i
= 0; i
< size
; i
++) {
1111 snprintf(buf
, HID_DEBUG_BUFSIZE
- 1,
1113 hid_debug_event(hid
, buf
);
1115 hid_debug_event(hid
, "\n");
1119 report
= hid_get_report(report_enum
, data
);
1124 if (hdrv
&& hdrv
->raw_event
&& hid_match_report(hid
, report
)) {
1125 ret
= hdrv
->raw_event(hid
, report
, data
, size
);
1127 return ret
< 0 ? ret
: 0;
1130 hid_report_raw_event(hid
, type
, data
, size
, interrupt
);
1134 EXPORT_SYMBOL_GPL(hid_input_report
);
1136 static bool hid_match_one_id(struct hid_device
*hdev
,
1137 const struct hid_device_id
*id
)
1139 return id
->bus
== hdev
->bus
&&
1140 (id
->vendor
== HID_ANY_ID
|| id
->vendor
== hdev
->vendor
) &&
1141 (id
->product
== HID_ANY_ID
|| id
->product
== hdev
->product
);
1144 static const struct hid_device_id
*hid_match_id(struct hid_device
*hdev
,
1145 const struct hid_device_id
*id
)
1147 for (; id
->bus
; id
++)
1148 if (hid_match_one_id(hdev
, id
))
1154 static const struct hid_device_id hid_hiddev_list
[] = {
1155 { HID_USB_DEVICE(USB_VENDOR_ID_MGE
, USB_DEVICE_ID_MGE_UPS
) },
1156 { HID_USB_DEVICE(USB_VENDOR_ID_MGE
, USB_DEVICE_ID_MGE_UPS1
) },
1160 static bool hid_hiddev(struct hid_device
*hdev
)
1162 return !!hid_match_id(hdev
, hid_hiddev_list
);
1167 read_report_descriptor(struct file
*filp
, struct kobject
*kobj
,
1168 struct bin_attribute
*attr
,
1169 char *buf
, loff_t off
, size_t count
)
1171 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
1172 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
1174 if (off
>= hdev
->rsize
)
1177 if (off
+ count
> hdev
->rsize
)
1178 count
= hdev
->rsize
- off
;
1180 memcpy(buf
, hdev
->rdesc
+ off
, count
);
1185 static struct bin_attribute dev_bin_attr_report_desc
= {
1186 .attr
= { .name
= "report_descriptor", .mode
= 0444 },
1187 .read
= read_report_descriptor
,
1188 .size
= HID_MAX_DESCRIPTOR_SIZE
,
1191 int hid_connect(struct hid_device
*hdev
, unsigned int connect_mask
)
1193 static const char *types
[] = { "Device", "Pointer", "Mouse", "Device",
1194 "Joystick", "Gamepad", "Keyboard", "Keypad",
1195 "Multi-Axis Controller"
1197 const char *type
, *bus
;
1203 if (hdev
->quirks
& HID_QUIRK_HIDDEV_FORCE
)
1204 connect_mask
|= (HID_CONNECT_HIDDEV_FORCE
| HID_CONNECT_HIDDEV
);
1205 if (hdev
->quirks
& HID_QUIRK_HIDINPUT_FORCE
)
1206 connect_mask
|= HID_CONNECT_HIDINPUT_FORCE
;
1207 if (hdev
->bus
!= BUS_USB
)
1208 connect_mask
&= ~HID_CONNECT_HIDDEV
;
1209 if (hid_hiddev(hdev
))
1210 connect_mask
|= HID_CONNECT_HIDDEV_FORCE
;
1212 if ((connect_mask
& HID_CONNECT_HIDINPUT
) && !hidinput_connect(hdev
,
1213 connect_mask
& HID_CONNECT_HIDINPUT_FORCE
))
1214 hdev
->claimed
|= HID_CLAIMED_INPUT
;
1215 if ((connect_mask
& HID_CONNECT_HIDDEV
) && hdev
->hiddev_connect
&&
1216 !hdev
->hiddev_connect(hdev
,
1217 connect_mask
& HID_CONNECT_HIDDEV_FORCE
))
1218 hdev
->claimed
|= HID_CLAIMED_HIDDEV
;
1219 if ((connect_mask
& HID_CONNECT_HIDRAW
) && !hidraw_connect(hdev
))
1220 hdev
->claimed
|= HID_CLAIMED_HIDRAW
;
1222 if (!hdev
->claimed
) {
1223 hid_err(hdev
, "claimed by neither input, hiddev nor hidraw\n");
1227 if ((hdev
->claimed
& HID_CLAIMED_INPUT
) &&
1228 (connect_mask
& HID_CONNECT_FF
) && hdev
->ff_init
)
1229 hdev
->ff_init(hdev
);
1232 if (hdev
->claimed
& HID_CLAIMED_INPUT
)
1233 len
+= sprintf(buf
+ len
, "input");
1234 if (hdev
->claimed
& HID_CLAIMED_HIDDEV
)
1235 len
+= sprintf(buf
+ len
, "%shiddev%d", len
? "," : "",
1237 if (hdev
->claimed
& HID_CLAIMED_HIDRAW
)
1238 len
+= sprintf(buf
+ len
, "%shidraw%d", len
? "," : "",
1239 ((struct hidraw
*)hdev
->hidraw
)->minor
);
1242 for (i
= 0; i
< hdev
->maxcollection
; i
++) {
1243 struct hid_collection
*col
= &hdev
->collection
[i
];
1244 if (col
->type
== HID_COLLECTION_APPLICATION
&&
1245 (col
->usage
& HID_USAGE_PAGE
) == HID_UP_GENDESK
&&
1246 (col
->usage
& 0xffff) < ARRAY_SIZE(types
)) {
1247 type
= types
[col
->usage
& 0xffff];
1252 switch (hdev
->bus
) {
1263 ret
= device_create_bin_file(&hdev
->dev
, &dev_bin_attr_report_desc
);
1266 "can't create sysfs report descriptor attribute err: %d\n", ret
);
1268 hid_info(hdev
, "%s: %s HID v%x.%02x %s [%s] on %s\n",
1269 buf
, bus
, hdev
->version
>> 8, hdev
->version
& 0xff,
1270 type
, hdev
->name
, hdev
->phys
);
1274 EXPORT_SYMBOL_GPL(hid_connect
);
1276 void hid_disconnect(struct hid_device
*hdev
)
1278 device_remove_bin_file(&hdev
->dev
, &dev_bin_attr_report_desc
);
1279 if (hdev
->claimed
& HID_CLAIMED_INPUT
)
1280 hidinput_disconnect(hdev
);
1281 if (hdev
->claimed
& HID_CLAIMED_HIDDEV
)
1282 hdev
->hiddev_disconnect(hdev
);
1283 if (hdev
->claimed
& HID_CLAIMED_HIDRAW
)
1284 hidraw_disconnect(hdev
);
1286 EXPORT_SYMBOL_GPL(hid_disconnect
);
1288 /* a list of devices for which there is a specialized driver on HID bus */
1289 static const struct hid_device_id hid_have_special_driver
[] = {
1290 { HID_USB_DEVICE(USB_VENDOR_ID_3M
, USB_DEVICE_ID_3M1968
) },
1291 { HID_USB_DEVICE(USB_VENDOR_ID_3M
, USB_DEVICE_ID_3M2256
) },
1292 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH
, USB_DEVICE_ID_A4TECH_WCP32PU
) },
1293 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH
, USB_DEVICE_ID_A4TECH_X5_005D
) },
1294 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH
, USB_DEVICE_ID_A4TECH_RP_649
) },
1295 { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX
, 0x0802) },
1296 { HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR
, USB_DEVICE_ID_ACTIONSTAR_1011
) },
1297 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ATV_IRCONTROL
) },
1298 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_IRCONTROL4
) },
1299 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_MIGHTYMOUSE
) },
1300 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_MAGICMOUSE
) },
1301 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_MAGICTRACKPAD
) },
1302 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI
) },
1303 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO
) },
1304 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER_ANSI
) },
1305 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER_ISO
) },
1306 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER_JIS
) },
1307 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER3_ANSI
) },
1308 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER3_ISO
) },
1309 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER3_JIS
) },
1310 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_ANSI
) },
1311 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_ISO
) },
1312 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_JIS
) },
1313 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI
) },
1314 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_MINI_ISO
) },
1315 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_MINI_JIS
) },
1316 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_ANSI
) },
1317 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_ISO
) },
1318 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_JIS
) },
1319 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI
) },
1320 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO
) },
1321 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS
) },
1322 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI
) },
1323 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO
) },
1324 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS
) },
1325 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI
) },
1326 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING_ISO
) },
1327 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING_JIS
) },
1328 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI
) },
1329 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO
) },
1330 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS
) },
1331 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI
) },
1332 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO
) },
1333 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS
) },
1334 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI
) },
1335 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO
) },
1336 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS
) },
1337 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI
) },
1338 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO
) },
1339 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS
) },
1340 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI
) },
1341 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO
) },
1342 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS
) },
1343 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI
) },
1344 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO
) },
1345 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS
) },
1346 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY
) },
1347 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY
) },
1348 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS
, USB_DEVICE_ID_ASUS_T91MT
) },
1349 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS
, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO
) },
1350 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN
, USB_DEVICE_ID_FLIP_KVM
) },
1351 { HID_USB_DEVICE(USB_VENDOR_ID_BTC
, USB_DEVICE_ID_BTC_EMPREX_REMOTE
) },
1352 { HID_USB_DEVICE(USB_VENDOR_ID_BTC
, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2
) },
1353 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO
, USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH
) },
1354 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO
, USB_DEVICE_ID_CANDO_MULTI_TOUCH
) },
1355 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO
, USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1
) },
1356 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO
, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6
) },
1357 { HID_USB_DEVICE(USB_VENDOR_ID_CANDO
, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6
) },
1358 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY
, USB_DEVICE_ID_CHERRY_CYMOTION
) },
1359 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY
, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR
) },
1360 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY
, USB_DEVICE_ID_CHICONY_TACTICAL_PAD
) },
1361 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY
, USB_DEVICE_ID_CHICONY_WIRELESS
) },
1362 { HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT
, USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH
) },
1363 { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS
, USB_DEVICE_ID_PRODIKEYS_PCMIDI
) },
1364 { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH
, USB_DEVICE_ID_CVTOUCH_SCREEN
) },
1365 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS
, USB_DEVICE_ID_CYPRESS_BARCODE_1
) },
1366 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS
, USB_DEVICE_ID_CYPRESS_BARCODE_2
) },
1367 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS
, USB_DEVICE_ID_CYPRESS_BARCODE_3
) },
1368 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS
, USB_DEVICE_ID_CYPRESS_MOUSE
) },
1369 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS
, USB_DEVICE_ID_CYPRESS_TRUETOUCH
) },
1370 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE
, 0x0006) },
1371 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE
, 0x0011) },
1372 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV
, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH
) },
1373 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV
, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1
) },
1374 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV
, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2
) },
1375 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV
, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3
) },
1376 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV
, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4
) },
1377 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM
, USB_DEVICE_ID_ELECOM_BM084
) },
1378 { HID_USB_DEVICE(USB_VENDOR_ID_ELO
, USB_DEVICE_ID_ELO_TS2515
) },
1379 { HID_USB_DEVICE(USB_VENDOR_ID_EMS
, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II
) },
1380 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY
, USB_DEVICE_ID_BTC_8193
) },
1381 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON
, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR
) },
1382 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON
, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR
) },
1383 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH
, USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS
) },
1384 { HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH
, USB_DEVICE_ID_GOODTOUCH_000f
) },
1385 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA
, 0x0003) },
1386 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA
, 0x0012) },
1387 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION
, USB_DEVICE_ID_GYRATION_REMOTE
) },
1388 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION
, USB_DEVICE_ID_GYRATION_REMOTE_2
) },
1389 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION
, USB_DEVICE_ID_GYRATION_REMOTE_3
) },
1390 { HID_USB_DEVICE(USB_VENDOR_ID_HANVON
, USB_DEVICE_ID_HANVON_MULTITOUCH
) },
1391 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK
, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP
) },
1392 { HID_USB_DEVICE(USB_VENDOR_ID_ILITEK
, USB_DEVICE_ID_ILITEK_MULTITOUCH
) },
1393 { HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS
, USB_DEVICE_ID_IRTOUCH_INFRARED_USB
) },
1394 { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON
, USB_DEVICE_ID_KS_SLIMBLADE
) },
1395 { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH
, USB_DEVICE_ID_KEYTOUCH_IEC
) },
1396 { HID_USB_DEVICE(USB_VENDOR_ID_KYE
, USB_DEVICE_ID_KYE_ERGO_525V
) },
1397 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC
, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD
) },
1398 { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER
, USB_DEVICE_ID_LCPOWER_LC1000
) },
1399 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_MX3000_RECEIVER
) },
1400 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_S510_RECEIVER
) },
1401 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_S510_RECEIVER_2
) },
1402 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_RECEIVER
) },
1403 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_DINOVO_DESKTOP
) },
1404 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_DINOVO_EDGE
) },
1405 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_DINOVO_MINI
) },
1406 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_ELITE_KBD
) },
1407 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500
) },
1408 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_EXTREME_3D
) },
1409 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_WHEEL
) },
1410 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD
) },
1411 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_RUMBLEPAD
) },
1412 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2
) },
1413 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D
) },
1414 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG
) },
1415 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO
) },
1416 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940
) },
1417 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL
) },
1418 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2
) },
1419 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_DFP_WHEEL
) },
1420 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_G25_WHEEL
) },
1421 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_G27_WHEEL
) },
1422 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_WII_WHEEL
) },
1423 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2
) },
1424 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_SPACETRAVELLER
) },
1425 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH
, USB_DEVICE_ID_SPACENAVIGATOR
) },
1426 { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO
, USB_DEVICE_ID_CRYSTALTOUCH
) },
1427 { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO
, USB_DEVICE_ID_CRYSTALTOUCH_DUAL
) },
1428 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP
, USB_DEVICE_ID_PICOLCD
) },
1429 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP
, USB_DEVICE_ID_PICOLCD_BOOTLOADER
) },
1430 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT
, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500
) },
1431 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT
, USB_DEVICE_ID_SIDEWINDER_GV
) },
1432 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT
, USB_DEVICE_ID_MS_NE4K
) },
1433 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT
, USB_DEVICE_ID_MS_LK6K
) },
1434 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT
, USB_DEVICE_ID_MS_PRESENTER_8K_USB
) },
1435 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT
, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K
) },
1436 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT
, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0
) },
1437 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY
, USB_DEVICE_ID_GENIUS_KB29E
) },
1438 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN
) },
1439 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1
) },
1440 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2
) },
1441 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3
) },
1442 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4
) },
1443 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5
) },
1444 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6
) },
1445 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7
) },
1446 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8
) },
1447 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9
) },
1448 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10
) },
1449 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11
) },
1450 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12
) },
1451 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13
) },
1452 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14
) },
1453 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15
) },
1454 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16
) },
1455 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17
) },
1456 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18
) },
1457 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK
, USB_DEVICE_ID_ORTEK_PKB1700
) },
1458 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK
, USB_DEVICE_ID_ORTEK_WKB2000
) },
1459 { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT
, USB_DEVICE_ID_PENMOUNT_PCI
) },
1460 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX
, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE
) },
1461 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA
, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH
) },
1462 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA
, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN
) },
1463 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT
, USB_DEVICE_ID_ROCCAT_KONE
) },
1464 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT
, USB_DEVICE_ID_ROCCAT_ARVO
) },
1465 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT
, USB_DEVICE_ID_ROCCAT_KONEPLUS
) },
1466 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT
, USB_DEVICE_ID_ROCCAT_KOVAPLUS
) },
1467 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT
, USB_DEVICE_ID_ROCCAT_PYRA_WIRED
) },
1468 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT
, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS
) },
1469 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG
, USB_DEVICE_ID_SAMSUNG_IR_REMOTE
) },
1470 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG
, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE
) },
1471 { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE
, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER
) },
1472 { HID_USB_DEVICE(USB_VENDOR_ID_SONY
, USB_DEVICE_ID_SONY_PS3_CONTROLLER
) },
1473 { HID_USB_DEVICE(USB_VENDOR_ID_SONY
, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER
) },
1474 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY
, USB_DEVICE_ID_SONY_PS3_CONTROLLER
) },
1475 { HID_USB_DEVICE(USB_VENDOR_ID_SONY
, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE
) },
1476 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM
, USB_DEVICE_ID_MTP
) },
1477 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM
, USB_DEVICE_ID_MTP_STM
) },
1478 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX
, USB_DEVICE_ID_MTP_SITRONIX
) },
1479 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS
, USB_DEVICE_ID_SUNPLUS_WDESKTOP
) },
1480 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER
, 0xb300) },
1481 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER
, 0xb304) },
1482 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER
, 0xb323) },
1483 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER
, 0xb324) },
1484 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER
, 0xb651) },
1485 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER
, 0xb653) },
1486 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER
, 0xb654) },
1487 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER
, 0xb65a) },
1488 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED
, USB_DEVICE_ID_TOPSEED_CYBERLINK
) },
1489 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2
, USB_DEVICE_ID_TOPSEED2_RF_COMBO
) },
1490 { HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL
, USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH
) },
1491 { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN
, USB_DEVICE_ID_TWINHAN_IR_REMOTE
) },
1492 { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX
, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART
) },
1493 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC
, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209
) },
1494 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC
, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U
) },
1495 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC
, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U
) },
1496 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC
, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U
) },
1497 { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC
, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062
) },
1498 { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC
, USB_DEVICE_ID_UNITEC_USB_TOUCH_0709
) },
1499 { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC
, USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19
) },
1500 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP
, USB_DEVICE_ID_SMARTJOY_PLUS
) },
1501 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM
, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH
) },
1502 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP
, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH
) },
1503 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP
, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH
) },
1504 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP
, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH
) },
1505 { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP
, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH
) },
1506 { HID_USB_DEVICE(USB_VENDOR_ID_XAT
, USB_DEVICE_ID_XAT_CSR
) },
1507 { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS
, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE
) },
1508 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS
, 0x0005) },
1509 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS
, 0x0030) },
1510 { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON
, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL
) },
1512 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT
, USB_DEVICE_ID_MS_PRESENTER_8K_BT
) },
1513 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO
, USB_DEVICE_ID_NINTENDO_WIIMOTE
) },
1518 struct list_head list
;
1519 struct hid_device_id id
;
1523 * store_new_id - add a new HID device ID to this driver and re-probe devices
1524 * @driver: target device driver
1525 * @buf: buffer for scanning device ID data
1526 * @count: input size
1528 * Adds a new dynamic hid device ID to this driver,
1529 * and causes the driver to probe for all devices again.
1531 static ssize_t
store_new_id(struct device_driver
*drv
, const char *buf
,
1534 struct hid_driver
*hdrv
= container_of(drv
, struct hid_driver
, driver
);
1535 struct hid_dynid
*dynid
;
1536 __u32 bus
, vendor
, product
;
1537 unsigned long driver_data
= 0;
1540 ret
= sscanf(buf
, "%x %x %x %lx",
1541 &bus
, &vendor
, &product
, &driver_data
);
1545 dynid
= kzalloc(sizeof(*dynid
), GFP_KERNEL
);
1549 dynid
->id
.bus
= bus
;
1550 dynid
->id
.vendor
= vendor
;
1551 dynid
->id
.product
= product
;
1552 dynid
->id
.driver_data
= driver_data
;
1554 spin_lock(&hdrv
->dyn_lock
);
1555 list_add_tail(&dynid
->list
, &hdrv
->dyn_list
);
1556 spin_unlock(&hdrv
->dyn_lock
);
1559 if (get_driver(&hdrv
->driver
)) {
1560 ret
= driver_attach(&hdrv
->driver
);
1561 put_driver(&hdrv
->driver
);
1564 return ret
? : count
;
1566 static DRIVER_ATTR(new_id
, S_IWUSR
, NULL
, store_new_id
);
1568 static void hid_free_dynids(struct hid_driver
*hdrv
)
1570 struct hid_dynid
*dynid
, *n
;
1572 spin_lock(&hdrv
->dyn_lock
);
1573 list_for_each_entry_safe(dynid
, n
, &hdrv
->dyn_list
, list
) {
1574 list_del(&dynid
->list
);
1577 spin_unlock(&hdrv
->dyn_lock
);
1580 static const struct hid_device_id
*hid_match_device(struct hid_device
*hdev
,
1581 struct hid_driver
*hdrv
)
1583 struct hid_dynid
*dynid
;
1585 spin_lock(&hdrv
->dyn_lock
);
1586 list_for_each_entry(dynid
, &hdrv
->dyn_list
, list
) {
1587 if (hid_match_one_id(hdev
, &dynid
->id
)) {
1588 spin_unlock(&hdrv
->dyn_lock
);
1592 spin_unlock(&hdrv
->dyn_lock
);
1594 return hid_match_id(hdev
, hdrv
->id_table
);
1597 static int hid_bus_match(struct device
*dev
, struct device_driver
*drv
)
1599 struct hid_driver
*hdrv
= container_of(drv
, struct hid_driver
, driver
);
1600 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
1602 if (!hid_match_device(hdev
, hdrv
))
1605 /* generic wants all that don't have specialized driver */
1606 if (!strncmp(hdrv
->name
, "generic-", 8))
1607 return !hid_match_id(hdev
, hid_have_special_driver
);
1612 static int hid_device_probe(struct device
*dev
)
1614 struct hid_driver
*hdrv
= container_of(dev
->driver
,
1615 struct hid_driver
, driver
);
1616 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
1617 const struct hid_device_id
*id
;
1620 if (!hdev
->driver
) {
1621 id
= hid_match_device(hdev
, hdrv
);
1625 hdev
->driver
= hdrv
;
1627 ret
= hdrv
->probe(hdev
, id
);
1628 } else { /* default probe */
1629 ret
= hid_parse(hdev
);
1631 ret
= hid_hw_start(hdev
, HID_CONNECT_DEFAULT
);
1634 hdev
->driver
= NULL
;
1639 static int hid_device_remove(struct device
*dev
)
1641 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
1642 struct hid_driver
*hdrv
= hdev
->driver
;
1647 else /* default remove */
1649 hdev
->driver
= NULL
;
1655 static int hid_uevent(struct device
*dev
, struct kobj_uevent_env
*env
)
1657 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
1659 if (add_uevent_var(env
, "HID_ID=%04X:%08X:%08X",
1660 hdev
->bus
, hdev
->vendor
, hdev
->product
))
1663 if (add_uevent_var(env
, "HID_NAME=%s", hdev
->name
))
1666 if (add_uevent_var(env
, "HID_PHYS=%s", hdev
->phys
))
1669 if (add_uevent_var(env
, "HID_UNIQ=%s", hdev
->uniq
))
1672 if (add_uevent_var(env
, "MODALIAS=hid:b%04Xv%08Xp%08X",
1673 hdev
->bus
, hdev
->vendor
, hdev
->product
))
1679 static struct bus_type hid_bus_type
= {
1681 .match
= hid_bus_match
,
1682 .probe
= hid_device_probe
,
1683 .remove
= hid_device_remove
,
1684 .uevent
= hid_uevent
,
1687 /* a list of devices that shouldn't be handled by HID core at all */
1688 static const struct hid_device_id hid_ignore_list
[] = {
1689 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD
, USB_DEVICE_ID_ACECAD_FLAIR
) },
1690 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD
, USB_DEVICE_ID_ACECAD_302
) },
1691 { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH
, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X
) },
1692 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK
, USB_DEVICE_ID_AIPTEK_01
) },
1693 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK
, USB_DEVICE_ID_AIPTEK_10
) },
1694 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK
, USB_DEVICE_ID_AIPTEK_20
) },
1695 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK
, USB_DEVICE_ID_AIPTEK_21
) },
1696 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK
, USB_DEVICE_ID_AIPTEK_22
) },
1697 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK
, USB_DEVICE_ID_AIPTEK_23
) },
1698 { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK
, USB_DEVICE_ID_AIPTEK_24
) },
1699 { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE
, USB_DEVICE_ID_AIRCABLE1
) },
1700 { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR
, USB_DEVICE_ID_ALCOR_USBRS232
) },
1701 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK
, USB_DEVICE_ID_ASUSTEK_LCM
)},
1702 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK
, USB_DEVICE_ID_ASUSTEK_LCM2
)},
1703 { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA
, USB_DEVICE_ID_AVER_FM_MR800
) },
1704 { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE
, USB_DEVICE_ID_BERKSHIRE_PCWD
) },
1705 { HID_USB_DEVICE(USB_VENDOR_ID_CIDC
, 0x0103) },
1706 { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL
, USB_DEVICE_ID_CYGNAL_RADIO_SI470X
) },
1707 { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA
, USB_DEVICE_ID_CM109
) },
1708 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS
, USB_DEVICE_ID_CYPRESS_HIDCOM
) },
1709 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS
, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE
) },
1710 { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME
, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701
) },
1711 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME
, USB_DEVICE_ID_DELORME_EARTHMATE
) },
1712 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME
, USB_DEVICE_ID_DELORME_EM_LT20
) },
1713 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY
, 0x0004) },
1714 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY
, USB_DEVICE_ID_ESSENTIAL_REALITY_P5
) },
1715 { HID_USB_DEVICE(USB_VENDOR_ID_ETT
, USB_DEVICE_ID_TC5UH
) },
1716 { HID_USB_DEVICE(USB_VENDOR_ID_ETT
, USB_DEVICE_ID_TC4UM
) },
1717 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH
, 0x0002) },
1718 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH
, 0x0003) },
1719 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH
, 0x0004) },
1720 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB
, USB_DEVICE_ID_4_PHIDGETSERVO_30
) },
1721 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB
, USB_DEVICE_ID_1_PHIDGETSERVO_30
) },
1722 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB
, USB_DEVICE_ID_0_0_4_IF_KIT
) },
1723 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB
, USB_DEVICE_ID_0_16_16_IF_KIT
) },
1724 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB
, USB_DEVICE_ID_8_8_8_IF_KIT
) },
1725 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB
, USB_DEVICE_ID_0_8_7_IF_KIT
) },
1726 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB
, USB_DEVICE_ID_0_8_8_IF_KIT
) },
1727 { HID_USB_DEVICE(USB_VENDOR_ID_GLAB
, USB_DEVICE_ID_PHIDGET_MOTORCONTROL
) },
1728 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP
, USB_DEVICE_ID_SUPER_Q2
) },
1729 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP
, USB_DEVICE_ID_GOGOPEN
) },
1730 { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP
, USB_DEVICE_ID_PENPOWER
) },
1731 { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH
, USB_DEVICE_ID_GRETAGMACBETH_HUEY
) },
1732 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN
, USB_DEVICE_ID_POWERMATE
) },
1733 { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN
, USB_DEVICE_ID_SOUNDKNOB
) },
1734 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_90
) },
1735 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_100
) },
1736 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_101
) },
1737 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_103
) },
1738 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_104
) },
1739 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_105
) },
1740 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_106
) },
1741 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_107
) },
1742 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_108
) },
1743 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_200
) },
1744 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_201
) },
1745 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_202
) },
1746 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_203
) },
1747 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_204
) },
1748 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_205
) },
1749 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_206
) },
1750 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_207
) },
1751 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_300
) },
1752 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_301
) },
1753 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_302
) },
1754 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_303
) },
1755 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_304
) },
1756 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_305
) },
1757 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_306
) },
1758 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_307
) },
1759 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_308
) },
1760 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_309
) },
1761 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_400
) },
1762 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_401
) },
1763 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_402
) },
1764 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_403
) },
1765 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_404
) },
1766 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_405
) },
1767 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_500
) },
1768 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_501
) },
1769 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_502
) },
1770 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_503
) },
1771 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_504
) },
1772 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_1000
) },
1773 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_1001
) },
1774 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_1002
) },
1775 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_1003
) },
1776 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_1004
) },
1777 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_1005
) },
1778 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_1006
) },
1779 { HID_USB_DEVICE(USB_VENDOR_ID_GTCO
, USB_DEVICE_ID_GTCO_1007
) },
1780 { HID_USB_DEVICE(USB_VENDOR_ID_IMATION
, USB_DEVICE_ID_DISC_STAKKA
) },
1781 { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR
, USB_DEVICE_ID_KBGEAR_JAMSTUDIO
) },
1782 { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD
, USB_DEVICE_ID_KWORLD_RADIO_FM700
) },
1783 { HID_USB_DEVICE(USB_VENDOR_ID_KYE
, USB_DEVICE_ID_KYE_GPEN_560
) },
1784 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE
, 0x0058) },
1785 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_CASSY
) },
1786 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_CASSY2
) },
1787 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_POCKETCASSY
) },
1788 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_POCKETCASSY2
) },
1789 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MOBILECASSY
) },
1790 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MOBILECASSY2
) },
1791 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE
) },
1792 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MICROCASSYCURRENT
) },
1793 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MICROCASSYTIME
) },
1794 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE
) },
1795 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MICROCASSYPH
) },
1796 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_JWM
) },
1797 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_DMMP
) },
1798 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_UMIP
) },
1799 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_UMIC
) },
1800 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_UMIB
) },
1801 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_XRAY
) },
1802 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_XRAY2
) },
1803 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_VIDEOCOM
) },
1804 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MOTOR
) },
1805 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_COM3LAB
) },
1806 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_TELEPORT
) },
1807 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_NETWORKANALYSER
) },
1808 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_POWERCONTROL
) },
1809 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MACHINETEST
) },
1810 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MOSTANALYSER
) },
1811 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MOSTANALYSER2
) },
1812 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_ABSESP
) },
1813 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_AUTODATABUS
) },
1814 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_MCT
) },
1815 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_HYBRID
) },
1816 { HID_USB_DEVICE(USB_VENDOR_ID_LD
, USB_DEVICE_ID_LD_HEATCONTROL
) },
1817 { HID_USB_DEVICE(USB_VENDOR_ID_MCC
, USB_DEVICE_ID_MCC_PMD1024LS
) },
1818 { HID_USB_DEVICE(USB_VENDOR_ID_MCC
, USB_DEVICE_ID_MCC_PMD1208LS
) },
1819 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP
, USB_DEVICE_ID_PICKIT1
) },
1820 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP
, USB_DEVICE_ID_PICKIT2
) },
1821 { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR
, USB_DEVICE_ID_N_S_HARMONY
) },
1822 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK
, USB_DEVICE_ID_ONTRAK_ADU100
) },
1823 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK
, USB_DEVICE_ID_ONTRAK_ADU100
+ 20) },
1824 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK
, USB_DEVICE_ID_ONTRAK_ADU100
+ 30) },
1825 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK
, USB_DEVICE_ID_ONTRAK_ADU100
+ 100) },
1826 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK
, USB_DEVICE_ID_ONTRAK_ADU100
+ 108) },
1827 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK
, USB_DEVICE_ID_ONTRAK_ADU100
+ 118) },
1828 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK
, USB_DEVICE_ID_ONTRAK_ADU100
+ 200) },
1829 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK
, USB_DEVICE_ID_ONTRAK_ADU100
+ 300) },
1830 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK
, USB_DEVICE_ID_ONTRAK_ADU100
+ 400) },
1831 { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK
, USB_DEVICE_ID_ONTRAK_ADU100
+ 500) },
1832 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT
, 0x0001) },
1833 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT
, 0x0002) },
1834 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT
, 0x0003) },
1835 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT
, 0x0004) },
1836 { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS
, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE
) },
1837 { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM
, USB_DEVICE_ID_POWERCOM_UPS
) },
1838 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER
, USB_DEVICE_ID_VERNIER_LABPRO
) },
1839 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER
, USB_DEVICE_ID_VERNIER_GOTEMP
) },
1840 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER
, USB_DEVICE_ID_VERNIER_SKIP
) },
1841 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER
, USB_DEVICE_ID_VERNIER_CYCLOPS
) },
1842 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER
, USB_DEVICE_ID_VERNIER_LCSPEC
) },
1843 { HID_USB_DEVICE(USB_VENDOR_ID_WACOM
, HID_ANY_ID
) },
1844 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP
, USB_DEVICE_ID_4_PHIDGETSERVO_20
) },
1845 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP
, USB_DEVICE_ID_1_PHIDGETSERVO_20
) },
1846 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP
, USB_DEVICE_ID_8_8_4_IF_KIT
) },
1847 { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK
, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K
) },
1852 * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer
1854 * There are composite devices for which we want to ignore only a certain
1855 * interface. This is a list of devices for which only the mouse interface will
1856 * be ignored. This allows a dedicated driver to take care of the interface.
1858 static const struct hid_device_id hid_mouse_ignore_list
[] = {
1859 /* appletouch driver */
1860 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI
) },
1861 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO
) },
1862 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER_ANSI
) },
1863 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER_ISO
) },
1864 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER_JIS
) },
1865 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER3_ANSI
) },
1866 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER3_ISO
) },
1867 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER3_JIS
) },
1868 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_ANSI
) },
1869 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_ISO
) },
1870 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_JIS
) },
1871 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI
) },
1872 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO
) },
1873 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS
) },
1874 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI
) },
1875 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING_ISO
) },
1876 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING_JIS
) },
1877 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI
) },
1878 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO
) },
1879 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS
) },
1880 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI
) },
1881 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO
) },
1882 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS
) },
1883 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI
) },
1884 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO
) },
1885 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS
) },
1886 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI
) },
1887 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO
) },
1888 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS
) },
1889 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI
) },
1890 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO
) },
1891 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS
) },
1892 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY
) },
1893 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE
, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY
) },
1897 static bool hid_ignore(struct hid_device
*hdev
)
1899 switch (hdev
->vendor
) {
1900 case USB_VENDOR_ID_CODEMERCS
:
1901 /* ignore all Code Mercenaries IOWarrior devices */
1902 if (hdev
->product
>= USB_DEVICE_ID_CODEMERCS_IOW_FIRST
&&
1903 hdev
->product
<= USB_DEVICE_ID_CODEMERCS_IOW_LAST
)
1906 case USB_VENDOR_ID_LOGITECH
:
1907 if (hdev
->product
>= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST
&&
1908 hdev
->product
<= USB_DEVICE_ID_LOGITECH_HARMONY_LAST
)
1911 case USB_VENDOR_ID_SOUNDGRAPH
:
1912 if (hdev
->product
>= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST
&&
1913 hdev
->product
<= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST
)
1916 case USB_VENDOR_ID_HANWANG
:
1917 if (hdev
->product
>= USB_DEVICE_ID_HANWANG_TABLET_FIRST
&&
1918 hdev
->product
<= USB_DEVICE_ID_HANWANG_TABLET_LAST
)
1921 case USB_VENDOR_ID_JESS
:
1922 if (hdev
->product
== USB_DEVICE_ID_JESS_YUREX
&&
1923 hdev
->type
== HID_TYPE_USBNONE
)
1928 if (hdev
->type
== HID_TYPE_USBMOUSE
&&
1929 hid_match_id(hdev
, hid_mouse_ignore_list
))
1932 return !!hid_match_id(hdev
, hid_ignore_list
);
1935 int hid_add_device(struct hid_device
*hdev
)
1937 static atomic_t id
= ATOMIC_INIT(0);
1940 if (WARN_ON(hdev
->status
& HID_STAT_ADDED
))
1943 /* we need to kill them here, otherwise they will stay allocated to
1944 * wait for coming driver */
1945 if (!(hdev
->quirks
& HID_QUIRK_NO_IGNORE
)
1946 && (hid_ignore(hdev
) || (hdev
->quirks
& HID_QUIRK_IGNORE
)))
1949 /* XXX hack, any other cleaner solution after the driver core
1950 * is converted to allow more than 20 bytes as the device name? */
1951 dev_set_name(&hdev
->dev
, "%04X:%04X:%04X.%04X", hdev
->bus
,
1952 hdev
->vendor
, hdev
->product
, atomic_inc_return(&id
));
1954 hid_debug_register(hdev
, dev_name(&hdev
->dev
));
1955 ret
= device_add(&hdev
->dev
);
1957 hdev
->status
|= HID_STAT_ADDED
;
1959 hid_debug_unregister(hdev
);
1963 EXPORT_SYMBOL_GPL(hid_add_device
);
1966 * hid_allocate_device - allocate new hid device descriptor
1968 * Allocate and initialize hid device, so that hid_destroy_device might be
1971 * New hid_device pointer is returned on success, otherwise ERR_PTR encoded
1974 struct hid_device
*hid_allocate_device(void)
1976 struct hid_device
*hdev
;
1980 hdev
= kzalloc(sizeof(*hdev
), GFP_KERNEL
);
1982 return ERR_PTR(ret
);
1984 device_initialize(&hdev
->dev
);
1985 hdev
->dev
.release
= hid_device_release
;
1986 hdev
->dev
.bus
= &hid_bus_type
;
1988 hdev
->collection
= kcalloc(HID_DEFAULT_NUM_COLLECTIONS
,
1989 sizeof(struct hid_collection
), GFP_KERNEL
);
1990 if (hdev
->collection
== NULL
)
1992 hdev
->collection_size
= HID_DEFAULT_NUM_COLLECTIONS
;
1994 for (i
= 0; i
< HID_REPORT_TYPES
; i
++)
1995 INIT_LIST_HEAD(&hdev
->report_enum
[i
].report_list
);
1997 init_waitqueue_head(&hdev
->debug_wait
);
1998 INIT_LIST_HEAD(&hdev
->debug_list
);
2002 put_device(&hdev
->dev
);
2003 return ERR_PTR(ret
);
2005 EXPORT_SYMBOL_GPL(hid_allocate_device
);
2007 static void hid_remove_device(struct hid_device
*hdev
)
2009 if (hdev
->status
& HID_STAT_ADDED
) {
2010 device_del(&hdev
->dev
);
2011 hid_debug_unregister(hdev
);
2012 hdev
->status
&= ~HID_STAT_ADDED
;
2017 * hid_destroy_device - free previously allocated device
2021 * If you allocate hid_device through hid_allocate_device, you should ever
2022 * free by this function.
2024 void hid_destroy_device(struct hid_device
*hdev
)
2026 hid_remove_device(hdev
);
2027 put_device(&hdev
->dev
);
2029 EXPORT_SYMBOL_GPL(hid_destroy_device
);
2031 int __hid_register_driver(struct hid_driver
*hdrv
, struct module
*owner
,
2032 const char *mod_name
)
2036 hdrv
->driver
.name
= hdrv
->name
;
2037 hdrv
->driver
.bus
= &hid_bus_type
;
2038 hdrv
->driver
.owner
= owner
;
2039 hdrv
->driver
.mod_name
= mod_name
;
2041 INIT_LIST_HEAD(&hdrv
->dyn_list
);
2042 spin_lock_init(&hdrv
->dyn_lock
);
2044 ret
= driver_register(&hdrv
->driver
);
2048 ret
= driver_create_file(&hdrv
->driver
, &driver_attr_new_id
);
2050 driver_unregister(&hdrv
->driver
);
2054 EXPORT_SYMBOL_GPL(__hid_register_driver
);
2056 void hid_unregister_driver(struct hid_driver
*hdrv
)
2058 driver_remove_file(&hdrv
->driver
, &driver_attr_new_id
);
2059 driver_unregister(&hdrv
->driver
);
2060 hid_free_dynids(hdrv
);
2062 EXPORT_SYMBOL_GPL(hid_unregister_driver
);
2064 int hid_check_keys_pressed(struct hid_device
*hid
)
2066 struct hid_input
*hidinput
;
2069 if (!(hid
->claimed
& HID_CLAIMED_INPUT
))
2072 list_for_each_entry(hidinput
, &hid
->inputs
, list
) {
2073 for (i
= 0; i
< BITS_TO_LONGS(KEY_MAX
); i
++)
2074 if (hidinput
->input
->key
[i
])
2081 EXPORT_SYMBOL_GPL(hid_check_keys_pressed
);
2083 static int __init
hid_init(void)
2088 pr_warn("hid_debug is now used solely for parser and driver debugging.\n"
2089 "debugfs is now used for inspecting the device (report descriptor, reports)\n");
2091 ret
= bus_register(&hid_bus_type
);
2093 pr_err("can't register hid bus\n");
2097 ret
= hidraw_init();
2105 bus_unregister(&hid_bus_type
);
2110 static void __exit
hid_exit(void)
2114 bus_unregister(&hid_bus_type
);
2117 module_init(hid_init
);
2118 module_exit(hid_exit
);
2120 MODULE_AUTHOR("Andreas Gal");
2121 MODULE_AUTHOR("Vojtech Pavlik");
2122 MODULE_AUTHOR("Jiri Kosina");
2123 MODULE_LICENSE(DRIVER_LICENSE
);