Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 1 | /* |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 2 | * HID support for Linux |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 3 | * |
| 4 | * Copyright (c) 1999 Andreas Gal |
| 5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> |
| 6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc |
Jiri Kosina | 7d39e84 | 2010-02-02 20:46:34 +0100 | [diff] [blame] | 7 | * Copyright (c) 2006-2010 Jiri Kosina |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 8 | */ |
| 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 Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 18 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 19 | #include <linux/module.h> |
| 20 | #include <linux/slab.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/kernel.h> |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 23 | #include <linux/list.h> |
| 24 | #include <linux/mm.h> |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 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> |
Jiri Kosina | 47a80ed | 2007-03-12 14:55:12 +0100 | [diff] [blame] | 30 | #include <linux/vmalloc.h> |
Jiri Kosina | c4124c9 | 2007-11-30 11:12:58 +0100 | [diff] [blame] | 31 | #include <linux/sched.h> |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 32 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 33 | #include <linux/hid.h> |
| 34 | #include <linux/hiddev.h> |
Jiri Kosina | c080d89 | 2007-01-25 11:43:31 +0100 | [diff] [blame] | 35 | #include <linux/hid-debug.h> |
Jiri Kosina | 86166b7 | 2007-05-14 09:57:40 +0200 | [diff] [blame] | 36 | #include <linux/hidraw.h> |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 37 | |
Jiri Slaby | 5f22a79 | 2008-05-16 11:49:19 +0200 | [diff] [blame] | 38 | #include "hid-ids.h" |
| 39 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 40 | /* |
| 41 | * Version Information |
| 42 | */ |
| 43 | |
Jiri Kosina | 5314980 | 2007-01-09 13:24:25 +0100 | [diff] [blame] | 44 | #define DRIVER_DESC "HID core driver" |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 45 | #define DRIVER_LICENSE "GPL" |
| 46 | |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 47 | int hid_debug = 0; |
Anssi Hannula | 377e10f | 2008-03-22 23:50:13 +0100 | [diff] [blame] | 48 | module_param_named(debug, hid_debug, int, 0600); |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 49 | MODULE_PARM_DESC(debug, "toggle HID debugging messages"); |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 50 | EXPORT_SYMBOL_GPL(hid_debug); |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 51 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 52 | /* |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 53 | * Register a new report for a device. |
| 54 | */ |
| 55 | |
Michael Poole | 90a006a | 2010-01-24 22:32:29 -0500 | [diff] [blame] | 56 | struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 57 | { |
| 58 | struct hid_report_enum *report_enum = device->report_enum + type; |
| 59 | struct hid_report *report; |
| 60 | |
| 61 | if (report_enum->report_id_hash[id]) |
| 62 | return report_enum->report_id_hash[id]; |
| 63 | |
| 64 | if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL))) |
| 65 | return NULL; |
| 66 | |
| 67 | if (id != 0) |
| 68 | report_enum->numbered = 1; |
| 69 | |
| 70 | report->id = id; |
| 71 | report->type = type; |
| 72 | report->size = 0; |
| 73 | report->device = device; |
| 74 | report_enum->report_id_hash[id] = report; |
| 75 | |
| 76 | list_add_tail(&report->list, &report_enum->report_list); |
| 77 | |
| 78 | return report; |
| 79 | } |
Michael Poole | 90a006a | 2010-01-24 22:32:29 -0500 | [diff] [blame] | 80 | EXPORT_SYMBOL_GPL(hid_register_report); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 81 | |
| 82 | /* |
| 83 | * Register a new field for this report. |
| 84 | */ |
| 85 | |
| 86 | static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) |
| 87 | { |
| 88 | struct hid_field *field; |
| 89 | |
| 90 | if (report->maxfield == HID_MAX_FIELDS) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 91 | dbg_hid("too many fields in report\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 92 | return NULL; |
| 93 | } |
| 94 | |
| 95 | if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage) |
| 96 | + values * sizeof(unsigned), GFP_KERNEL))) return NULL; |
| 97 | |
| 98 | field->index = report->maxfield++; |
| 99 | report->field[field->index] = field; |
| 100 | field->usage = (struct hid_usage *)(field + 1); |
Jiri Slaby | 282bfd4 | 2008-03-28 17:06:41 +0100 | [diff] [blame] | 101 | field->value = (s32 *)(field->usage + usages); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 102 | field->report = report; |
| 103 | |
| 104 | return field; |
| 105 | } |
| 106 | |
| 107 | /* |
| 108 | * Open a collection. The type/usage is pushed on the stack. |
| 109 | */ |
| 110 | |
| 111 | static int open_collection(struct hid_parser *parser, unsigned type) |
| 112 | { |
| 113 | struct hid_collection *collection; |
| 114 | unsigned usage; |
| 115 | |
| 116 | usage = parser->local.usage[0]; |
| 117 | |
| 118 | if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 119 | dbg_hid("collection stack overflow\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 120 | return -1; |
| 121 | } |
| 122 | |
| 123 | if (parser->device->maxcollection == parser->device->collection_size) { |
| 124 | collection = kmalloc(sizeof(struct hid_collection) * |
| 125 | parser->device->collection_size * 2, GFP_KERNEL); |
| 126 | if (collection == NULL) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 127 | dbg_hid("failed to reallocate collection array\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 128 | return -1; |
| 129 | } |
| 130 | memcpy(collection, parser->device->collection, |
| 131 | sizeof(struct hid_collection) * |
| 132 | parser->device->collection_size); |
| 133 | memset(collection + parser->device->collection_size, 0, |
| 134 | sizeof(struct hid_collection) * |
| 135 | parser->device->collection_size); |
| 136 | kfree(parser->device->collection); |
| 137 | parser->device->collection = collection; |
| 138 | parser->device->collection_size *= 2; |
| 139 | } |
| 140 | |
| 141 | parser->collection_stack[parser->collection_stack_ptr++] = |
| 142 | parser->device->maxcollection; |
| 143 | |
| 144 | collection = parser->device->collection + |
| 145 | parser->device->maxcollection++; |
| 146 | collection->type = type; |
| 147 | collection->usage = usage; |
| 148 | collection->level = parser->collection_stack_ptr - 1; |
| 149 | |
| 150 | if (type == HID_COLLECTION_APPLICATION) |
| 151 | parser->device->maxapplication++; |
| 152 | |
| 153 | return 0; |
| 154 | } |
| 155 | |
| 156 | /* |
| 157 | * Close a collection. |
| 158 | */ |
| 159 | |
| 160 | static int close_collection(struct hid_parser *parser) |
| 161 | { |
| 162 | if (!parser->collection_stack_ptr) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 163 | dbg_hid("collection stack underflow\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 164 | return -1; |
| 165 | } |
| 166 | parser->collection_stack_ptr--; |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | /* |
| 171 | * Climb up the stack, search for the specified collection type |
| 172 | * and return the usage. |
| 173 | */ |
| 174 | |
| 175 | static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) |
| 176 | { |
| 177 | int n; |
| 178 | for (n = parser->collection_stack_ptr - 1; n >= 0; n--) |
| 179 | if (parser->device->collection[parser->collection_stack[n]].type == type) |
| 180 | return parser->device->collection[parser->collection_stack[n]].usage; |
| 181 | return 0; /* we know nothing about this usage type */ |
| 182 | } |
| 183 | |
| 184 | /* |
| 185 | * Add a usage to the temporary parser table. |
| 186 | */ |
| 187 | |
| 188 | static int hid_add_usage(struct hid_parser *parser, unsigned usage) |
| 189 | { |
| 190 | if (parser->local.usage_index >= HID_MAX_USAGES) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 191 | dbg_hid("usage index exceeded\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 192 | return -1; |
| 193 | } |
| 194 | parser->local.usage[parser->local.usage_index] = usage; |
| 195 | parser->local.collection_index[parser->local.usage_index] = |
| 196 | parser->collection_stack_ptr ? |
| 197 | parser->collection_stack[parser->collection_stack_ptr - 1] : 0; |
| 198 | parser->local.usage_index++; |
| 199 | return 0; |
| 200 | } |
| 201 | |
| 202 | /* |
| 203 | * Register a new field for this report. |
| 204 | */ |
| 205 | |
| 206 | static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags) |
| 207 | { |
| 208 | struct hid_report *report; |
| 209 | struct hid_field *field; |
| 210 | int usages; |
| 211 | unsigned offset; |
| 212 | int i; |
| 213 | |
| 214 | if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 215 | dbg_hid("hid_register_report failed\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 216 | return -1; |
| 217 | } |
| 218 | |
| 219 | if (parser->global.logical_maximum < parser->global.logical_minimum) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 220 | dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 221 | return -1; |
| 222 | } |
| 223 | |
| 224 | offset = report->size; |
| 225 | report->size += parser->global.report_size * parser->global.report_count; |
| 226 | |
| 227 | if (!parser->local.usage_index) /* Ignore padding fields */ |
| 228 | return 0; |
| 229 | |
| 230 | usages = max_t(int, parser->local.usage_index, parser->global.report_count); |
| 231 | |
| 232 | if ((field = hid_register_field(report, usages, parser->global.report_count)) == NULL) |
| 233 | return 0; |
| 234 | |
| 235 | field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); |
| 236 | field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL); |
| 237 | field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); |
| 238 | |
| 239 | for (i = 0; i < usages; i++) { |
| 240 | int j = i; |
| 241 | /* Duplicate the last usage we parsed if we have excess values */ |
| 242 | if (i >= parser->local.usage_index) |
| 243 | j = parser->local.usage_index - 1; |
| 244 | field->usage[i].hid = parser->local.usage[j]; |
| 245 | field->usage[i].collection_index = |
| 246 | parser->local.collection_index[j]; |
| 247 | } |
| 248 | |
| 249 | field->maxusage = usages; |
| 250 | field->flags = flags; |
| 251 | field->report_offset = offset; |
| 252 | field->report_type = report_type; |
| 253 | field->report_size = parser->global.report_size; |
| 254 | field->report_count = parser->global.report_count; |
| 255 | field->logical_minimum = parser->global.logical_minimum; |
| 256 | field->logical_maximum = parser->global.logical_maximum; |
| 257 | field->physical_minimum = parser->global.physical_minimum; |
| 258 | field->physical_maximum = parser->global.physical_maximum; |
| 259 | field->unit_exponent = parser->global.unit_exponent; |
| 260 | field->unit = parser->global.unit; |
| 261 | |
| 262 | return 0; |
| 263 | } |
| 264 | |
| 265 | /* |
| 266 | * Read data value from item. |
| 267 | */ |
| 268 | |
| 269 | static u32 item_udata(struct hid_item *item) |
| 270 | { |
| 271 | switch (item->size) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 272 | case 1: return item->data.u8; |
| 273 | case 2: return item->data.u16; |
| 274 | case 4: return item->data.u32; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 275 | } |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | static s32 item_sdata(struct hid_item *item) |
| 280 | { |
| 281 | switch (item->size) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 282 | case 1: return item->data.s8; |
| 283 | case 2: return item->data.s16; |
| 284 | case 4: return item->data.s32; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 285 | } |
| 286 | return 0; |
| 287 | } |
| 288 | |
| 289 | /* |
| 290 | * Process a global item. |
| 291 | */ |
| 292 | |
| 293 | static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) |
| 294 | { |
| 295 | switch (item->tag) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 296 | case HID_GLOBAL_ITEM_TAG_PUSH: |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 297 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 298 | if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { |
| 299 | dbg_hid("global enviroment stack overflow\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 300 | return -1; |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | memcpy(parser->global_stack + parser->global_stack_ptr++, |
| 304 | &parser->global, sizeof(struct hid_global)); |
| 305 | return 0; |
| 306 | |
| 307 | case HID_GLOBAL_ITEM_TAG_POP: |
| 308 | |
| 309 | if (!parser->global_stack_ptr) { |
| 310 | dbg_hid("global enviroment stack underflow\n"); |
| 311 | return -1; |
| 312 | } |
| 313 | |
| 314 | memcpy(&parser->global, parser->global_stack + |
| 315 | --parser->global_stack_ptr, sizeof(struct hid_global)); |
| 316 | return 0; |
| 317 | |
| 318 | case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: |
| 319 | parser->global.usage_page = item_udata(item); |
| 320 | return 0; |
| 321 | |
| 322 | case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: |
| 323 | parser->global.logical_minimum = item_sdata(item); |
| 324 | return 0; |
| 325 | |
| 326 | case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: |
| 327 | if (parser->global.logical_minimum < 0) |
| 328 | parser->global.logical_maximum = item_sdata(item); |
| 329 | else |
| 330 | parser->global.logical_maximum = item_udata(item); |
| 331 | return 0; |
| 332 | |
| 333 | case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: |
| 334 | parser->global.physical_minimum = item_sdata(item); |
| 335 | return 0; |
| 336 | |
| 337 | case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: |
| 338 | if (parser->global.physical_minimum < 0) |
| 339 | parser->global.physical_maximum = item_sdata(item); |
| 340 | else |
| 341 | parser->global.physical_maximum = item_udata(item); |
| 342 | return 0; |
| 343 | |
| 344 | case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: |
| 345 | parser->global.unit_exponent = item_sdata(item); |
| 346 | return 0; |
| 347 | |
| 348 | case HID_GLOBAL_ITEM_TAG_UNIT: |
| 349 | parser->global.unit = item_udata(item); |
| 350 | return 0; |
| 351 | |
| 352 | case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: |
| 353 | parser->global.report_size = item_udata(item); |
| 354 | if (parser->global.report_size > 32) { |
| 355 | dbg_hid("invalid report_size %d\n", |
| 356 | parser->global.report_size); |
| 357 | return -1; |
| 358 | } |
| 359 | return 0; |
| 360 | |
| 361 | case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: |
| 362 | parser->global.report_count = item_udata(item); |
| 363 | if (parser->global.report_count > HID_MAX_USAGES) { |
| 364 | dbg_hid("invalid report_count %d\n", |
| 365 | parser->global.report_count); |
| 366 | return -1; |
| 367 | } |
| 368 | return 0; |
| 369 | |
| 370 | case HID_GLOBAL_ITEM_TAG_REPORT_ID: |
| 371 | parser->global.report_id = item_udata(item); |
| 372 | if (parser->global.report_id == 0) { |
| 373 | dbg_hid("report_id 0 is invalid\n"); |
| 374 | return -1; |
| 375 | } |
| 376 | return 0; |
| 377 | |
| 378 | default: |
| 379 | dbg_hid("unknown global tag 0x%x\n", item->tag); |
| 380 | return -1; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | |
| 384 | /* |
| 385 | * Process a local item. |
| 386 | */ |
| 387 | |
| 388 | static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) |
| 389 | { |
| 390 | __u32 data; |
| 391 | unsigned n; |
| 392 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 393 | data = item_udata(item); |
| 394 | |
| 395 | switch (item->tag) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 396 | case HID_LOCAL_ITEM_TAG_DELIMITER: |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 397 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 398 | if (data) { |
| 399 | /* |
| 400 | * We treat items before the first delimiter |
| 401 | * as global to all usage sets (branch 0). |
| 402 | * In the moment we process only these global |
| 403 | * items and the first delimiter set. |
| 404 | */ |
| 405 | if (parser->local.delimiter_depth != 0) { |
| 406 | dbg_hid("nested delimiters\n"); |
| 407 | return -1; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 408 | } |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 409 | parser->local.delimiter_depth++; |
| 410 | parser->local.delimiter_branch++; |
| 411 | } else { |
| 412 | if (parser->local.delimiter_depth < 1) { |
| 413 | dbg_hid("bogus close delimiter\n"); |
| 414 | return -1; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 415 | } |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 416 | parser->local.delimiter_depth--; |
| 417 | } |
| 418 | return 1; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 419 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 420 | case HID_LOCAL_ITEM_TAG_USAGE: |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 421 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 422 | if (parser->local.delimiter_branch > 1) { |
| 423 | dbg_hid("alternative usage ignored\n"); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 424 | return 0; |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 425 | } |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 426 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 427 | if (item->size <= 2) |
| 428 | data = (parser->global.usage_page << 16) + data; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 429 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 430 | return hid_add_usage(parser, data); |
| 431 | |
| 432 | case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: |
| 433 | |
| 434 | if (parser->local.delimiter_branch > 1) { |
| 435 | dbg_hid("alternative usage ignored\n"); |
| 436 | return 0; |
| 437 | } |
| 438 | |
| 439 | if (item->size <= 2) |
| 440 | data = (parser->global.usage_page << 16) + data; |
| 441 | |
| 442 | parser->local.usage_minimum = data; |
| 443 | return 0; |
| 444 | |
| 445 | case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: |
| 446 | |
| 447 | if (parser->local.delimiter_branch > 1) { |
| 448 | dbg_hid("alternative usage ignored\n"); |
| 449 | return 0; |
| 450 | } |
| 451 | |
| 452 | if (item->size <= 2) |
| 453 | data = (parser->global.usage_page << 16) + data; |
| 454 | |
| 455 | for (n = parser->local.usage_minimum; n <= data; n++) |
| 456 | if (hid_add_usage(parser, n)) { |
| 457 | dbg_hid("hid_add_usage failed\n"); |
| 458 | return -1; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 459 | } |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 460 | return 0; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 461 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 462 | default: |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 463 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 464 | dbg_hid("unknown local item tag 0x%x\n", item->tag); |
| 465 | return 0; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 466 | } |
| 467 | return 0; |
| 468 | } |
| 469 | |
| 470 | /* |
| 471 | * Process a main item. |
| 472 | */ |
| 473 | |
| 474 | static int hid_parser_main(struct hid_parser *parser, struct hid_item *item) |
| 475 | { |
| 476 | __u32 data; |
| 477 | int ret; |
| 478 | |
| 479 | data = item_udata(item); |
| 480 | |
| 481 | switch (item->tag) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 482 | case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: |
| 483 | ret = open_collection(parser, data & 0xff); |
| 484 | break; |
| 485 | case HID_MAIN_ITEM_TAG_END_COLLECTION: |
| 486 | ret = close_collection(parser); |
| 487 | break; |
| 488 | case HID_MAIN_ITEM_TAG_INPUT: |
| 489 | ret = hid_add_field(parser, HID_INPUT_REPORT, data); |
| 490 | break; |
| 491 | case HID_MAIN_ITEM_TAG_OUTPUT: |
| 492 | ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); |
| 493 | break; |
| 494 | case HID_MAIN_ITEM_TAG_FEATURE: |
| 495 | ret = hid_add_field(parser, HID_FEATURE_REPORT, data); |
| 496 | break; |
| 497 | default: |
| 498 | dbg_hid("unknown main item tag 0x%x\n", item->tag); |
| 499 | ret = 0; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ |
| 503 | |
| 504 | return ret; |
| 505 | } |
| 506 | |
| 507 | /* |
| 508 | * Process a reserved item. |
| 509 | */ |
| 510 | |
| 511 | static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) |
| 512 | { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 513 | dbg_hid("reserved item type, tag 0x%x\n", item->tag); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 514 | return 0; |
| 515 | } |
| 516 | |
| 517 | /* |
| 518 | * Free a report and all registered fields. The field->usage and |
| 519 | * field->value table's are allocated behind the field, so we need |
| 520 | * only to free(field) itself. |
| 521 | */ |
| 522 | |
| 523 | static void hid_free_report(struct hid_report *report) |
| 524 | { |
| 525 | unsigned n; |
| 526 | |
| 527 | for (n = 0; n < report->maxfield; n++) |
| 528 | kfree(report->field[n]); |
| 529 | kfree(report); |
| 530 | } |
| 531 | |
| 532 | /* |
| 533 | * Free a device structure, all reports, and all fields. |
| 534 | */ |
| 535 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 536 | static void hid_device_release(struct device *dev) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 537 | { |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 538 | struct hid_device *device = container_of(dev, struct hid_device, dev); |
| 539 | unsigned i, j; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 540 | |
| 541 | for (i = 0; i < HID_REPORT_TYPES; i++) { |
| 542 | struct hid_report_enum *report_enum = device->report_enum + i; |
| 543 | |
| 544 | for (j = 0; j < 256; j++) { |
| 545 | struct hid_report *report = report_enum->report_id_hash[j]; |
| 546 | if (report) |
| 547 | hid_free_report(report); |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | kfree(device->rdesc); |
Jiri Kosina | 767fe78 | 2007-01-24 23:05:07 +0100 | [diff] [blame] | 552 | kfree(device->collection); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 553 | kfree(device); |
| 554 | } |
| 555 | |
| 556 | /* |
| 557 | * Fetch a report description item from the data stream. We support long |
| 558 | * items, though they are not used yet. |
| 559 | */ |
| 560 | |
| 561 | static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) |
| 562 | { |
| 563 | u8 b; |
| 564 | |
| 565 | if ((end - start) <= 0) |
| 566 | return NULL; |
| 567 | |
| 568 | b = *start++; |
| 569 | |
| 570 | item->type = (b >> 2) & 3; |
| 571 | item->tag = (b >> 4) & 15; |
| 572 | |
| 573 | if (item->tag == HID_ITEM_TAG_LONG) { |
| 574 | |
| 575 | item->format = HID_ITEM_FORMAT_LONG; |
| 576 | |
| 577 | if ((end - start) < 2) |
| 578 | return NULL; |
| 579 | |
| 580 | item->size = *start++; |
| 581 | item->tag = *start++; |
| 582 | |
| 583 | if ((end - start) < item->size) |
| 584 | return NULL; |
| 585 | |
| 586 | item->data.longdata = start; |
| 587 | start += item->size; |
| 588 | return start; |
| 589 | } |
| 590 | |
| 591 | item->format = HID_ITEM_FORMAT_SHORT; |
| 592 | item->size = b & 3; |
| 593 | |
| 594 | switch (item->size) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 595 | case 0: |
| 596 | return start; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 597 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 598 | case 1: |
| 599 | if ((end - start) < 1) |
| 600 | return NULL; |
| 601 | item->data.u8 = *start++; |
| 602 | return start; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 603 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 604 | case 2: |
| 605 | if ((end - start) < 2) |
| 606 | return NULL; |
| 607 | item->data.u16 = get_unaligned_le16(start); |
| 608 | start = (__u8 *)((__le16 *)start + 1); |
| 609 | return start; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 610 | |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 611 | case 3: |
| 612 | item->size++; |
| 613 | if ((end - start) < 4) |
| 614 | return NULL; |
| 615 | item->data.u32 = get_unaligned_le32(start); |
| 616 | start = (__u8 *)((__le32 *)start + 1); |
| 617 | return start; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | return NULL; |
| 621 | } |
| 622 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 623 | /** |
| 624 | * hid_parse_report - parse device report |
| 625 | * |
| 626 | * @device: hid device |
| 627 | * @start: report start |
| 628 | * @size: report size |
| 629 | * |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 630 | * Parse a report description into a hid_device structure. Reports are |
| 631 | * enumerated, fields are attached to these reports. |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 632 | * 0 returned on success, otherwise nonzero error value. |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 633 | */ |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 634 | int hid_parse_report(struct hid_device *device, __u8 *start, |
| 635 | unsigned size) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 636 | { |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 637 | struct hid_parser *parser; |
| 638 | struct hid_item item; |
| 639 | __u8 *end; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 640 | int ret; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 641 | static int (*dispatch_type[])(struct hid_parser *parser, |
| 642 | struct hid_item *item) = { |
| 643 | hid_parser_main, |
| 644 | hid_parser_global, |
| 645 | hid_parser_local, |
| 646 | hid_parser_reserved |
| 647 | }; |
| 648 | |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 649 | if (device->driver->report_fixup) |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 650 | start = device->driver->report_fixup(device, start, &size); |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 651 | |
Julia Lawall | 1721a23 | 2010-05-15 23:19:30 +0200 | [diff] [blame] | 652 | device->rdesc = kmemdup(start, size, GFP_KERNEL); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 653 | if (device->rdesc == NULL) |
| 654 | return -ENOMEM; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 655 | device->rsize = size; |
| 656 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 657 | parser = vmalloc(sizeof(struct hid_parser)); |
| 658 | if (!parser) { |
| 659 | ret = -ENOMEM; |
| 660 | goto err; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 661 | } |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 662 | |
Jiri Kosina | 47a80ed | 2007-03-12 14:55:12 +0100 | [diff] [blame] | 663 | memset(parser, 0, sizeof(struct hid_parser)); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 664 | parser->device = device; |
| 665 | |
| 666 | end = start + size; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 667 | ret = -EINVAL; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 668 | while ((start = fetch_item(start, end, &item)) != NULL) { |
| 669 | |
| 670 | if (item.format != HID_ITEM_FORMAT_SHORT) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 671 | dbg_hid("unexpected long global item\n"); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 672 | goto err; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | if (dispatch_type[item.type](parser, &item)) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 676 | dbg_hid("item %u %u %u %u parsing failed\n", |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 677 | item.format, (unsigned)item.size, |
| 678 | (unsigned)item.type, (unsigned)item.tag); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 679 | goto err; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | if (start == end) { |
| 683 | if (parser->collection_stack_ptr) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 684 | dbg_hid("unbalanced collection at end of report description\n"); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 685 | goto err; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 686 | } |
| 687 | if (parser->local.delimiter_depth) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 688 | dbg_hid("unbalanced delimiter at end of report description\n"); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 689 | goto err; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 690 | } |
Jiri Kosina | 47a80ed | 2007-03-12 14:55:12 +0100 | [diff] [blame] | 691 | vfree(parser); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 692 | return 0; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 693 | } |
| 694 | } |
| 695 | |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 696 | dbg_hid("item fetching failed at offset %d\n", (int)(end - start)); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 697 | err: |
Jiri Kosina | 47a80ed | 2007-03-12 14:55:12 +0100 | [diff] [blame] | 698 | vfree(parser); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 699 | return ret; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 700 | } |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 701 | EXPORT_SYMBOL_GPL(hid_parse_report); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 702 | |
| 703 | /* |
| 704 | * Convert a signed n-bit integer to signed 32-bit integer. Common |
| 705 | * cases are done through the compiler, the screwed things has to be |
| 706 | * done by hand. |
| 707 | */ |
| 708 | |
| 709 | static s32 snto32(__u32 value, unsigned n) |
| 710 | { |
| 711 | switch (n) { |
Jiri Slaby | 880d29f | 2008-06-18 23:55:41 +0200 | [diff] [blame] | 712 | case 8: return ((__s8)value); |
| 713 | case 16: return ((__s16)value); |
| 714 | case 32: return ((__s32)value); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 715 | } |
| 716 | return value & (1 << (n - 1)) ? value | (-1 << n) : value; |
| 717 | } |
| 718 | |
| 719 | /* |
| 720 | * Convert a signed 32-bit integer to a signed n-bit integer. |
| 721 | */ |
| 722 | |
| 723 | static u32 s32ton(__s32 value, unsigned n) |
| 724 | { |
| 725 | s32 a = value >> (n - 1); |
| 726 | if (a && a != -1) |
| 727 | return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; |
| 728 | return value & ((1 << n) - 1); |
| 729 | } |
| 730 | |
| 731 | /* |
| 732 | * Extract/implement a data field from/to a little endian report (bit array). |
| 733 | * |
| 734 | * Code sort-of follows HID spec: |
| 735 | * http://www.usb.org/developers/devclass_docs/HID1_11.pdf |
| 736 | * |
| 737 | * While the USB HID spec allows unlimited length bit fields in "report |
| 738 | * descriptors", most devices never use more than 16 bits. |
| 739 | * One model of UPS is claimed to report "LINEV" as a 32-bit field. |
| 740 | * Search linux-kernel and linux-usb-devel archives for "hid-core extract". |
| 741 | */ |
| 742 | |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 743 | static __inline__ __u32 extract(const struct hid_device *hid, __u8 *report, |
| 744 | unsigned offset, unsigned n) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 745 | { |
| 746 | u64 x; |
| 747 | |
Jiri Kosina | c4124c9 | 2007-11-30 11:12:58 +0100 | [diff] [blame] | 748 | if (n > 32) |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 749 | hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n", |
| 750 | n, current->comm); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 751 | |
| 752 | report += offset >> 3; /* adjust byte index */ |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 753 | offset &= 7; /* now only need bit offset into one byte */ |
Harvey Harrison | c105068 | 2008-04-29 01:03:31 -0700 | [diff] [blame] | 754 | x = get_unaligned_le64(report); |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 755 | x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 756 | return (u32) x; |
| 757 | } |
| 758 | |
| 759 | /* |
| 760 | * "implement" : set bits in a little endian bit stream. |
| 761 | * Same concepts as "extract" (see comments above). |
| 762 | * The data mangled in the bit stream remains in little endian |
| 763 | * order the whole time. It make more sense to talk about |
| 764 | * endianness of register values by considering a register |
| 765 | * a "cached" copy of the little endiad bit stream. |
| 766 | */ |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 767 | static __inline__ void implement(const struct hid_device *hid, __u8 *report, |
| 768 | unsigned offset, unsigned n, __u32 value) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 769 | { |
Harvey Harrison | 6f0168d | 2008-05-16 11:00:23 +0200 | [diff] [blame] | 770 | u64 x; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 771 | u64 m = (1ULL << n) - 1; |
| 772 | |
Jiri Kosina | c4124c9 | 2007-11-30 11:12:58 +0100 | [diff] [blame] | 773 | if (n > 32) |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 774 | hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n", |
| 775 | __func__, n, current->comm); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 776 | |
Jiri Kosina | c4124c9 | 2007-11-30 11:12:58 +0100 | [diff] [blame] | 777 | if (value > m) |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 778 | hid_warn(hid, "%s() called with too large value %d! (%s)\n", |
| 779 | __func__, value, current->comm); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 780 | WARN_ON(value > m); |
| 781 | value &= m; |
| 782 | |
| 783 | report += offset >> 3; |
| 784 | offset &= 7; |
| 785 | |
Harvey Harrison | 6f0168d | 2008-05-16 11:00:23 +0200 | [diff] [blame] | 786 | x = get_unaligned_le64(report); |
| 787 | x &= ~(m << offset); |
| 788 | x |= ((u64)value) << offset; |
| 789 | put_unaligned_le64(x, report); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | /* |
| 793 | * Search an array for a value. |
| 794 | */ |
| 795 | |
| 796 | static __inline__ int search(__s32 *array, __s32 value, unsigned n) |
| 797 | { |
| 798 | while (n--) { |
| 799 | if (*array++ == value) |
| 800 | return 0; |
| 801 | } |
| 802 | return -1; |
| 803 | } |
| 804 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 805 | /** |
| 806 | * hid_match_report - check if driver's raw_event should be called |
| 807 | * |
| 808 | * @hid: hid device |
| 809 | * @report_type: type to match against |
| 810 | * |
| 811 | * compare hid->driver->report_table->report_type to report->type |
| 812 | */ |
| 813 | static int hid_match_report(struct hid_device *hid, struct hid_report *report) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 814 | { |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 815 | const struct hid_report_id *id = hid->driver->report_table; |
| 816 | |
| 817 | if (!id) /* NULL means all */ |
| 818 | return 1; |
| 819 | |
| 820 | for (; id->report_type != HID_TERMINATOR; id++) |
| 821 | if (id->report_type == HID_ANY_ID || |
| 822 | id->report_type == report->type) |
| 823 | return 1; |
| 824 | return 0; |
| 825 | } |
| 826 | |
| 827 | /** |
| 828 | * hid_match_usage - check if driver's event should be called |
| 829 | * |
| 830 | * @hid: hid device |
| 831 | * @usage: usage to match against |
| 832 | * |
| 833 | * compare hid->driver->usage_table->usage_{type,code} to |
| 834 | * usage->usage_{type,code} |
| 835 | */ |
| 836 | static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage) |
| 837 | { |
| 838 | const struct hid_usage_id *id = hid->driver->usage_table; |
| 839 | |
| 840 | if (!id) /* NULL means all */ |
| 841 | return 1; |
| 842 | |
| 843 | for (; id->usage_type != HID_ANY_ID - 1; id++) |
| 844 | if ((id->usage_hid == HID_ANY_ID || |
| 845 | id->usage_hid == usage->hid) && |
| 846 | (id->usage_type == HID_ANY_ID || |
| 847 | id->usage_type == usage->type) && |
| 848 | (id->usage_code == HID_ANY_ID || |
| 849 | id->usage_code == usage->code)) |
| 850 | return 1; |
| 851 | return 0; |
| 852 | } |
| 853 | |
| 854 | static void hid_process_event(struct hid_device *hid, struct hid_field *field, |
| 855 | struct hid_usage *usage, __s32 value, int interrupt) |
| 856 | { |
| 857 | struct hid_driver *hdrv = hid->driver; |
| 858 | int ret; |
| 859 | |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 860 | hid_dump_input(hid, usage, value); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 861 | |
| 862 | if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { |
| 863 | ret = hdrv->event(hid, field, usage, value); |
| 864 | if (ret != 0) { |
| 865 | if (ret < 0) |
| 866 | dbg_hid("%s's event failed with %d\n", |
| 867 | hdrv->name, ret); |
| 868 | return; |
| 869 | } |
| 870 | } |
| 871 | |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 872 | if (hid->claimed & HID_CLAIMED_INPUT) |
| 873 | hidinput_hid_event(hid, field, usage, value); |
Jiri Kosina | aa938f7 | 2006-12-08 18:41:10 +0100 | [diff] [blame] | 874 | if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) |
| 875 | hid->hiddev_hid_event(hid, field, usage, value); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | /* |
| 879 | * Analyse a received field, and fetch the data from it. The field |
| 880 | * content is stored for next report processing (we do differential |
| 881 | * reporting to the layer). |
| 882 | */ |
| 883 | |
Adrian Bunk | abdff0f | 2008-03-31 01:53:56 +0200 | [diff] [blame] | 884 | static void hid_input_field(struct hid_device *hid, struct hid_field *field, |
| 885 | __u8 *data, int interrupt) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 886 | { |
| 887 | unsigned n; |
| 888 | unsigned count = field->report_count; |
| 889 | unsigned offset = field->report_offset; |
| 890 | unsigned size = field->report_size; |
| 891 | __s32 min = field->logical_minimum; |
| 892 | __s32 max = field->logical_maximum; |
| 893 | __s32 *value; |
| 894 | |
| 895 | if (!(value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC))) |
| 896 | return; |
| 897 | |
| 898 | for (n = 0; n < count; n++) { |
| 899 | |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 900 | value[n] = min < 0 ? |
| 901 | snto32(extract(hid, data, offset + n * size, size), |
| 902 | size) : |
| 903 | extract(hid, data, offset + n * size, size); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 904 | |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 905 | /* Ignore report if ErrorRollOver */ |
| 906 | if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && |
| 907 | value[n] >= min && value[n] <= max && |
| 908 | field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) |
| 909 | goto exit; |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | for (n = 0; n < count; n++) { |
| 913 | |
| 914 | if (HID_MAIN_ITEM_VARIABLE & field->flags) { |
| 915 | hid_process_event(hid, field, &field->usage[n], value[n], interrupt); |
| 916 | continue; |
| 917 | } |
| 918 | |
| 919 | if (field->value[n] >= min && field->value[n] <= max |
| 920 | && field->usage[field->value[n] - min].hid |
| 921 | && search(value, field->value[n], count)) |
| 922 | hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); |
| 923 | |
| 924 | if (value[n] >= min && value[n] <= max |
| 925 | && field->usage[value[n] - min].hid |
| 926 | && search(field->value, value[n], count)) |
| 927 | hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); |
| 928 | } |
| 929 | |
| 930 | memcpy(field->value, value, count * sizeof(__s32)); |
| 931 | exit: |
| 932 | kfree(value); |
| 933 | } |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 934 | |
| 935 | /* |
| 936 | * Output the field into the report. |
| 937 | */ |
| 938 | |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 939 | static void hid_output_field(const struct hid_device *hid, |
| 940 | struct hid_field *field, __u8 *data) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 941 | { |
| 942 | unsigned count = field->report_count; |
| 943 | unsigned offset = field->report_offset; |
| 944 | unsigned size = field->report_size; |
| 945 | unsigned n; |
| 946 | |
| 947 | for (n = 0; n < count; n++) { |
| 948 | if (field->logical_minimum < 0) /* signed values */ |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 949 | implement(hid, data, offset + n * size, size, |
| 950 | s32ton(field->value[n], size)); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 951 | else /* unsigned values */ |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 952 | implement(hid, data, offset + n * size, size, |
| 953 | field->value[n]); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 954 | } |
| 955 | } |
| 956 | |
| 957 | /* |
| 958 | * Create a report. |
| 959 | */ |
| 960 | |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 961 | void hid_output_report(struct hid_report *report, __u8 *data) |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 962 | { |
| 963 | unsigned n; |
| 964 | |
| 965 | if (report->id > 0) |
| 966 | *data++ = report->id; |
| 967 | |
Pete Zaitcev | 75c28df | 2010-04-12 12:16:11 -0600 | [diff] [blame] | 968 | memset(data, 0, ((report->size - 1) >> 3) + 1); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 969 | for (n = 0; n < report->maxfield; n++) |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 970 | hid_output_field(report->device, report->field[n], data); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 971 | } |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 972 | EXPORT_SYMBOL_GPL(hid_output_report); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 973 | |
| 974 | /* |
| 975 | * Set a field value. The report this field belongs to has to be |
| 976 | * created and transferred to the device, to set this value in the |
| 977 | * device. |
| 978 | */ |
| 979 | |
| 980 | int hid_set_field(struct hid_field *field, unsigned offset, __s32 value) |
| 981 | { |
| 982 | unsigned size = field->report_size; |
| 983 | |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 984 | hid_dump_input(field->report->device, field->usage + offset, value); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 985 | |
| 986 | if (offset >= field->report_count) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 987 | dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 988 | return -1; |
| 989 | } |
| 990 | if (field->logical_minimum < 0) { |
| 991 | if (value != snto32(s32ton(value, size), size)) { |
Jiri Kosina | 58037eb | 2007-05-30 15:07:13 +0200 | [diff] [blame] | 992 | dbg_hid("value %d is out of range\n", value); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 993 | return -1; |
| 994 | } |
| 995 | } |
| 996 | field->value[offset] = value; |
| 997 | return 0; |
| 998 | } |
Jiri Kosina | 229695e | 2006-12-08 18:40:53 +0100 | [diff] [blame] | 999 | EXPORT_SYMBOL_GPL(hid_set_field); |
Jiri Kosina | dde5845 | 2006-12-08 18:40:44 +0100 | [diff] [blame] | 1000 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1001 | static struct hid_report *hid_get_report(struct hid_report_enum *report_enum, |
| 1002 | const u8 *data) |
| 1003 | { |
| 1004 | struct hid_report *report; |
| 1005 | unsigned int n = 0; /* Normally report number is 0 */ |
| 1006 | |
| 1007 | /* Device uses numbered reports, data[0] is report number */ |
| 1008 | if (report_enum->numbered) |
| 1009 | n = *data; |
| 1010 | |
| 1011 | report = report_enum->report_id_hash[n]; |
| 1012 | if (report == NULL) |
| 1013 | dbg_hid("undefined report_id %u received\n", n); |
| 1014 | |
| 1015 | return report; |
| 1016 | } |
| 1017 | |
| 1018 | void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, |
| 1019 | int interrupt) |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1020 | { |
| 1021 | struct hid_report_enum *report_enum = hid->report_enum + type; |
| 1022 | struct hid_report *report; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1023 | unsigned int a; |
| 1024 | int rsize, csize = size; |
| 1025 | u8 *cdata = data; |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1026 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1027 | report = hid_get_report(report_enum, data); |
| 1028 | if (!report) |
| 1029 | return; |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1030 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1031 | if (report_enum->numbered) { |
| 1032 | cdata++; |
| 1033 | csize--; |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1034 | } |
| 1035 | |
| 1036 | rsize = ((report->size - 1) >> 3) + 1; |
| 1037 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1038 | if (csize < rsize) { |
| 1039 | dbg_hid("report %d is too short, (%d < %d)\n", report->id, |
| 1040 | csize, rsize); |
| 1041 | memset(cdata + csize, 0, rsize - csize); |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1042 | } |
| 1043 | |
| 1044 | if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) |
| 1045 | hid->hiddev_report_event(hid, report); |
Alan Ott | 5a38f2c | 2010-04-26 18:34:46 -0400 | [diff] [blame] | 1046 | if (hid->claimed & HID_CLAIMED_HIDRAW) |
| 1047 | hidraw_report_event(hid, data, size); |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1048 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1049 | for (a = 0; a < report->maxfield; a++) |
| 1050 | hid_input_field(hid, report->field[a], cdata, interrupt); |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1051 | |
| 1052 | if (hid->claimed & HID_CLAIMED_INPUT) |
| 1053 | hidinput_report_event(hid, report); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1054 | } |
| 1055 | EXPORT_SYMBOL_GPL(hid_report_raw_event); |
| 1056 | |
| 1057 | /** |
| 1058 | * hid_input_report - report data from lower layer (usb, bt...) |
| 1059 | * |
| 1060 | * @hid: hid device |
| 1061 | * @type: HID report type (HID_*_REPORT) |
| 1062 | * @data: report contents |
| 1063 | * @size: size of data parameter |
Jiri Kosina | ff9b00a | 2009-10-01 16:03:13 +0200 | [diff] [blame] | 1064 | * @interrupt: distinguish between interrupt and control transfers |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1065 | * |
| 1066 | * This is data entry for lower layers. |
| 1067 | */ |
| 1068 | int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) |
| 1069 | { |
Julia Lawall | 76c317d | 2009-07-19 17:26:13 +0200 | [diff] [blame] | 1070 | struct hid_report_enum *report_enum; |
| 1071 | struct hid_driver *hdrv; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1072 | struct hid_report *report; |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1073 | char *buf; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1074 | unsigned int i; |
| 1075 | int ret; |
| 1076 | |
| 1077 | if (!hid || !hid->driver) |
| 1078 | return -ENODEV; |
Julia Lawall | 76c317d | 2009-07-19 17:26:13 +0200 | [diff] [blame] | 1079 | report_enum = hid->report_enum + type; |
| 1080 | hdrv = hid->driver; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1081 | |
| 1082 | if (!size) { |
| 1083 | dbg_hid("empty report\n"); |
| 1084 | return -1; |
| 1085 | } |
| 1086 | |
Jiri Kosina | d1ff652 | 2009-09-15 11:59:49 +0200 | [diff] [blame] | 1087 | buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC); |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1088 | |
Jiri Kosina | f77e347 | 2010-03-18 14:11:53 +0100 | [diff] [blame] | 1089 | if (!buf) |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1090 | goto nomem; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1091 | |
| 1092 | /* dump the report */ |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1093 | snprintf(buf, HID_DEBUG_BUFSIZE - 1, |
Jiri Kosina | 1caea61 | 2010-03-18 12:09:53 +0100 | [diff] [blame] | 1094 | "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un"); |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1095 | hid_debug_event(hid, buf); |
Jiri Kosina | 1caea61 | 2010-03-18 12:09:53 +0100 | [diff] [blame] | 1096 | |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1097 | for (i = 0; i < size; i++) { |
| 1098 | snprintf(buf, HID_DEBUG_BUFSIZE - 1, |
| 1099 | " %02x", data[i]); |
| 1100 | hid_debug_event(hid, buf); |
| 1101 | } |
| 1102 | hid_debug_event(hid, "\n"); |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1103 | kfree(buf); |
| 1104 | |
| 1105 | nomem: |
Jiri Kosina | f77e347 | 2010-03-18 14:11:53 +0100 | [diff] [blame] | 1106 | report = hid_get_report(report_enum, data); |
| 1107 | |
| 1108 | if (!report) |
| 1109 | return -1; |
| 1110 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1111 | if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { |
| 1112 | ret = hdrv->raw_event(hid, report, data, size); |
| 1113 | if (ret != 0) |
| 1114 | return ret < 0 ? ret : 0; |
| 1115 | } |
| 1116 | |
| 1117 | hid_report_raw_event(hid, type, data, size, interrupt); |
Jiri Kosina | aa8de2f | 2006-12-08 18:41:17 +0100 | [diff] [blame] | 1118 | |
| 1119 | return 0; |
| 1120 | } |
| 1121 | EXPORT_SYMBOL_GPL(hid_input_report); |
| 1122 | |
Jiri Kosina | 0f37cd0 | 2008-08-20 19:13:52 +0200 | [diff] [blame] | 1123 | static bool hid_match_one_id(struct hid_device *hdev, |
| 1124 | const struct hid_device_id *id) |
| 1125 | { |
| 1126 | return id->bus == hdev->bus && |
| 1127 | (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && |
| 1128 | (id->product == HID_ANY_ID || id->product == hdev->product); |
| 1129 | } |
| 1130 | |
| 1131 | static const struct hid_device_id *hid_match_id(struct hid_device *hdev, |
| 1132 | const struct hid_device_id *id) |
| 1133 | { |
| 1134 | for (; id->bus; id++) |
| 1135 | if (hid_match_one_id(hdev, id)) |
| 1136 | return id; |
| 1137 | |
| 1138 | return NULL; |
| 1139 | } |
| 1140 | |
| 1141 | static const struct hid_device_id hid_hiddev_list[] = { |
Richard Hughes | c0bd6a4 | 2008-08-27 11:19:37 +0200 | [diff] [blame] | 1142 | { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, |
| 1143 | { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, |
Jiri Kosina | 0f37cd0 | 2008-08-20 19:13:52 +0200 | [diff] [blame] | 1144 | { } |
| 1145 | }; |
| 1146 | |
| 1147 | static bool hid_hiddev(struct hid_device *hdev) |
| 1148 | { |
| 1149 | return !!hid_match_id(hdev, hid_hiddev_list); |
| 1150 | } |
| 1151 | |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1152 | int hid_connect(struct hid_device *hdev, unsigned int connect_mask) |
| 1153 | { |
| 1154 | static const char *types[] = { "Device", "Pointer", "Mouse", "Device", |
| 1155 | "Joystick", "Gamepad", "Keyboard", "Keypad", |
| 1156 | "Multi-Axis Controller" |
| 1157 | }; |
| 1158 | const char *type, *bus; |
| 1159 | char buf[64]; |
| 1160 | unsigned int i; |
| 1161 | int len; |
| 1162 | |
Bastien Nocera | b5e5a37 | 2010-04-16 17:19:50 +0100 | [diff] [blame] | 1163 | if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) |
| 1164 | connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV); |
Daniel Mack | 3a343ee | 2010-07-12 19:28:27 +0200 | [diff] [blame] | 1165 | if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE) |
| 1166 | connect_mask |= HID_CONNECT_HIDINPUT_FORCE; |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1167 | if (hdev->bus != BUS_USB) |
| 1168 | connect_mask &= ~HID_CONNECT_HIDDEV; |
Jiri Kosina | 0f37cd0 | 2008-08-20 19:13:52 +0200 | [diff] [blame] | 1169 | if (hid_hiddev(hdev)) |
| 1170 | connect_mask |= HID_CONNECT_HIDDEV_FORCE; |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1171 | |
| 1172 | if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev, |
| 1173 | connect_mask & HID_CONNECT_HIDINPUT_FORCE)) |
| 1174 | hdev->claimed |= HID_CLAIMED_INPUT; |
| 1175 | if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect && |
| 1176 | !hdev->hiddev_connect(hdev, |
| 1177 | connect_mask & HID_CONNECT_HIDDEV_FORCE)) |
| 1178 | hdev->claimed |= HID_CLAIMED_HIDDEV; |
| 1179 | if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev)) |
| 1180 | hdev->claimed |= HID_CLAIMED_HIDRAW; |
| 1181 | |
| 1182 | if (!hdev->claimed) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 1183 | hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n"); |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1184 | return -ENODEV; |
| 1185 | } |
| 1186 | |
| 1187 | if ((hdev->claimed & HID_CLAIMED_INPUT) && |
| 1188 | (connect_mask & HID_CONNECT_FF) && hdev->ff_init) |
| 1189 | hdev->ff_init(hdev); |
| 1190 | |
| 1191 | len = 0; |
| 1192 | if (hdev->claimed & HID_CLAIMED_INPUT) |
| 1193 | len += sprintf(buf + len, "input"); |
| 1194 | if (hdev->claimed & HID_CLAIMED_HIDDEV) |
| 1195 | len += sprintf(buf + len, "%shiddev%d", len ? "," : "", |
| 1196 | hdev->minor); |
| 1197 | if (hdev->claimed & HID_CLAIMED_HIDRAW) |
| 1198 | len += sprintf(buf + len, "%shidraw%d", len ? "," : "", |
| 1199 | ((struct hidraw *)hdev->hidraw)->minor); |
| 1200 | |
| 1201 | type = "Device"; |
| 1202 | for (i = 0; i < hdev->maxcollection; i++) { |
| 1203 | struct hid_collection *col = &hdev->collection[i]; |
| 1204 | if (col->type == HID_COLLECTION_APPLICATION && |
| 1205 | (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK && |
| 1206 | (col->usage & 0xffff) < ARRAY_SIZE(types)) { |
| 1207 | type = types[col->usage & 0xffff]; |
| 1208 | break; |
| 1209 | } |
| 1210 | } |
| 1211 | |
| 1212 | switch (hdev->bus) { |
| 1213 | case BUS_USB: |
| 1214 | bus = "USB"; |
| 1215 | break; |
| 1216 | case BUS_BLUETOOTH: |
| 1217 | bus = "BLUETOOTH"; |
| 1218 | break; |
| 1219 | default: |
| 1220 | bus = "<UNKNOWN>"; |
| 1221 | } |
| 1222 | |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 1223 | hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", |
| 1224 | buf, bus, hdev->version >> 8, hdev->version & 0xff, |
| 1225 | type, hdev->name, hdev->phys); |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1226 | |
| 1227 | return 0; |
| 1228 | } |
| 1229 | EXPORT_SYMBOL_GPL(hid_connect); |
| 1230 | |
Jiri Kosina | c4c259b | 2009-09-15 16:27:45 +0200 | [diff] [blame] | 1231 | void hid_disconnect(struct hid_device *hdev) |
| 1232 | { |
| 1233 | if (hdev->claimed & HID_CLAIMED_INPUT) |
| 1234 | hidinput_disconnect(hdev); |
| 1235 | if (hdev->claimed & HID_CLAIMED_HIDDEV) |
| 1236 | hdev->hiddev_disconnect(hdev); |
| 1237 | if (hdev->claimed & HID_CLAIMED_HIDRAW) |
| 1238 | hidraw_disconnect(hdev); |
| 1239 | } |
| 1240 | EXPORT_SYMBOL_GPL(hid_disconnect); |
| 1241 | |
Jiri Kosina | bae7eb3 | 2009-01-28 23:06:37 +0100 | [diff] [blame] | 1242 | /* a list of devices for which there is a specialized driver on HID bus */ |
Dmitry Torokhov | ce06b9d | 2010-11-28 16:37:14 +0100 | [diff] [blame] | 1243 | static const struct hid_device_id hid_have_special_driver[] = { |
Stephane Chatty | b6353f4 | 2009-12-22 23:04:17 +0100 | [diff] [blame] | 1244 | { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, |
Stephane Chatty | 6dec143 | 2010-04-11 14:51:24 +0200 | [diff] [blame] | 1245 | { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, |
Jiri Slaby | 14a21cd | 2008-06-23 23:31:09 +0200 | [diff] [blame] | 1246 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, |
| 1247 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, |
Lech Perczak | b7e1b20 | 2010-09-16 23:19:33 +0200 | [diff] [blame] | 1248 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, |
Sergei Kolzun | c0dbcc3 | 2010-07-19 12:13:23 +0200 | [diff] [blame] | 1249 | #if defined(CONFIG_HID_ACRUX_FF) || defined(CONFIG_HID_ACRUX_FF_MODULE) |
| 1250 | { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) }, |
| 1251 | #endif |
Jiri Kosina | df9bcac | 2008-10-14 22:45:40 +0200 | [diff] [blame] | 1252 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1253 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, |
| 1254 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, |
Michael Poole | 128537c | 2010-02-06 12:24:36 -0500 | [diff] [blame] | 1255 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) }, |
Chase Douglas | a462230 | 2010-08-31 21:56:23 -0400 | [diff] [blame] | 1256 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1257 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, |
| 1258 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, |
| 1259 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, |
| 1260 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, |
| 1261 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, |
| 1262 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, |
| 1263 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, |
| 1264 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, |
| 1265 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, |
| 1266 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, |
| 1267 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, |
Ryan Finnie | fef3f57 | 2009-03-05 10:18:01 +0100 | [diff] [blame] | 1268 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI) }, |
| 1269 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO) }, |
| 1270 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1271 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) }, |
| 1272 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) }, |
| 1273 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) }, |
| 1274 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, |
| 1275 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, |
| 1276 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, |
Jan Scholz | ee8a1a0 | 2008-11-26 15:33:45 +0100 | [diff] [blame] | 1277 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, |
| 1278 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, |
| 1279 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1280 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, |
| 1281 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, |
| 1282 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, |
| 1283 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, |
| 1284 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, |
| 1285 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, |
Henrik Rydberg | a96d6ef | 2008-11-04 20:03:45 +0100 | [diff] [blame] | 1286 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, |
| 1287 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, |
| 1288 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, |
Edgar (gimli) Hucek | 99b9f75 | 2010-11-03 10:36:18 -0400 | [diff] [blame] | 1289 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, |
| 1290 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, |
| 1291 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, |
| 1292 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, |
| 1293 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, |
| 1294 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, |
Christian Schuerer-Waldheim | 23aeb61 | 2010-01-06 14:49:57 +0100 | [diff] [blame] | 1295 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, |
| 1296 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, |
| 1297 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1298 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
| 1299 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
Jiri Kosina | eaca138 | 2010-09-08 14:31:47 +0200 | [diff] [blame] | 1300 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) }, |
Roland Baum | cec15a0 | 2010-09-08 14:27:55 +0200 | [diff] [blame] | 1301 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, |
Jiri Slaby | b5635b1 | 2008-06-24 23:24:57 +0200 | [diff] [blame] | 1302 | { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, |
Wayne Thomas | bf28062 | 2010-04-29 00:45:01 +0200 | [diff] [blame] | 1303 | { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, |
Jiri Kosina | c3dc66d | 2010-08-30 15:43:25 +0200 | [diff] [blame] | 1304 | { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, |
Stephane Chatty | 36213e1 | 2010-04-15 00:28:11 +0200 | [diff] [blame] | 1305 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, |
Stephane Chatty | ba4d8ab | 2010-04-22 23:24:36 +0200 | [diff] [blame] | 1306 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, |
François Jaouen | 272036e | 2010-10-13 10:47:32 +0200 | [diff] [blame] | 1307 | { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, |
Jiri Slaby | 3b239cd | 2008-06-24 20:42:25 +0200 | [diff] [blame] | 1308 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, |
Raphaël Doursenaud | 1ce31b2 | 2010-04-08 13:40:52 +0200 | [diff] [blame] | 1309 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, |
Jiri Slaby | fcfacfd | 2008-06-24 22:48:52 +0200 | [diff] [blame] | 1310 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, |
Dennis Kügler | b9e4b1e | 2010-11-23 21:40:09 +0100 | [diff] [blame] | 1311 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, |
Don Prince | 3a370ca | 2010-05-12 15:18:59 +0200 | [diff] [blame] | 1312 | { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, |
Jiri Slaby | 0f22132 | 2008-06-23 22:54:08 +0200 | [diff] [blame] | 1313 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, |
| 1314 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, |
Jiri Kosina | e8d0eab | 2009-12-02 22:54:11 +0100 | [diff] [blame] | 1315 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) }, |
Jiri Slaby | 0f22132 | 2008-06-23 22:54:08 +0200 | [diff] [blame] | 1316 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, |
Richard Walmsley | 3f866fb | 2009-03-04 22:12:04 +1300 | [diff] [blame] | 1317 | { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, |
Stephane Chatty | 0c3910c | 2010-04-10 16:43:08 +0200 | [diff] [blame] | 1318 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) }, |
Chris Ball | 83e4491 | 2010-08-16 16:01:28 +0200 | [diff] [blame] | 1319 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) }, |
Richard Nauber | 64b386e | 2010-06-28 18:54:25 +0200 | [diff] [blame] | 1320 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, |
Ignaz Forster | 04561c5 | 2010-11-01 15:13:37 -0400 | [diff] [blame] | 1321 | { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) }, |
Jiri Slaby | 1f243e3 | 2008-06-24 21:11:21 +0200 | [diff] [blame] | 1322 | { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, |
Jiri Kosina | 5181e59 | 2008-11-17 01:44:38 +0100 | [diff] [blame] | 1323 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, |
Jiri Kosina | 578f3a3 | 2008-11-20 15:55:38 +0100 | [diff] [blame] | 1324 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, |
Jiri Kosina | 5181e59 | 2008-11-17 01:44:38 +0100 | [diff] [blame] | 1325 | { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, |
Lukasz Lubojanski | 42859e0 | 2008-12-11 22:07:59 +0100 | [diff] [blame] | 1326 | { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) }, |
Jiri Slaby | 949f8fe | 2008-07-24 23:35:13 +0200 | [diff] [blame] | 1327 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, |
Jiri Kosina | 1e09320 | 2008-10-17 11:52:23 +0200 | [diff] [blame] | 1328 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, |
Cory Maccarrone | c2fd1a4 | 2010-05-22 13:00:28 -0700 | [diff] [blame] | 1329 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, |
Jiri Kosina | fdf93aa | 2009-03-04 16:09:40 +0100 | [diff] [blame] | 1330 | { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, |
Jiri Kosina | 7942274 | 2009-03-11 11:43:27 +0100 | [diff] [blame] | 1331 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, |
Jiri Slaby | b5635b1 | 2008-06-24 23:24:57 +0200 | [diff] [blame] | 1332 | { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, |
Jiri Slaby | 5f22a79 | 2008-05-16 11:49:19 +0200 | [diff] [blame] | 1333 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, |
| 1334 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, |
| 1335 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, |
| 1336 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, |
| 1337 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, |
| 1338 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, |
| 1339 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, |
Jiri Slaby | 5f22a79 | 2008-05-16 11:49:19 +0200 | [diff] [blame] | 1340 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, |
| 1341 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, |
Jiri Slaby | 5f22a79 | 2008-05-16 11:49:19 +0200 | [diff] [blame] | 1342 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, |
| 1343 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) }, |
Hendrik Iben | 2c6118e | 2010-10-04 15:39:49 +0200 | [diff] [blame] | 1344 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) }, |
Jiri Slaby | 606bd0a | 2008-07-04 23:06:45 +0200 | [diff] [blame] | 1345 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) }, |
| 1346 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) }, |
| 1347 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, |
Jiri Kosina | fd30ea8 | 2009-06-23 12:11:31 +0200 | [diff] [blame] | 1348 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) }, |
Jiri Slaby | 606bd0a | 2008-07-04 23:06:45 +0200 | [diff] [blame] | 1349 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, |
Gary Stein | 74f292c | 2010-01-13 00:25:58 +0100 | [diff] [blame] | 1350 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) }, |
Jiri Slaby | 606bd0a | 2008-07-04 23:06:45 +0200 | [diff] [blame] | 1351 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) }, |
| 1352 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) }, |
Christophe Borivant | 243b706 | 2009-04-17 11:39:39 +0200 | [diff] [blame] | 1353 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) }, |
Simon Wood | 32c88cb | 2010-09-22 13:19:42 +0200 | [diff] [blame] | 1354 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) }, |
Jiri Slaby | 606bd0a | 2008-07-04 23:06:45 +0200 | [diff] [blame] | 1355 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, |
Jiri Kosina | 24985cf | 2009-11-13 10:45:53 +0100 | [diff] [blame] | 1356 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) }, |
| 1357 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) }, |
Bruno Prémont | 236db47 | 2010-03-30 22:33:50 +0200 | [diff] [blame] | 1358 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, |
| 1359 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) }, |
Jiri Slaby | 78a849a | 2008-06-20 21:26:11 +0200 | [diff] [blame] | 1360 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, |
| 1361 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, |
| 1362 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, |
| 1363 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, |
| 1364 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, |
Jiri Slaby | 3b8006e | 2008-06-25 00:07:50 +0200 | [diff] [blame] | 1365 | { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, |
Rafi Rubin | 94011f9 | 2008-11-19 15:54:46 +0100 | [diff] [blame] | 1366 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, |
micki | 6e32819 | 2010-06-19 11:37:29 +0300 | [diff] [blame] | 1367 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) }, |
| 1368 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) }, |
| 1369 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) }, |
| 1370 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) }, |
| 1371 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) }, |
| 1372 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) }, |
| 1373 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) }, |
| 1374 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) }, |
| 1375 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) }, |
| 1376 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) }, |
| 1377 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) }, |
| 1378 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) }, |
| 1379 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) }, |
| 1380 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) }, |
| 1381 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) }, |
| 1382 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) }, |
| 1383 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) }, |
| 1384 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) }, |
Johnathon Harris | cd9ec30 | 2010-01-21 14:36:52 +0000 | [diff] [blame] | 1385 | { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, |
Jiri Slaby | 1e76253 | 2008-06-24 23:46:21 +0200 | [diff] [blame] | 1386 | { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, |
Stephane Chatty | 49e4739 | 2010-01-13 00:29:16 +0100 | [diff] [blame] | 1387 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, |
Alex Neblett | f54405d | 2010-02-02 21:16:03 -0800 | [diff] [blame] | 1388 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, |
Stefan Achatz | 14bf62c | 2010-03-18 16:19:43 +0100 | [diff] [blame] | 1389 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, |
Stefan Achatz | cb7cf3d | 2010-08-29 12:30:18 +0200 | [diff] [blame] | 1390 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, |
Jiri Slaby | 980a3da | 2008-06-25 22:31:48 +0200 | [diff] [blame] | 1391 | { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, |
Don Prince | b355850 | 2010-05-17 11:42:39 +0100 | [diff] [blame] | 1392 | { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, |
Jiri Slaby | bd28ce0 | 2008-06-25 23:47:04 +0200 | [diff] [blame] | 1393 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, |
Bastien Nocera | f9ce7c2 | 2010-01-20 12:01:53 +0000 | [diff] [blame] | 1394 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, |
Jiri Kosina | cc6e0bb | 2008-10-23 12:58:38 +0200 | [diff] [blame] | 1395 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, |
Stephane Chatty | d3fb545 | 2010-01-04 12:04:08 +0100 | [diff] [blame] | 1396 | { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) }, |
Pascal Auriel - Stantum | b6dc799 | 2010-10-01 16:01:28 +0200 | [diff] [blame] | 1397 | { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) }, |
| 1398 | { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) }, |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 1399 | { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, |
Anssi Hannula | daedb3d | 2009-02-14 11:45:05 +0200 | [diff] [blame] | 1400 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, |
| 1401 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, |
Ruben Aos Garralda | 7a84b13 | 2009-06-29 09:41:29 +0200 | [diff] [blame] | 1402 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, |
| 1403 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) }, |
Anssi Hannula | daedb3d | 2009-02-14 11:45:05 +0200 | [diff] [blame] | 1404 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, |
Markus Rathgeb | 3ee8f0a | 2010-03-13 17:29:43 +0100 | [diff] [blame] | 1405 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) }, |
Anssi Hannula | daedb3d | 2009-02-14 11:45:05 +0200 | [diff] [blame] | 1406 | { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, |
Lev Babiev | f14f526 | 2009-01-04 00:36:56 +0100 | [diff] [blame] | 1407 | { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, |
Kees Bakker | 5400108 | 2010-07-13 22:50:51 +0200 | [diff] [blame] | 1408 | { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) }, |
Bruno Premont | 711a680 | 2009-07-13 14:19:58 +0200 | [diff] [blame] | 1409 | { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, |
Nikolai Kondrashov | 41fa923 | 2010-08-23 15:09:01 +0400 | [diff] [blame] | 1410 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, |
Nikolai Kondrashov | f8a489c | 2010-08-09 20:44:17 +0400 | [diff] [blame] | 1411 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) }, |
| 1412 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) }, |
| 1413 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) }, |
Jussi Kivilinna | fac733f | 2009-05-13 11:54:38 +0300 | [diff] [blame] | 1414 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, |
Bastien Nocera | ca2dcd4 | 2009-05-11 17:18:12 +0200 | [diff] [blame] | 1415 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, |
Nikolai Kondrashov | 72a4634 | 2010-08-20 19:21:11 +0400 | [diff] [blame] | 1416 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, |
Nikolai Kondrashov | 00e7f96 | 2010-09-25 23:16:58 +0400 | [diff] [blame] | 1417 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, |
Nikolai Kondrashov | 72a4634 | 2010-08-20 19:21:11 +0400 | [diff] [blame] | 1418 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, |
Nikolai Kondrashov | 8f1acc3 | 2010-08-30 14:06:36 +0400 | [diff] [blame] | 1419 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, |
Anssi Hannula | daedb3d | 2009-02-14 11:45:05 +0200 | [diff] [blame] | 1420 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, |
| 1421 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, |
Don Prince | a9885c8 | 2010-05-14 17:30:59 +0100 | [diff] [blame] | 1422 | { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, |
Jiri Slaby | 8c19a51 | 2008-06-18 23:36:49 +0200 | [diff] [blame] | 1423 | |
Jiri Slaby | 78a849a | 2008-06-20 21:26:11 +0200 | [diff] [blame] | 1424 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1425 | { } |
| 1426 | }; |
| 1427 | |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1428 | struct hid_dynid { |
| 1429 | struct list_head list; |
| 1430 | struct hid_device_id id; |
| 1431 | }; |
| 1432 | |
| 1433 | /** |
| 1434 | * store_new_id - add a new HID device ID to this driver and re-probe devices |
| 1435 | * @driver: target device driver |
| 1436 | * @buf: buffer for scanning device ID data |
| 1437 | * @count: input size |
| 1438 | * |
| 1439 | * Adds a new dynamic hid device ID to this driver, |
| 1440 | * and causes the driver to probe for all devices again. |
| 1441 | */ |
| 1442 | static ssize_t store_new_id(struct device_driver *drv, const char *buf, |
| 1443 | size_t count) |
| 1444 | { |
| 1445 | struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); |
| 1446 | struct hid_dynid *dynid; |
| 1447 | __u32 bus, vendor, product; |
| 1448 | unsigned long driver_data = 0; |
| 1449 | int ret; |
| 1450 | |
| 1451 | ret = sscanf(buf, "%x %x %x %lx", |
| 1452 | &bus, &vendor, &product, &driver_data); |
| 1453 | if (ret < 3) |
| 1454 | return -EINVAL; |
| 1455 | |
| 1456 | dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); |
| 1457 | if (!dynid) |
| 1458 | return -ENOMEM; |
| 1459 | |
| 1460 | dynid->id.bus = bus; |
| 1461 | dynid->id.vendor = vendor; |
| 1462 | dynid->id.product = product; |
| 1463 | dynid->id.driver_data = driver_data; |
| 1464 | |
| 1465 | spin_lock(&hdrv->dyn_lock); |
| 1466 | list_add_tail(&dynid->list, &hdrv->dyn_list); |
| 1467 | spin_unlock(&hdrv->dyn_lock); |
| 1468 | |
| 1469 | ret = 0; |
| 1470 | if (get_driver(&hdrv->driver)) { |
| 1471 | ret = driver_attach(&hdrv->driver); |
| 1472 | put_driver(&hdrv->driver); |
| 1473 | } |
| 1474 | |
| 1475 | return ret ? : count; |
| 1476 | } |
| 1477 | static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); |
| 1478 | |
| 1479 | static void hid_free_dynids(struct hid_driver *hdrv) |
| 1480 | { |
| 1481 | struct hid_dynid *dynid, *n; |
| 1482 | |
| 1483 | spin_lock(&hdrv->dyn_lock); |
| 1484 | list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) { |
| 1485 | list_del(&dynid->list); |
| 1486 | kfree(dynid); |
| 1487 | } |
| 1488 | spin_unlock(&hdrv->dyn_lock); |
| 1489 | } |
| 1490 | |
| 1491 | static const struct hid_device_id *hid_match_device(struct hid_device *hdev, |
| 1492 | struct hid_driver *hdrv) |
| 1493 | { |
| 1494 | struct hid_dynid *dynid; |
| 1495 | |
| 1496 | spin_lock(&hdrv->dyn_lock); |
| 1497 | list_for_each_entry(dynid, &hdrv->dyn_list, list) { |
| 1498 | if (hid_match_one_id(hdev, &dynid->id)) { |
| 1499 | spin_unlock(&hdrv->dyn_lock); |
| 1500 | return &dynid->id; |
| 1501 | } |
| 1502 | } |
| 1503 | spin_unlock(&hdrv->dyn_lock); |
| 1504 | |
| 1505 | return hid_match_id(hdev, hdrv->id_table); |
| 1506 | } |
| 1507 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1508 | static int hid_bus_match(struct device *dev, struct device_driver *drv) |
| 1509 | { |
| 1510 | struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); |
| 1511 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 1512 | |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1513 | if (!hid_match_device(hdev, hdrv)) |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1514 | return 0; |
| 1515 | |
Dmitry Torokhov | ce06b9d | 2010-11-28 16:37:14 +0100 | [diff] [blame] | 1516 | /* generic wants all that don't have specialized driver */ |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1517 | if (!strncmp(hdrv->name, "generic-", 8)) |
Dmitry Torokhov | ce06b9d | 2010-11-28 16:37:14 +0100 | [diff] [blame] | 1518 | return !hid_match_id(hdev, hid_have_special_driver); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1519 | |
| 1520 | return 1; |
| 1521 | } |
| 1522 | |
| 1523 | static int hid_device_probe(struct device *dev) |
| 1524 | { |
| 1525 | struct hid_driver *hdrv = container_of(dev->driver, |
| 1526 | struct hid_driver, driver); |
| 1527 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 1528 | const struct hid_device_id *id; |
| 1529 | int ret = 0; |
| 1530 | |
| 1531 | if (!hdev->driver) { |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1532 | id = hid_match_device(hdev, hdrv); |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 1533 | if (id == NULL) |
| 1534 | return -ENODEV; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1535 | |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 1536 | hdev->driver = hdrv; |
| 1537 | if (hdrv->probe) { |
| 1538 | ret = hdrv->probe(hdev, id); |
| 1539 | } else { /* default probe */ |
| 1540 | ret = hid_parse(hdev); |
| 1541 | if (!ret) |
Jiri Slaby | 93c1013 | 2008-06-27 00:04:24 +0200 | [diff] [blame] | 1542 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1543 | } |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 1544 | if (ret) |
| 1545 | hdev->driver = NULL; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1546 | } |
| 1547 | return ret; |
| 1548 | } |
| 1549 | |
| 1550 | static int hid_device_remove(struct device *dev) |
| 1551 | { |
| 1552 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 1553 | struct hid_driver *hdrv = hdev->driver; |
| 1554 | |
| 1555 | if (hdrv) { |
| 1556 | if (hdrv->remove) |
| 1557 | hdrv->remove(hdev); |
Jiri Slaby | c500c97 | 2008-05-16 11:49:16 +0200 | [diff] [blame] | 1558 | else /* default remove */ |
| 1559 | hid_hw_stop(hdev); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1560 | hdev->driver = NULL; |
| 1561 | } |
| 1562 | |
| 1563 | return 0; |
| 1564 | } |
| 1565 | |
| 1566 | static int hid_uevent(struct device *dev, struct kobj_uevent_env *env) |
| 1567 | { |
| 1568 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 1569 | |
| 1570 | if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", |
| 1571 | hdev->bus, hdev->vendor, hdev->product)) |
| 1572 | return -ENOMEM; |
| 1573 | |
| 1574 | if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) |
| 1575 | return -ENOMEM; |
| 1576 | |
| 1577 | if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) |
| 1578 | return -ENOMEM; |
| 1579 | |
| 1580 | if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) |
| 1581 | return -ENOMEM; |
| 1582 | |
| 1583 | if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X", |
| 1584 | hdev->bus, hdev->vendor, hdev->product)) |
| 1585 | return -ENOMEM; |
| 1586 | |
| 1587 | return 0; |
| 1588 | } |
| 1589 | |
| 1590 | static struct bus_type hid_bus_type = { |
| 1591 | .name = "hid", |
| 1592 | .match = hid_bus_match, |
| 1593 | .probe = hid_device_probe, |
| 1594 | .remove = hid_device_remove, |
| 1595 | .uevent = hid_uevent, |
| 1596 | }; |
| 1597 | |
Jiri Kosina | bae7eb3 | 2009-01-28 23:06:37 +0100 | [diff] [blame] | 1598 | /* a list of devices that shouldn't be handled by HID core at all */ |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1599 | static const struct hid_device_id hid_ignore_list[] = { |
| 1600 | { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, |
| 1601 | { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, |
| 1602 | { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, |
| 1603 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, |
| 1604 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, |
| 1605 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, |
| 1606 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, |
| 1607 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, |
| 1608 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, |
| 1609 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, |
| 1610 | { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, |
| 1611 | { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, |
Stephane Chatty | 77f720b | 2010-02-06 15:17:13 +0100 | [diff] [blame] | 1612 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)}, |
| 1613 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)}, |
Alexey Klimov | 62a5658 | 2008-11-13 05:44:50 +0300 | [diff] [blame] | 1614 | { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1615 | { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, |
| 1616 | { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, |
| 1617 | { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, |
| 1618 | { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, |
| 1619 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, |
| 1620 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, |
Alexey Klimov | 5f6108c | 2008-12-08 12:40:14 +0100 | [diff] [blame] | 1621 | { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1622 | { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, |
| 1623 | { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, |
| 1624 | { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, |
Petr Å tetiar | 70c6656 | 2009-12-09 22:09:53 +0100 | [diff] [blame] | 1625 | { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) }, |
Petr Å tetiar | df506f2 | 2010-06-28 09:38:54 -0700 | [diff] [blame] | 1626 | { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1627 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, |
| 1628 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, |
| 1629 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) }, |
| 1630 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, |
| 1631 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, |
| 1632 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, |
| 1633 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, |
| 1634 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, |
| 1635 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, |
| 1636 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, |
| 1637 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, |
| 1638 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, |
| 1639 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, |
| 1640 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, |
| 1641 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, |
| 1642 | { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, |
| 1643 | { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, |
| 1644 | { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, |
| 1645 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, |
| 1646 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, |
| 1647 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, |
| 1648 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, |
| 1649 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, |
| 1650 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, |
| 1651 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, |
| 1652 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, |
| 1653 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, |
| 1654 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, |
| 1655 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, |
| 1656 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, |
| 1657 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, |
| 1658 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, |
| 1659 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, |
| 1660 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, |
| 1661 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, |
| 1662 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, |
| 1663 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, |
| 1664 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, |
| 1665 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, |
| 1666 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, |
| 1667 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, |
| 1668 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, |
| 1669 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, |
| 1670 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, |
| 1671 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, |
| 1672 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, |
| 1673 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, |
| 1674 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, |
| 1675 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, |
| 1676 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, |
| 1677 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, |
| 1678 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, |
| 1679 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, |
| 1680 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, |
| 1681 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, |
| 1682 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, |
| 1683 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, |
| 1684 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, |
| 1685 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, |
| 1686 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, |
| 1687 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, |
| 1688 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, |
| 1689 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, |
| 1690 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, |
| 1691 | { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, |
Tomoki Sekiyama | 6bc235a | 2010-09-29 12:16:50 +0900 | [diff] [blame] | 1692 | { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_JESS_YUREX) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1693 | { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, |
Alexey Klimov | c91c21c | 2008-11-13 10:36:11 +0100 | [diff] [blame] | 1694 | { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1695 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, |
Lamarque Vieira Souza | eb8141c | 2009-10-02 15:04:44 +0200 | [diff] [blame] | 1696 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1697 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, |
| 1698 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, |
| 1699 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, |
| 1700 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, |
| 1701 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, |
| 1702 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, |
| 1703 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY1) }, |
| 1704 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, |
| 1705 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, |
| 1706 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, |
| 1707 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, |
| 1708 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, |
| 1709 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, |
| 1710 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, |
| 1711 | { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, |
| 1712 | { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1713 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, |
| 1714 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, |
| 1715 | { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, |
| 1716 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, |
| 1717 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, |
| 1718 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, |
| 1719 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, |
| 1720 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, |
| 1721 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, |
| 1722 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, |
| 1723 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, |
| 1724 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, |
| 1725 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, |
| 1726 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, |
| 1727 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, |
| 1728 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, |
| 1729 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, |
Henning Glawe | 4cfae3e | 2009-08-02 22:18:12 +0200 | [diff] [blame] | 1730 | { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, |
Michael Tokarev | 35cfd1d | 2009-02-01 16:11:04 +0100 | [diff] [blame] | 1731 | { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1732 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, |
| 1733 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, |
| 1734 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, |
| 1735 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, |
| 1736 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, |
| 1737 | { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, |
| 1738 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, |
| 1739 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, |
| 1740 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, |
| 1741 | { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, |
| 1742 | { } |
| 1743 | }; |
| 1744 | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 1745 | /** |
| 1746 | * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer |
| 1747 | * |
| 1748 | * There are composite devices for which we want to ignore only a certain |
| 1749 | * interface. This is a list of devices for which only the mouse interface will |
| 1750 | * be ignored. This allows a dedicated driver to take care of the interface. |
| 1751 | */ |
| 1752 | static const struct hid_device_id hid_mouse_ignore_list[] = { |
| 1753 | /* appletouch driver */ |
| 1754 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, |
| 1755 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, |
| 1756 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, |
| 1757 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, |
| 1758 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, |
| 1759 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, |
| 1760 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, |
| 1761 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, |
| 1762 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, |
| 1763 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, |
| 1764 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, |
| 1765 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, |
| 1766 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, |
| 1767 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, |
| 1768 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, |
| 1769 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, |
| 1770 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, |
| 1771 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, |
| 1772 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, |
| 1773 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, |
Jiri Kosina | ac26fca | 2008-11-20 11:27:02 +0100 | [diff] [blame] | 1774 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, |
| 1775 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, |
| 1776 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, |
Edgar (gimli) Hucek | 99b9f75 | 2010-11-03 10:36:18 -0400 | [diff] [blame] | 1777 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, |
| 1778 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, |
| 1779 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, |
| 1780 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, |
| 1781 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, |
| 1782 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 1783 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
| 1784 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
| 1785 | { } |
| 1786 | }; |
| 1787 | |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1788 | static bool hid_ignore(struct hid_device *hdev) |
| 1789 | { |
| 1790 | switch (hdev->vendor) { |
| 1791 | case USB_VENDOR_ID_CODEMERCS: |
| 1792 | /* ignore all Code Mercenaries IOWarrior devices */ |
| 1793 | if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && |
| 1794 | hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) |
| 1795 | return true; |
| 1796 | break; |
| 1797 | case USB_VENDOR_ID_LOGITECH: |
| 1798 | if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && |
| 1799 | hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) |
| 1800 | return true; |
| 1801 | break; |
Jarod Wilson | 31f7fd7 | 2009-07-31 10:56:36 -0400 | [diff] [blame] | 1802 | case USB_VENDOR_ID_SOUNDGRAPH: |
| 1803 | if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST && |
| 1804 | hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST) |
| 1805 | return true; |
| 1806 | break; |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1807 | } |
| 1808 | |
Jiri Slaby | b4d8e47 | 2008-10-22 14:47:18 +0200 | [diff] [blame] | 1809 | if (hdev->type == HID_TYPE_USBMOUSE && |
| 1810 | hid_match_id(hdev, hid_mouse_ignore_list)) |
| 1811 | return true; |
| 1812 | |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1813 | return !!hid_match_id(hdev, hid_ignore_list); |
| 1814 | } |
| 1815 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1816 | int hid_add_device(struct hid_device *hdev) |
| 1817 | { |
| 1818 | static atomic_t id = ATOMIC_INIT(0); |
| 1819 | int ret; |
| 1820 | |
| 1821 | if (WARN_ON(hdev->status & HID_STAT_ADDED)) |
| 1822 | return -EBUSY; |
| 1823 | |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1824 | /* we need to kill them here, otherwise they will stay allocated to |
| 1825 | * wait for coming driver */ |
Jindrich Makovicka | e5a2a04 | 2010-06-03 12:50:42 +0200 | [diff] [blame] | 1826 | if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) |
| 1827 | && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE))) |
Jiri Slaby | d458a9d | 2008-05-16 11:49:20 +0200 | [diff] [blame] | 1828 | return -ENODEV; |
| 1829 | |
Kay Sievers | 6bbe586 | 2008-10-31 00:12:32 +0100 | [diff] [blame] | 1830 | /* XXX hack, any other cleaner solution after the driver core |
| 1831 | * is converted to allow more than 20 bytes as the device name? */ |
| 1832 | dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, |
| 1833 | hdev->vendor, hdev->product, atomic_inc_return(&id)); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1834 | |
Bruno Prémont | 4da361b | 2010-03-15 14:55:40 +0100 | [diff] [blame] | 1835 | hid_debug_register(hdev, dev_name(&hdev->dev)); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1836 | ret = device_add(&hdev->dev); |
| 1837 | if (!ret) |
| 1838 | hdev->status |= HID_STAT_ADDED; |
Bruno Prémont | 4da361b | 2010-03-15 14:55:40 +0100 | [diff] [blame] | 1839 | else |
| 1840 | hid_debug_unregister(hdev); |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 1841 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1842 | return ret; |
| 1843 | } |
| 1844 | EXPORT_SYMBOL_GPL(hid_add_device); |
| 1845 | |
| 1846 | /** |
| 1847 | * hid_allocate_device - allocate new hid device descriptor |
| 1848 | * |
| 1849 | * Allocate and initialize hid device, so that hid_destroy_device might be |
| 1850 | * used to free it. |
| 1851 | * |
| 1852 | * New hid_device pointer is returned on success, otherwise ERR_PTR encoded |
| 1853 | * error value. |
| 1854 | */ |
| 1855 | struct hid_device *hid_allocate_device(void) |
| 1856 | { |
| 1857 | struct hid_device *hdev; |
| 1858 | unsigned int i; |
| 1859 | int ret = -ENOMEM; |
| 1860 | |
| 1861 | hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); |
| 1862 | if (hdev == NULL) |
| 1863 | return ERR_PTR(ret); |
| 1864 | |
| 1865 | device_initialize(&hdev->dev); |
| 1866 | hdev->dev.release = hid_device_release; |
| 1867 | hdev->dev.bus = &hid_bus_type; |
| 1868 | |
| 1869 | hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, |
| 1870 | sizeof(struct hid_collection), GFP_KERNEL); |
| 1871 | if (hdev->collection == NULL) |
| 1872 | goto err; |
| 1873 | hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS; |
| 1874 | |
| 1875 | for (i = 0; i < HID_REPORT_TYPES; i++) |
| 1876 | INIT_LIST_HEAD(&hdev->report_enum[i].report_list); |
| 1877 | |
Jiri Kosina | cd667ce | 2009-06-12 15:20:57 +0200 | [diff] [blame] | 1878 | init_waitqueue_head(&hdev->debug_wait); |
| 1879 | INIT_LIST_HEAD(&hdev->debug_list); |
| 1880 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1881 | return hdev; |
| 1882 | err: |
| 1883 | put_device(&hdev->dev); |
| 1884 | return ERR_PTR(ret); |
| 1885 | } |
| 1886 | EXPORT_SYMBOL_GPL(hid_allocate_device); |
| 1887 | |
| 1888 | static void hid_remove_device(struct hid_device *hdev) |
| 1889 | { |
| 1890 | if (hdev->status & HID_STAT_ADDED) { |
| 1891 | device_del(&hdev->dev); |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 1892 | hid_debug_unregister(hdev); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1893 | hdev->status &= ~HID_STAT_ADDED; |
| 1894 | } |
| 1895 | } |
| 1896 | |
| 1897 | /** |
| 1898 | * hid_destroy_device - free previously allocated device |
| 1899 | * |
| 1900 | * @hdev: hid device |
| 1901 | * |
| 1902 | * If you allocate hid_device through hid_allocate_device, you should ever |
| 1903 | * free by this function. |
| 1904 | */ |
| 1905 | void hid_destroy_device(struct hid_device *hdev) |
| 1906 | { |
| 1907 | hid_remove_device(hdev); |
| 1908 | put_device(&hdev->dev); |
| 1909 | } |
| 1910 | EXPORT_SYMBOL_GPL(hid_destroy_device); |
| 1911 | |
| 1912 | int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, |
| 1913 | const char *mod_name) |
| 1914 | { |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1915 | int ret; |
| 1916 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1917 | hdrv->driver.name = hdrv->name; |
| 1918 | hdrv->driver.bus = &hid_bus_type; |
| 1919 | hdrv->driver.owner = owner; |
| 1920 | hdrv->driver.mod_name = mod_name; |
| 1921 | |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1922 | INIT_LIST_HEAD(&hdrv->dyn_list); |
| 1923 | spin_lock_init(&hdrv->dyn_lock); |
| 1924 | |
| 1925 | ret = driver_register(&hdrv->driver); |
| 1926 | if (ret) |
| 1927 | return ret; |
| 1928 | |
| 1929 | ret = driver_create_file(&hdrv->driver, &driver_attr_new_id); |
| 1930 | if (ret) |
| 1931 | driver_unregister(&hdrv->driver); |
| 1932 | |
| 1933 | return ret; |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1934 | } |
| 1935 | EXPORT_SYMBOL_GPL(__hid_register_driver); |
| 1936 | |
| 1937 | void hid_unregister_driver(struct hid_driver *hdrv) |
| 1938 | { |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1939 | driver_remove_file(&hdrv->driver, &driver_attr_new_id); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1940 | driver_unregister(&hdrv->driver); |
Jiri Slaby | 3a6f82f | 2008-11-24 16:20:09 +0100 | [diff] [blame] | 1941 | hid_free_dynids(hdrv); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1942 | } |
| 1943 | EXPORT_SYMBOL_GPL(hid_unregister_driver); |
| 1944 | |
Oliver Neukum | 0361a28 | 2008-12-17 15:38:03 +0100 | [diff] [blame] | 1945 | int hid_check_keys_pressed(struct hid_device *hid) |
| 1946 | { |
| 1947 | struct hid_input *hidinput; |
| 1948 | int i; |
| 1949 | |
Jiri Kosina | e5288eb | 2009-05-02 00:02:57 +0200 | [diff] [blame] | 1950 | if (!(hid->claimed & HID_CLAIMED_INPUT)) |
| 1951 | return 0; |
| 1952 | |
Oliver Neukum | 0361a28 | 2008-12-17 15:38:03 +0100 | [diff] [blame] | 1953 | list_for_each_entry(hidinput, &hid->inputs, list) { |
| 1954 | for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++) |
| 1955 | if (hidinput->input->key[i]) |
| 1956 | return 1; |
| 1957 | } |
| 1958 | |
| 1959 | return 0; |
| 1960 | } |
| 1961 | |
| 1962 | EXPORT_SYMBOL_GPL(hid_check_keys_pressed); |
| 1963 | |
Jiri Kosina | 86166b7 | 2007-05-14 09:57:40 +0200 | [diff] [blame] | 1964 | static int __init hid_init(void) |
| 1965 | { |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1966 | int ret; |
| 1967 | |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 1968 | if (hid_debug) |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 1969 | pr_warn("hid_debug is now used solely for parser and driver debugging.\n" |
| 1970 | "debugfs is now used for inspecting the device (report descriptor, reports)\n"); |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 1971 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1972 | ret = bus_register(&hid_bus_type); |
| 1973 | if (ret) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame^] | 1974 | pr_err("can't register hid bus\n"); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1975 | goto err; |
| 1976 | } |
| 1977 | |
| 1978 | ret = hidraw_init(); |
| 1979 | if (ret) |
| 1980 | goto err_bus; |
| 1981 | |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 1982 | hid_debug_init(); |
| 1983 | |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1984 | return 0; |
| 1985 | err_bus: |
| 1986 | bus_unregister(&hid_bus_type); |
| 1987 | err: |
| 1988 | return ret; |
Jiri Kosina | 86166b7 | 2007-05-14 09:57:40 +0200 | [diff] [blame] | 1989 | } |
| 1990 | |
| 1991 | static void __exit hid_exit(void) |
| 1992 | { |
Jiri Kosina | a635f9d | 2009-06-12 15:20:55 +0200 | [diff] [blame] | 1993 | hid_debug_exit(); |
Jiri Kosina | 86166b7 | 2007-05-14 09:57:40 +0200 | [diff] [blame] | 1994 | hidraw_exit(); |
Jiri Slaby | 85cdaf5 | 2008-05-16 11:49:15 +0200 | [diff] [blame] | 1995 | bus_unregister(&hid_bus_type); |
Jiri Kosina | 86166b7 | 2007-05-14 09:57:40 +0200 | [diff] [blame] | 1996 | } |
| 1997 | |
| 1998 | module_init(hid_init); |
| 1999 | module_exit(hid_exit); |
| 2000 | |
Jiri Kosina | 88adb72 | 2009-10-02 18:29:34 +0200 | [diff] [blame] | 2001 | MODULE_AUTHOR("Andreas Gal"); |
| 2002 | MODULE_AUTHOR("Vojtech Pavlik"); |
| 2003 | MODULE_AUTHOR("Jiri Kosina"); |
Jiri Kosina | aa938f7 | 2006-12-08 18:41:10 +0100 | [diff] [blame] | 2004 | MODULE_LICENSE(DRIVER_LICENSE); |
| 2005 | |