1dde5845aSJiri Kosina /* 2229695e5SJiri Kosina * HID support for Linux 3dde5845aSJiri Kosina * 4dde5845aSJiri Kosina * Copyright (c) 1999 Andreas Gal 5dde5845aSJiri Kosina * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 6dde5845aSJiri Kosina * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 76b1968d5SJiri Kosina * Copyright (c) 2006-2012 Jiri Kosina 8dde5845aSJiri Kosina */ 9dde5845aSJiri Kosina 10dde5845aSJiri Kosina /* 11dde5845aSJiri Kosina * This program is free software; you can redistribute it and/or modify it 12dde5845aSJiri Kosina * under the terms of the GNU General Public License as published by the Free 13dde5845aSJiri Kosina * Software Foundation; either version 2 of the License, or (at your option) 14dde5845aSJiri Kosina * any later version. 15dde5845aSJiri Kosina */ 16dde5845aSJiri Kosina 174291ee30SJoe Perches #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 184291ee30SJoe Perches 19dde5845aSJiri Kosina #include <linux/module.h> 20dde5845aSJiri Kosina #include <linux/slab.h> 21dde5845aSJiri Kosina #include <linux/init.h> 22dde5845aSJiri Kosina #include <linux/kernel.h> 23dde5845aSJiri Kosina #include <linux/list.h> 24dde5845aSJiri Kosina #include <linux/mm.h> 25dde5845aSJiri Kosina #include <linux/spinlock.h> 26dde5845aSJiri Kosina #include <asm/unaligned.h> 27dde5845aSJiri Kosina #include <asm/byteorder.h> 28dde5845aSJiri Kosina #include <linux/input.h> 29dde5845aSJiri Kosina #include <linux/wait.h> 3047a80edbSJiri Kosina #include <linux/vmalloc.h> 31c4124c9bSJiri Kosina #include <linux/sched.h> 324ea54542SDavid Herrmann #include <linux/semaphore.h> 33dde5845aSJiri Kosina 34dde5845aSJiri Kosina #include <linux/hid.h> 35dde5845aSJiri Kosina #include <linux/hiddev.h> 36c080d89aSJiri Kosina #include <linux/hid-debug.h> 3786166b7bSJiri Kosina #include <linux/hidraw.h> 38dde5845aSJiri Kosina 395f22a799SJiri Slaby #include "hid-ids.h" 405f22a799SJiri Slaby 41dde5845aSJiri Kosina /* 42dde5845aSJiri Kosina * Version Information 43dde5845aSJiri Kosina */ 44dde5845aSJiri Kosina 4553149801SJiri Kosina #define DRIVER_DESC "HID core driver" 46dde5845aSJiri Kosina #define DRIVER_LICENSE "GPL" 47dde5845aSJiri Kosina 4858037eb9SJiri Kosina int hid_debug = 0; 49377e10fbSAnssi Hannula module_param_named(debug, hid_debug, int, 0600); 50cd667ce2SJiri Kosina MODULE_PARM_DESC(debug, "toggle HID debugging messages"); 5158037eb9SJiri Kosina EXPORT_SYMBOL_GPL(hid_debug); 5258037eb9SJiri Kosina 536b1968d5SJiri Kosina static int hid_ignore_special_drivers = 0; 546b1968d5SJiri Kosina module_param_named(ignore_special_drivers, hid_ignore_special_drivers, int, 0600); 556b1968d5SJiri Kosina MODULE_PARM_DESC(debug, "Ignore any special drivers and handle all devices by generic driver"); 566b1968d5SJiri Kosina 57dde5845aSJiri Kosina /* 58dde5845aSJiri Kosina * Register a new report for a device. 59dde5845aSJiri Kosina */ 60dde5845aSJiri Kosina 6190a006abSMichael Poole struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) 62dde5845aSJiri Kosina { 63dde5845aSJiri Kosina struct hid_report_enum *report_enum = device->report_enum + type; 64dde5845aSJiri Kosina struct hid_report *report; 65dde5845aSJiri Kosina 66dde5845aSJiri Kosina if (report_enum->report_id_hash[id]) 67dde5845aSJiri Kosina return report_enum->report_id_hash[id]; 68dde5845aSJiri Kosina 69a3789a17SJoe Perches report = kzalloc(sizeof(struct hid_report), GFP_KERNEL); 70a3789a17SJoe Perches if (!report) 71dde5845aSJiri Kosina return NULL; 72dde5845aSJiri Kosina 73dde5845aSJiri Kosina if (id != 0) 74dde5845aSJiri Kosina report_enum->numbered = 1; 75dde5845aSJiri Kosina 76dde5845aSJiri Kosina report->id = id; 77dde5845aSJiri Kosina report->type = type; 78dde5845aSJiri Kosina report->size = 0; 79dde5845aSJiri Kosina report->device = device; 80dde5845aSJiri Kosina report_enum->report_id_hash[id] = report; 81dde5845aSJiri Kosina 82dde5845aSJiri Kosina list_add_tail(&report->list, &report_enum->report_list); 83dde5845aSJiri Kosina 84dde5845aSJiri Kosina return report; 85dde5845aSJiri Kosina } 8690a006abSMichael Poole EXPORT_SYMBOL_GPL(hid_register_report); 87dde5845aSJiri Kosina 88dde5845aSJiri Kosina /* 89dde5845aSJiri Kosina * Register a new field for this report. 90dde5845aSJiri Kosina */ 91dde5845aSJiri Kosina 92dde5845aSJiri Kosina static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) 93dde5845aSJiri Kosina { 94dde5845aSJiri Kosina struct hid_field *field; 95dde5845aSJiri Kosina 96dde5845aSJiri Kosina if (report->maxfield == HID_MAX_FIELDS) { 978c3d52fcSJiri Kosina hid_err(report->device, "too many fields in report\n"); 98dde5845aSJiri Kosina return NULL; 99dde5845aSJiri Kosina } 100dde5845aSJiri Kosina 101a3789a17SJoe Perches field = kzalloc((sizeof(struct hid_field) + 102a3789a17SJoe Perches usages * sizeof(struct hid_usage) + 103a3789a17SJoe Perches values * sizeof(unsigned)), GFP_KERNEL); 104a3789a17SJoe Perches if (!field) 105a3789a17SJoe Perches return NULL; 106dde5845aSJiri Kosina 107dde5845aSJiri Kosina field->index = report->maxfield++; 108dde5845aSJiri Kosina report->field[field->index] = field; 109dde5845aSJiri Kosina field->usage = (struct hid_usage *)(field + 1); 110282bfd4cSJiri Slaby field->value = (s32 *)(field->usage + usages); 111dde5845aSJiri Kosina field->report = report; 112dde5845aSJiri Kosina 113dde5845aSJiri Kosina return field; 114dde5845aSJiri Kosina } 115dde5845aSJiri Kosina 116dde5845aSJiri Kosina /* 117dde5845aSJiri Kosina * Open a collection. The type/usage is pushed on the stack. 118dde5845aSJiri Kosina */ 119dde5845aSJiri Kosina 120dde5845aSJiri Kosina static int open_collection(struct hid_parser *parser, unsigned type) 121dde5845aSJiri Kosina { 122dde5845aSJiri Kosina struct hid_collection *collection; 123dde5845aSJiri Kosina unsigned usage; 124dde5845aSJiri Kosina 125dde5845aSJiri Kosina usage = parser->local.usage[0]; 126dde5845aSJiri Kosina 127dde5845aSJiri Kosina if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { 1288c3d52fcSJiri Kosina hid_err(parser->device, "collection stack overflow\n"); 129dde5845aSJiri Kosina return -1; 130dde5845aSJiri Kosina } 131dde5845aSJiri Kosina 132dde5845aSJiri Kosina if (parser->device->maxcollection == parser->device->collection_size) { 133dde5845aSJiri Kosina collection = kmalloc(sizeof(struct hid_collection) * 134dde5845aSJiri Kosina parser->device->collection_size * 2, GFP_KERNEL); 135dde5845aSJiri Kosina if (collection == NULL) { 1368c3d52fcSJiri Kosina hid_err(parser->device, "failed to reallocate collection array\n"); 137dde5845aSJiri Kosina return -1; 138dde5845aSJiri Kosina } 139dde5845aSJiri Kosina memcpy(collection, parser->device->collection, 140dde5845aSJiri Kosina sizeof(struct hid_collection) * 141dde5845aSJiri Kosina parser->device->collection_size); 142dde5845aSJiri Kosina memset(collection + parser->device->collection_size, 0, 143dde5845aSJiri Kosina sizeof(struct hid_collection) * 144dde5845aSJiri Kosina parser->device->collection_size); 145dde5845aSJiri Kosina kfree(parser->device->collection); 146dde5845aSJiri Kosina parser->device->collection = collection; 147dde5845aSJiri Kosina parser->device->collection_size *= 2; 148dde5845aSJiri Kosina } 149dde5845aSJiri Kosina 150dde5845aSJiri Kosina parser->collection_stack[parser->collection_stack_ptr++] = 151dde5845aSJiri Kosina parser->device->maxcollection; 152dde5845aSJiri Kosina 153dde5845aSJiri Kosina collection = parser->device->collection + 154dde5845aSJiri Kosina parser->device->maxcollection++; 155dde5845aSJiri Kosina collection->type = type; 156dde5845aSJiri Kosina collection->usage = usage; 157dde5845aSJiri Kosina collection->level = parser->collection_stack_ptr - 1; 158dde5845aSJiri Kosina 159dde5845aSJiri Kosina if (type == HID_COLLECTION_APPLICATION) 160dde5845aSJiri Kosina parser->device->maxapplication++; 161dde5845aSJiri Kosina 162dde5845aSJiri Kosina return 0; 163dde5845aSJiri Kosina } 164dde5845aSJiri Kosina 165dde5845aSJiri Kosina /* 166dde5845aSJiri Kosina * Close a collection. 167dde5845aSJiri Kosina */ 168dde5845aSJiri Kosina 169dde5845aSJiri Kosina static int close_collection(struct hid_parser *parser) 170dde5845aSJiri Kosina { 171dde5845aSJiri Kosina if (!parser->collection_stack_ptr) { 1728c3d52fcSJiri Kosina hid_err(parser->device, "collection stack underflow\n"); 173dde5845aSJiri Kosina return -1; 174dde5845aSJiri Kosina } 175dde5845aSJiri Kosina parser->collection_stack_ptr--; 176dde5845aSJiri Kosina return 0; 177dde5845aSJiri Kosina } 178dde5845aSJiri Kosina 179dde5845aSJiri Kosina /* 180dde5845aSJiri Kosina * Climb up the stack, search for the specified collection type 181dde5845aSJiri Kosina * and return the usage. 182dde5845aSJiri Kosina */ 183dde5845aSJiri Kosina 184dde5845aSJiri Kosina static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) 185dde5845aSJiri Kosina { 186504499f2SJoe Perches struct hid_collection *collection = parser->device->collection; 187dde5845aSJiri Kosina int n; 188504499f2SJoe Perches 189504499f2SJoe Perches for (n = parser->collection_stack_ptr - 1; n >= 0; n--) { 190504499f2SJoe Perches unsigned index = parser->collection_stack[n]; 191504499f2SJoe Perches if (collection[index].type == type) 192504499f2SJoe Perches return collection[index].usage; 193504499f2SJoe Perches } 194dde5845aSJiri Kosina return 0; /* we know nothing about this usage type */ 195dde5845aSJiri Kosina } 196dde5845aSJiri Kosina 197dde5845aSJiri Kosina /* 198dde5845aSJiri Kosina * Add a usage to the temporary parser table. 199dde5845aSJiri Kosina */ 200dde5845aSJiri Kosina 201dde5845aSJiri Kosina static int hid_add_usage(struct hid_parser *parser, unsigned usage) 202dde5845aSJiri Kosina { 203dde5845aSJiri Kosina if (parser->local.usage_index >= HID_MAX_USAGES) { 2048c3d52fcSJiri Kosina hid_err(parser->device, "usage index exceeded\n"); 205dde5845aSJiri Kosina return -1; 206dde5845aSJiri Kosina } 207dde5845aSJiri Kosina parser->local.usage[parser->local.usage_index] = usage; 208dde5845aSJiri Kosina parser->local.collection_index[parser->local.usage_index] = 209dde5845aSJiri Kosina parser->collection_stack_ptr ? 210dde5845aSJiri Kosina parser->collection_stack[parser->collection_stack_ptr - 1] : 0; 211dde5845aSJiri Kosina parser->local.usage_index++; 212dde5845aSJiri Kosina return 0; 213dde5845aSJiri Kosina } 214dde5845aSJiri Kosina 215dde5845aSJiri Kosina /* 216dde5845aSJiri Kosina * Register a new field for this report. 217dde5845aSJiri Kosina */ 218dde5845aSJiri Kosina 219dde5845aSJiri Kosina static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags) 220dde5845aSJiri Kosina { 221dde5845aSJiri Kosina struct hid_report *report; 222dde5845aSJiri Kosina struct hid_field *field; 223dde5845aSJiri Kosina int usages; 224dde5845aSJiri Kosina unsigned offset; 225dde5845aSJiri Kosina int i; 226dde5845aSJiri Kosina 227a3789a17SJoe Perches report = hid_register_report(parser->device, report_type, parser->global.report_id); 228a3789a17SJoe Perches if (!report) { 2298c3d52fcSJiri Kosina hid_err(parser->device, "hid_register_report failed\n"); 230dde5845aSJiri Kosina return -1; 231dde5845aSJiri Kosina } 232dde5845aSJiri Kosina 233bb2e1976SJiri Kosina /* Handle both signed and unsigned cases properly */ 2340cd516c2Ssrinivas pandruvada if ((parser->global.logical_minimum < 0 && 2350cd516c2Ssrinivas pandruvada parser->global.logical_maximum < 2360cd516c2Ssrinivas pandruvada parser->global.logical_minimum) || 2370cd516c2Ssrinivas pandruvada (parser->global.logical_minimum >= 0 && 2380cd516c2Ssrinivas pandruvada (__u32)parser->global.logical_maximum < 2390cd516c2Ssrinivas pandruvada (__u32)parser->global.logical_minimum)) { 2400cd516c2Ssrinivas pandruvada dbg_hid("logical range invalid 0x%x 0x%x\n", 2410cd516c2Ssrinivas pandruvada parser->global.logical_minimum, 2420cd516c2Ssrinivas pandruvada parser->global.logical_maximum); 243dde5845aSJiri Kosina return -1; 244dde5845aSJiri Kosina } 245dde5845aSJiri Kosina 246dde5845aSJiri Kosina offset = report->size; 247dde5845aSJiri Kosina report->size += parser->global.report_size * parser->global.report_count; 248dde5845aSJiri Kosina 249dde5845aSJiri Kosina if (!parser->local.usage_index) /* Ignore padding fields */ 250dde5845aSJiri Kosina return 0; 251dde5845aSJiri Kosina 252dde5845aSJiri Kosina usages = max_t(int, parser->local.usage_index, parser->global.report_count); 253dde5845aSJiri Kosina 254a3789a17SJoe Perches field = hid_register_field(report, usages, parser->global.report_count); 255a3789a17SJoe Perches if (!field) 256dde5845aSJiri Kosina return 0; 257dde5845aSJiri Kosina 258dde5845aSJiri Kosina field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); 259dde5845aSJiri Kosina field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL); 260dde5845aSJiri Kosina field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); 261dde5845aSJiri Kosina 262dde5845aSJiri Kosina for (i = 0; i < usages; i++) { 263dde5845aSJiri Kosina int j = i; 264dde5845aSJiri Kosina /* Duplicate the last usage we parsed if we have excess values */ 265dde5845aSJiri Kosina if (i >= parser->local.usage_index) 266dde5845aSJiri Kosina j = parser->local.usage_index - 1; 267dde5845aSJiri Kosina field->usage[i].hid = parser->local.usage[j]; 268dde5845aSJiri Kosina field->usage[i].collection_index = 269dde5845aSJiri Kosina parser->local.collection_index[j]; 270dde5845aSJiri Kosina } 271dde5845aSJiri Kosina 272dde5845aSJiri Kosina field->maxusage = usages; 273dde5845aSJiri Kosina field->flags = flags; 274dde5845aSJiri Kosina field->report_offset = offset; 275dde5845aSJiri Kosina field->report_type = report_type; 276dde5845aSJiri Kosina field->report_size = parser->global.report_size; 277dde5845aSJiri Kosina field->report_count = parser->global.report_count; 278dde5845aSJiri Kosina field->logical_minimum = parser->global.logical_minimum; 279dde5845aSJiri Kosina field->logical_maximum = parser->global.logical_maximum; 280dde5845aSJiri Kosina field->physical_minimum = parser->global.physical_minimum; 281dde5845aSJiri Kosina field->physical_maximum = parser->global.physical_maximum; 282dde5845aSJiri Kosina field->unit_exponent = parser->global.unit_exponent; 283dde5845aSJiri Kosina field->unit = parser->global.unit; 284dde5845aSJiri Kosina 285dde5845aSJiri Kosina return 0; 286dde5845aSJiri Kosina } 287dde5845aSJiri Kosina 288dde5845aSJiri Kosina /* 289dde5845aSJiri Kosina * Read data value from item. 290dde5845aSJiri Kosina */ 291dde5845aSJiri Kosina 292dde5845aSJiri Kosina static u32 item_udata(struct hid_item *item) 293dde5845aSJiri Kosina { 294dde5845aSJiri Kosina switch (item->size) { 295dde5845aSJiri Kosina case 1: return item->data.u8; 296dde5845aSJiri Kosina case 2: return item->data.u16; 297dde5845aSJiri Kosina case 4: return item->data.u32; 298dde5845aSJiri Kosina } 299dde5845aSJiri Kosina return 0; 300dde5845aSJiri Kosina } 301dde5845aSJiri Kosina 302dde5845aSJiri Kosina static s32 item_sdata(struct hid_item *item) 303dde5845aSJiri Kosina { 304dde5845aSJiri Kosina switch (item->size) { 305dde5845aSJiri Kosina case 1: return item->data.s8; 306dde5845aSJiri Kosina case 2: return item->data.s16; 307dde5845aSJiri Kosina case 4: return item->data.s32; 308dde5845aSJiri Kosina } 309dde5845aSJiri Kosina return 0; 310dde5845aSJiri Kosina } 311dde5845aSJiri Kosina 312dde5845aSJiri Kosina /* 313dde5845aSJiri Kosina * Process a global item. 314dde5845aSJiri Kosina */ 315dde5845aSJiri Kosina 316dde5845aSJiri Kosina static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) 317dde5845aSJiri Kosina { 318dde5845aSJiri Kosina switch (item->tag) { 319dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_PUSH: 320dde5845aSJiri Kosina 321dde5845aSJiri Kosina if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { 3228c3d52fcSJiri Kosina hid_err(parser->device, "global environment stack overflow\n"); 323dde5845aSJiri Kosina return -1; 324dde5845aSJiri Kosina } 325dde5845aSJiri Kosina 326dde5845aSJiri Kosina memcpy(parser->global_stack + parser->global_stack_ptr++, 327dde5845aSJiri Kosina &parser->global, sizeof(struct hid_global)); 328dde5845aSJiri Kosina return 0; 329dde5845aSJiri Kosina 330dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_POP: 331dde5845aSJiri Kosina 332dde5845aSJiri Kosina if (!parser->global_stack_ptr) { 3338c3d52fcSJiri Kosina hid_err(parser->device, "global environment stack underflow\n"); 334dde5845aSJiri Kosina return -1; 335dde5845aSJiri Kosina } 336dde5845aSJiri Kosina 337880d29f1SJiri Slaby memcpy(&parser->global, parser->global_stack + 338880d29f1SJiri Slaby --parser->global_stack_ptr, sizeof(struct hid_global)); 339dde5845aSJiri Kosina return 0; 340dde5845aSJiri Kosina 341dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: 342dde5845aSJiri Kosina parser->global.usage_page = item_udata(item); 343dde5845aSJiri Kosina return 0; 344dde5845aSJiri Kosina 345dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: 346dde5845aSJiri Kosina parser->global.logical_minimum = item_sdata(item); 347dde5845aSJiri Kosina return 0; 348dde5845aSJiri Kosina 349dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: 350dde5845aSJiri Kosina if (parser->global.logical_minimum < 0) 351dde5845aSJiri Kosina parser->global.logical_maximum = item_sdata(item); 352dde5845aSJiri Kosina else 353dde5845aSJiri Kosina parser->global.logical_maximum = item_udata(item); 354dde5845aSJiri Kosina return 0; 355dde5845aSJiri Kosina 356dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: 357dde5845aSJiri Kosina parser->global.physical_minimum = item_sdata(item); 358dde5845aSJiri Kosina return 0; 359dde5845aSJiri Kosina 360dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: 361dde5845aSJiri Kosina if (parser->global.physical_minimum < 0) 362dde5845aSJiri Kosina parser->global.physical_maximum = item_sdata(item); 363dde5845aSJiri Kosina else 364dde5845aSJiri Kosina parser->global.physical_maximum = item_udata(item); 365dde5845aSJiri Kosina return 0; 366dde5845aSJiri Kosina 367dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: 368dde5845aSJiri Kosina parser->global.unit_exponent = item_sdata(item); 369dde5845aSJiri Kosina return 0; 370dde5845aSJiri Kosina 371dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_UNIT: 372dde5845aSJiri Kosina parser->global.unit = item_udata(item); 373dde5845aSJiri Kosina return 0; 374dde5845aSJiri Kosina 375dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: 376880d29f1SJiri Slaby parser->global.report_size = item_udata(item); 377e46e927bSChase Douglas if (parser->global.report_size > 96) { 3788c3d52fcSJiri Kosina hid_err(parser->device, "invalid report_size %d\n", 379880d29f1SJiri Slaby parser->global.report_size); 380dde5845aSJiri Kosina return -1; 381dde5845aSJiri Kosina } 382dde5845aSJiri Kosina return 0; 383dde5845aSJiri Kosina 384dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: 385880d29f1SJiri Slaby parser->global.report_count = item_udata(item); 386880d29f1SJiri Slaby if (parser->global.report_count > HID_MAX_USAGES) { 3878c3d52fcSJiri Kosina hid_err(parser->device, "invalid report_count %d\n", 388880d29f1SJiri Slaby parser->global.report_count); 389dde5845aSJiri Kosina return -1; 390dde5845aSJiri Kosina } 391dde5845aSJiri Kosina return 0; 392dde5845aSJiri Kosina 393dde5845aSJiri Kosina case HID_GLOBAL_ITEM_TAG_REPORT_ID: 394880d29f1SJiri Slaby parser->global.report_id = item_udata(item); 395880d29f1SJiri Slaby if (parser->global.report_id == 0) { 3968c3d52fcSJiri Kosina hid_err(parser->device, "report_id 0 is invalid\n"); 397dde5845aSJiri Kosina return -1; 398dde5845aSJiri Kosina } 399dde5845aSJiri Kosina return 0; 400dde5845aSJiri Kosina 401dde5845aSJiri Kosina default: 4028c3d52fcSJiri Kosina hid_err(parser->device, "unknown global tag 0x%x\n", item->tag); 403dde5845aSJiri Kosina return -1; 404dde5845aSJiri Kosina } 405dde5845aSJiri Kosina } 406dde5845aSJiri Kosina 407dde5845aSJiri Kosina /* 408dde5845aSJiri Kosina * Process a local item. 409dde5845aSJiri Kosina */ 410dde5845aSJiri Kosina 411dde5845aSJiri Kosina static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) 412dde5845aSJiri Kosina { 413dde5845aSJiri Kosina __u32 data; 414dde5845aSJiri Kosina unsigned n; 415dde5845aSJiri Kosina 416dde5845aSJiri Kosina data = item_udata(item); 417dde5845aSJiri Kosina 418dde5845aSJiri Kosina switch (item->tag) { 419dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_DELIMITER: 420dde5845aSJiri Kosina 421dde5845aSJiri Kosina if (data) { 422dde5845aSJiri Kosina /* 423dde5845aSJiri Kosina * We treat items before the first delimiter 424dde5845aSJiri Kosina * as global to all usage sets (branch 0). 425dde5845aSJiri Kosina * In the moment we process only these global 426dde5845aSJiri Kosina * items and the first delimiter set. 427dde5845aSJiri Kosina */ 428dde5845aSJiri Kosina if (parser->local.delimiter_depth != 0) { 4298c3d52fcSJiri Kosina hid_err(parser->device, "nested delimiters\n"); 430dde5845aSJiri Kosina return -1; 431dde5845aSJiri Kosina } 432dde5845aSJiri Kosina parser->local.delimiter_depth++; 433dde5845aSJiri Kosina parser->local.delimiter_branch++; 434dde5845aSJiri Kosina } else { 435dde5845aSJiri Kosina if (parser->local.delimiter_depth < 1) { 4368c3d52fcSJiri Kosina hid_err(parser->device, "bogus close delimiter\n"); 437dde5845aSJiri Kosina return -1; 438dde5845aSJiri Kosina } 439dde5845aSJiri Kosina parser->local.delimiter_depth--; 440dde5845aSJiri Kosina } 441dde5845aSJiri Kosina return 1; 442dde5845aSJiri Kosina 443dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_USAGE: 444dde5845aSJiri Kosina 445dde5845aSJiri Kosina if (parser->local.delimiter_branch > 1) { 44658037eb9SJiri Kosina dbg_hid("alternative usage ignored\n"); 447dde5845aSJiri Kosina return 0; 448dde5845aSJiri Kosina } 449dde5845aSJiri Kosina 450dde5845aSJiri Kosina if (item->size <= 2) 451dde5845aSJiri Kosina data = (parser->global.usage_page << 16) + data; 452dde5845aSJiri Kosina 453dde5845aSJiri Kosina return hid_add_usage(parser, data); 454dde5845aSJiri Kosina 455dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: 456dde5845aSJiri Kosina 457dde5845aSJiri Kosina if (parser->local.delimiter_branch > 1) { 45858037eb9SJiri Kosina dbg_hid("alternative usage ignored\n"); 459dde5845aSJiri Kosina return 0; 460dde5845aSJiri Kosina } 461dde5845aSJiri Kosina 462dde5845aSJiri Kosina if (item->size <= 2) 463dde5845aSJiri Kosina data = (parser->global.usage_page << 16) + data; 464dde5845aSJiri Kosina 465dde5845aSJiri Kosina parser->local.usage_minimum = data; 466dde5845aSJiri Kosina return 0; 467dde5845aSJiri Kosina 468dde5845aSJiri Kosina case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: 469dde5845aSJiri Kosina 470dde5845aSJiri Kosina if (parser->local.delimiter_branch > 1) { 47158037eb9SJiri Kosina dbg_hid("alternative usage ignored\n"); 472dde5845aSJiri Kosina return 0; 473dde5845aSJiri Kosina } 474dde5845aSJiri Kosina 475dde5845aSJiri Kosina if (item->size <= 2) 476dde5845aSJiri Kosina data = (parser->global.usage_page << 16) + data; 477dde5845aSJiri Kosina 478dde5845aSJiri Kosina for (n = parser->local.usage_minimum; n <= data; n++) 479dde5845aSJiri Kosina if (hid_add_usage(parser, n)) { 48058037eb9SJiri Kosina dbg_hid("hid_add_usage failed\n"); 481dde5845aSJiri Kosina return -1; 482dde5845aSJiri Kosina } 483dde5845aSJiri Kosina return 0; 484dde5845aSJiri Kosina 485dde5845aSJiri Kosina default: 486dde5845aSJiri Kosina 48758037eb9SJiri Kosina dbg_hid("unknown local item tag 0x%x\n", item->tag); 488dde5845aSJiri Kosina return 0; 489dde5845aSJiri Kosina } 490dde5845aSJiri Kosina return 0; 491dde5845aSJiri Kosina } 492dde5845aSJiri Kosina 493dde5845aSJiri Kosina /* 494dde5845aSJiri Kosina * Process a main item. 495dde5845aSJiri Kosina */ 496dde5845aSJiri Kosina 497dde5845aSJiri Kosina static int hid_parser_main(struct hid_parser *parser, struct hid_item *item) 498dde5845aSJiri Kosina { 499dde5845aSJiri Kosina __u32 data; 500dde5845aSJiri Kosina int ret; 501dde5845aSJiri Kosina 502dde5845aSJiri Kosina data = item_udata(item); 503dde5845aSJiri Kosina 504dde5845aSJiri Kosina switch (item->tag) { 505dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: 506dde5845aSJiri Kosina ret = open_collection(parser, data & 0xff); 507dde5845aSJiri Kosina break; 508dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_END_COLLECTION: 509dde5845aSJiri Kosina ret = close_collection(parser); 510dde5845aSJiri Kosina break; 511dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_INPUT: 512dde5845aSJiri Kosina ret = hid_add_field(parser, HID_INPUT_REPORT, data); 513dde5845aSJiri Kosina break; 514dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_OUTPUT: 515dde5845aSJiri Kosina ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); 516dde5845aSJiri Kosina break; 517dde5845aSJiri Kosina case HID_MAIN_ITEM_TAG_FEATURE: 518dde5845aSJiri Kosina ret = hid_add_field(parser, HID_FEATURE_REPORT, data); 519dde5845aSJiri Kosina break; 520dde5845aSJiri Kosina default: 5218c3d52fcSJiri Kosina hid_err(parser->device, "unknown main item tag 0x%x\n", item->tag); 522dde5845aSJiri Kosina ret = 0; 523dde5845aSJiri Kosina } 524dde5845aSJiri Kosina 525dde5845aSJiri Kosina memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ 526dde5845aSJiri Kosina 527dde5845aSJiri Kosina return ret; 528dde5845aSJiri Kosina } 529dde5845aSJiri Kosina 530dde5845aSJiri Kosina /* 531dde5845aSJiri Kosina * Process a reserved item. 532dde5845aSJiri Kosina */ 533dde5845aSJiri Kosina 534dde5845aSJiri Kosina static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) 535dde5845aSJiri Kosina { 53658037eb9SJiri Kosina dbg_hid("reserved item type, tag 0x%x\n", item->tag); 537dde5845aSJiri Kosina return 0; 538dde5845aSJiri Kosina } 539dde5845aSJiri Kosina 540dde5845aSJiri Kosina /* 541dde5845aSJiri Kosina * Free a report and all registered fields. The field->usage and 542dde5845aSJiri Kosina * field->value table's are allocated behind the field, so we need 543dde5845aSJiri Kosina * only to free(field) itself. 544dde5845aSJiri Kosina */ 545dde5845aSJiri Kosina 546dde5845aSJiri Kosina static void hid_free_report(struct hid_report *report) 547dde5845aSJiri Kosina { 548dde5845aSJiri Kosina unsigned n; 549dde5845aSJiri Kosina 550dde5845aSJiri Kosina for (n = 0; n < report->maxfield; n++) 551dde5845aSJiri Kosina kfree(report->field[n]); 552dde5845aSJiri Kosina kfree(report); 553dde5845aSJiri Kosina } 554dde5845aSJiri Kosina 555dde5845aSJiri Kosina /* 556dde5845aSJiri Kosina * Free a device structure, all reports, and all fields. 557dde5845aSJiri Kosina */ 558dde5845aSJiri Kosina 55985cdaf52SJiri Slaby static void hid_device_release(struct device *dev) 560dde5845aSJiri Kosina { 56185cdaf52SJiri Slaby struct hid_device *device = container_of(dev, struct hid_device, dev); 562dde5845aSJiri Kosina unsigned i, j; 563dde5845aSJiri Kosina 564dde5845aSJiri Kosina for (i = 0; i < HID_REPORT_TYPES; i++) { 565dde5845aSJiri Kosina struct hid_report_enum *report_enum = device->report_enum + i; 566dde5845aSJiri Kosina 567dde5845aSJiri Kosina for (j = 0; j < 256; j++) { 568dde5845aSJiri Kosina struct hid_report *report = report_enum->report_id_hash[j]; 569dde5845aSJiri Kosina if (report) 570dde5845aSJiri Kosina hid_free_report(report); 571dde5845aSJiri Kosina } 572dde5845aSJiri Kosina } 573dde5845aSJiri Kosina 574dde5845aSJiri Kosina kfree(device->rdesc); 575767fe787SJiri Kosina kfree(device->collection); 576dde5845aSJiri Kosina kfree(device); 577dde5845aSJiri Kosina } 578dde5845aSJiri Kosina 579dde5845aSJiri Kosina /* 580dde5845aSJiri Kosina * Fetch a report description item from the data stream. We support long 581dde5845aSJiri Kosina * items, though they are not used yet. 582dde5845aSJiri Kosina */ 583dde5845aSJiri Kosina 584dde5845aSJiri Kosina static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) 585dde5845aSJiri Kosina { 586dde5845aSJiri Kosina u8 b; 587dde5845aSJiri Kosina 588dde5845aSJiri Kosina if ((end - start) <= 0) 589dde5845aSJiri Kosina return NULL; 590dde5845aSJiri Kosina 591dde5845aSJiri Kosina b = *start++; 592dde5845aSJiri Kosina 593dde5845aSJiri Kosina item->type = (b >> 2) & 3; 594dde5845aSJiri Kosina item->tag = (b >> 4) & 15; 595dde5845aSJiri Kosina 596dde5845aSJiri Kosina if (item->tag == HID_ITEM_TAG_LONG) { 597dde5845aSJiri Kosina 598dde5845aSJiri Kosina item->format = HID_ITEM_FORMAT_LONG; 599dde5845aSJiri Kosina 600dde5845aSJiri Kosina if ((end - start) < 2) 601dde5845aSJiri Kosina return NULL; 602dde5845aSJiri Kosina 603dde5845aSJiri Kosina item->size = *start++; 604dde5845aSJiri Kosina item->tag = *start++; 605dde5845aSJiri Kosina 606dde5845aSJiri Kosina if ((end - start) < item->size) 607dde5845aSJiri Kosina return NULL; 608dde5845aSJiri Kosina 609dde5845aSJiri Kosina item->data.longdata = start; 610dde5845aSJiri Kosina start += item->size; 611dde5845aSJiri Kosina return start; 612dde5845aSJiri Kosina } 613dde5845aSJiri Kosina 614dde5845aSJiri Kosina item->format = HID_ITEM_FORMAT_SHORT; 615dde5845aSJiri Kosina item->size = b & 3; 616dde5845aSJiri Kosina 617dde5845aSJiri Kosina switch (item->size) { 618dde5845aSJiri Kosina case 0: 619dde5845aSJiri Kosina return start; 620dde5845aSJiri Kosina 621dde5845aSJiri Kosina case 1: 622dde5845aSJiri Kosina if ((end - start) < 1) 623dde5845aSJiri Kosina return NULL; 624dde5845aSJiri Kosina item->data.u8 = *start++; 625dde5845aSJiri Kosina return start; 626dde5845aSJiri Kosina 627dde5845aSJiri Kosina case 2: 628dde5845aSJiri Kosina if ((end - start) < 2) 629dde5845aSJiri Kosina return NULL; 630c105068fSHarvey Harrison item->data.u16 = get_unaligned_le16(start); 631dde5845aSJiri Kosina start = (__u8 *)((__le16 *)start + 1); 632dde5845aSJiri Kosina return start; 633dde5845aSJiri Kosina 634dde5845aSJiri Kosina case 3: 635dde5845aSJiri Kosina item->size++; 636dde5845aSJiri Kosina if ((end - start) < 4) 637dde5845aSJiri Kosina return NULL; 638c105068fSHarvey Harrison item->data.u32 = get_unaligned_le32(start); 639dde5845aSJiri Kosina start = (__u8 *)((__le32 *)start + 1); 640dde5845aSJiri Kosina return start; 641dde5845aSJiri Kosina } 642dde5845aSJiri Kosina 643dde5845aSJiri Kosina return NULL; 644dde5845aSJiri Kosina } 645dde5845aSJiri Kosina 64685cdaf52SJiri Slaby /** 64785cdaf52SJiri Slaby * hid_parse_report - parse device report 64885cdaf52SJiri Slaby * 64985cdaf52SJiri Slaby * @device: hid device 65085cdaf52SJiri Slaby * @start: report start 65185cdaf52SJiri Slaby * @size: report size 65285cdaf52SJiri Slaby * 653dde5845aSJiri Kosina * Parse a report description into a hid_device structure. Reports are 654dde5845aSJiri Kosina * enumerated, fields are attached to these reports. 65585cdaf52SJiri Slaby * 0 returned on success, otherwise nonzero error value. 656dde5845aSJiri Kosina */ 65785cdaf52SJiri Slaby int hid_parse_report(struct hid_device *device, __u8 *start, 65885cdaf52SJiri Slaby unsigned size) 659dde5845aSJiri Kosina { 660dde5845aSJiri Kosina struct hid_parser *parser; 661dde5845aSJiri Kosina struct hid_item item; 662dde5845aSJiri Kosina __u8 *end; 66385cdaf52SJiri Slaby int ret; 664dde5845aSJiri Kosina static int (*dispatch_type[])(struct hid_parser *parser, 665dde5845aSJiri Kosina struct hid_item *item) = { 666dde5845aSJiri Kosina hid_parser_main, 667dde5845aSJiri Kosina hid_parser_global, 668dde5845aSJiri Kosina hid_parser_local, 669dde5845aSJiri Kosina hid_parser_reserved 670dde5845aSJiri Kosina }; 671dde5845aSJiri Kosina 672c500c971SJiri Slaby if (device->driver->report_fixup) 67373e4008dSNikolai Kondrashov start = device->driver->report_fixup(device, start, &size); 674c500c971SJiri Slaby 6751721a238SJulia Lawall device->rdesc = kmemdup(start, size, GFP_KERNEL); 67685cdaf52SJiri Slaby if (device->rdesc == NULL) 67785cdaf52SJiri Slaby return -ENOMEM; 678dde5845aSJiri Kosina device->rsize = size; 679dde5845aSJiri Kosina 680fe258020SJoe Perches parser = vzalloc(sizeof(struct hid_parser)); 68185cdaf52SJiri Slaby if (!parser) { 68285cdaf52SJiri Slaby ret = -ENOMEM; 68385cdaf52SJiri Slaby goto err; 684dde5845aSJiri Kosina } 68585cdaf52SJiri Slaby 686dde5845aSJiri Kosina parser->device = device; 687dde5845aSJiri Kosina 688dde5845aSJiri Kosina end = start + size; 68985cdaf52SJiri Slaby ret = -EINVAL; 690dde5845aSJiri Kosina while ((start = fetch_item(start, end, &item)) != NULL) { 691dde5845aSJiri Kosina 692dde5845aSJiri Kosina if (item.format != HID_ITEM_FORMAT_SHORT) { 6938c3d52fcSJiri Kosina hid_err(device, "unexpected long global item\n"); 69485cdaf52SJiri Slaby goto err; 695dde5845aSJiri Kosina } 696dde5845aSJiri Kosina 697dde5845aSJiri Kosina if (dispatch_type[item.type](parser, &item)) { 6988c3d52fcSJiri Kosina hid_err(device, "item %u %u %u %u parsing failed\n", 6994291ee30SJoe Perches item.format, (unsigned)item.size, 7004291ee30SJoe Perches (unsigned)item.type, (unsigned)item.tag); 70185cdaf52SJiri Slaby goto err; 702dde5845aSJiri Kosina } 703dde5845aSJiri Kosina 704dde5845aSJiri Kosina if (start == end) { 705dde5845aSJiri Kosina if (parser->collection_stack_ptr) { 7068c3d52fcSJiri Kosina hid_err(device, "unbalanced collection at end of report description\n"); 70785cdaf52SJiri Slaby goto err; 708dde5845aSJiri Kosina } 709dde5845aSJiri Kosina if (parser->local.delimiter_depth) { 7108c3d52fcSJiri Kosina hid_err(device, "unbalanced delimiter at end of report description\n"); 71185cdaf52SJiri Slaby goto err; 712dde5845aSJiri Kosina } 71347a80edbSJiri Kosina vfree(parser); 71485cdaf52SJiri Slaby return 0; 715dde5845aSJiri Kosina } 716dde5845aSJiri Kosina } 717dde5845aSJiri Kosina 7188c3d52fcSJiri Kosina hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); 71985cdaf52SJiri Slaby err: 72047a80edbSJiri Kosina vfree(parser); 72185cdaf52SJiri Slaby return ret; 722dde5845aSJiri Kosina } 723229695e5SJiri Kosina EXPORT_SYMBOL_GPL(hid_parse_report); 724dde5845aSJiri Kosina 725dde5845aSJiri Kosina /* 726dde5845aSJiri Kosina * Convert a signed n-bit integer to signed 32-bit integer. Common 727dde5845aSJiri Kosina * cases are done through the compiler, the screwed things has to be 728dde5845aSJiri Kosina * done by hand. 729dde5845aSJiri Kosina */ 730dde5845aSJiri Kosina 731dde5845aSJiri Kosina static s32 snto32(__u32 value, unsigned n) 732dde5845aSJiri Kosina { 733dde5845aSJiri Kosina switch (n) { 734dde5845aSJiri Kosina case 8: return ((__s8)value); 735dde5845aSJiri Kosina case 16: return ((__s16)value); 736dde5845aSJiri Kosina case 32: return ((__s32)value); 737dde5845aSJiri Kosina } 738dde5845aSJiri Kosina return value & (1 << (n - 1)) ? value | (-1 << n) : value; 739dde5845aSJiri Kosina } 740dde5845aSJiri Kosina 741dde5845aSJiri Kosina /* 742dde5845aSJiri Kosina * Convert a signed 32-bit integer to a signed n-bit integer. 743dde5845aSJiri Kosina */ 744dde5845aSJiri Kosina 745dde5845aSJiri Kosina static u32 s32ton(__s32 value, unsigned n) 746dde5845aSJiri Kosina { 747dde5845aSJiri Kosina s32 a = value >> (n - 1); 748dde5845aSJiri Kosina if (a && a != -1) 749dde5845aSJiri Kosina return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; 750dde5845aSJiri Kosina return value & ((1 << n) - 1); 751dde5845aSJiri Kosina } 752dde5845aSJiri Kosina 753dde5845aSJiri Kosina /* 754dde5845aSJiri Kosina * Extract/implement a data field from/to a little endian report (bit array). 755dde5845aSJiri Kosina * 756dde5845aSJiri Kosina * Code sort-of follows HID spec: 757dde5845aSJiri Kosina * http://www.usb.org/developers/devclass_docs/HID1_11.pdf 758dde5845aSJiri Kosina * 759dde5845aSJiri Kosina * While the USB HID spec allows unlimited length bit fields in "report 760dde5845aSJiri Kosina * descriptors", most devices never use more than 16 bits. 761dde5845aSJiri Kosina * One model of UPS is claimed to report "LINEV" as a 32-bit field. 762dde5845aSJiri Kosina * Search linux-kernel and linux-usb-devel archives for "hid-core extract". 763dde5845aSJiri Kosina */ 764dde5845aSJiri Kosina 76516ee4cc8SJoe Perches static __u32 extract(const struct hid_device *hid, __u8 *report, 7664291ee30SJoe Perches unsigned offset, unsigned n) 767dde5845aSJiri Kosina { 768dde5845aSJiri Kosina u64 x; 769dde5845aSJiri Kosina 770c4124c9bSJiri Kosina if (n > 32) 7714291ee30SJoe Perches hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n", 772c4124c9bSJiri Kosina n, current->comm); 773dde5845aSJiri Kosina 774dde5845aSJiri Kosina report += offset >> 3; /* adjust byte index */ 775dde5845aSJiri Kosina offset &= 7; /* now only need bit offset into one byte */ 776c105068fSHarvey Harrison x = get_unaligned_le64(report); 777dde5845aSJiri Kosina x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ 778dde5845aSJiri Kosina return (u32) x; 779dde5845aSJiri Kosina } 780dde5845aSJiri Kosina 781dde5845aSJiri Kosina /* 782dde5845aSJiri Kosina * "implement" : set bits in a little endian bit stream. 783dde5845aSJiri Kosina * Same concepts as "extract" (see comments above). 784dde5845aSJiri Kosina * The data mangled in the bit stream remains in little endian 785dde5845aSJiri Kosina * order the whole time. It make more sense to talk about 786dde5845aSJiri Kosina * endianness of register values by considering a register 787dde5845aSJiri Kosina * a "cached" copy of the little endiad bit stream. 788dde5845aSJiri Kosina */ 78916ee4cc8SJoe Perches static void implement(const struct hid_device *hid, __u8 *report, 7904291ee30SJoe Perches unsigned offset, unsigned n, __u32 value) 791dde5845aSJiri Kosina { 7926f0168d2SHarvey Harrison u64 x; 793dde5845aSJiri Kosina u64 m = (1ULL << n) - 1; 794dde5845aSJiri Kosina 795c4124c9bSJiri Kosina if (n > 32) 7964291ee30SJoe Perches hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n", 7974291ee30SJoe Perches __func__, n, current->comm); 798dde5845aSJiri Kosina 799c4124c9bSJiri Kosina if (value > m) 8004291ee30SJoe Perches hid_warn(hid, "%s() called with too large value %d! (%s)\n", 8014291ee30SJoe Perches __func__, value, current->comm); 802dde5845aSJiri Kosina WARN_ON(value > m); 803dde5845aSJiri Kosina value &= m; 804dde5845aSJiri Kosina 805dde5845aSJiri Kosina report += offset >> 3; 806dde5845aSJiri Kosina offset &= 7; 807dde5845aSJiri Kosina 8086f0168d2SHarvey Harrison x = get_unaligned_le64(report); 8096f0168d2SHarvey Harrison x &= ~(m << offset); 8106f0168d2SHarvey Harrison x |= ((u64)value) << offset; 8116f0168d2SHarvey Harrison put_unaligned_le64(x, report); 812dde5845aSJiri Kosina } 813dde5845aSJiri Kosina 814dde5845aSJiri Kosina /* 815dde5845aSJiri Kosina * Search an array for a value. 816dde5845aSJiri Kosina */ 817dde5845aSJiri Kosina 81816ee4cc8SJoe Perches static int search(__s32 *array, __s32 value, unsigned n) 819dde5845aSJiri Kosina { 820dde5845aSJiri Kosina while (n--) { 821dde5845aSJiri Kosina if (*array++ == value) 822dde5845aSJiri Kosina return 0; 823dde5845aSJiri Kosina } 824dde5845aSJiri Kosina return -1; 825dde5845aSJiri Kosina } 826dde5845aSJiri Kosina 82785cdaf52SJiri Slaby /** 82885cdaf52SJiri Slaby * hid_match_report - check if driver's raw_event should be called 82985cdaf52SJiri Slaby * 83085cdaf52SJiri Slaby * @hid: hid device 83185cdaf52SJiri Slaby * @report_type: type to match against 83285cdaf52SJiri Slaby * 83385cdaf52SJiri Slaby * compare hid->driver->report_table->report_type to report->type 83485cdaf52SJiri Slaby */ 83585cdaf52SJiri Slaby static int hid_match_report(struct hid_device *hid, struct hid_report *report) 836dde5845aSJiri Kosina { 83785cdaf52SJiri Slaby const struct hid_report_id *id = hid->driver->report_table; 83885cdaf52SJiri Slaby 83985cdaf52SJiri Slaby if (!id) /* NULL means all */ 84085cdaf52SJiri Slaby return 1; 84185cdaf52SJiri Slaby 84285cdaf52SJiri Slaby for (; id->report_type != HID_TERMINATOR; id++) 84385cdaf52SJiri Slaby if (id->report_type == HID_ANY_ID || 84485cdaf52SJiri Slaby id->report_type == report->type) 84585cdaf52SJiri Slaby return 1; 84685cdaf52SJiri Slaby return 0; 84785cdaf52SJiri Slaby } 84885cdaf52SJiri Slaby 84985cdaf52SJiri Slaby /** 85085cdaf52SJiri Slaby * hid_match_usage - check if driver's event should be called 85185cdaf52SJiri Slaby * 85285cdaf52SJiri Slaby * @hid: hid device 85385cdaf52SJiri Slaby * @usage: usage to match against 85485cdaf52SJiri Slaby * 85585cdaf52SJiri Slaby * compare hid->driver->usage_table->usage_{type,code} to 85685cdaf52SJiri Slaby * usage->usage_{type,code} 85785cdaf52SJiri Slaby */ 85885cdaf52SJiri Slaby static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage) 85985cdaf52SJiri Slaby { 86085cdaf52SJiri Slaby const struct hid_usage_id *id = hid->driver->usage_table; 86185cdaf52SJiri Slaby 86285cdaf52SJiri Slaby if (!id) /* NULL means all */ 86385cdaf52SJiri Slaby return 1; 86485cdaf52SJiri Slaby 86585cdaf52SJiri Slaby for (; id->usage_type != HID_ANY_ID - 1; id++) 86685cdaf52SJiri Slaby if ((id->usage_hid == HID_ANY_ID || 86785cdaf52SJiri Slaby id->usage_hid == usage->hid) && 86885cdaf52SJiri Slaby (id->usage_type == HID_ANY_ID || 86985cdaf52SJiri Slaby id->usage_type == usage->type) && 87085cdaf52SJiri Slaby (id->usage_code == HID_ANY_ID || 87185cdaf52SJiri Slaby id->usage_code == usage->code)) 87285cdaf52SJiri Slaby return 1; 87385cdaf52SJiri Slaby return 0; 87485cdaf52SJiri Slaby } 87585cdaf52SJiri Slaby 87685cdaf52SJiri Slaby static void hid_process_event(struct hid_device *hid, struct hid_field *field, 87785cdaf52SJiri Slaby struct hid_usage *usage, __s32 value, int interrupt) 87885cdaf52SJiri Slaby { 87985cdaf52SJiri Slaby struct hid_driver *hdrv = hid->driver; 88085cdaf52SJiri Slaby int ret; 88185cdaf52SJiri Slaby 882cd667ce2SJiri Kosina hid_dump_input(hid, usage, value); 88385cdaf52SJiri Slaby 88485cdaf52SJiri Slaby if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { 88585cdaf52SJiri Slaby ret = hdrv->event(hid, field, usage, value); 88685cdaf52SJiri Slaby if (ret != 0) { 88785cdaf52SJiri Slaby if (ret < 0) 8888c3d52fcSJiri Kosina hid_err(hid, "%s's event failed with %d\n", 88985cdaf52SJiri Slaby hdrv->name, ret); 89085cdaf52SJiri Slaby return; 89185cdaf52SJiri Slaby } 89285cdaf52SJiri Slaby } 89385cdaf52SJiri Slaby 894dde5845aSJiri Kosina if (hid->claimed & HID_CLAIMED_INPUT) 895dde5845aSJiri Kosina hidinput_hid_event(hid, field, usage, value); 896aa938f79SJiri Kosina if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) 897aa938f79SJiri Kosina hid->hiddev_hid_event(hid, field, usage, value); 898dde5845aSJiri Kosina } 899dde5845aSJiri Kosina 900dde5845aSJiri Kosina /* 901dde5845aSJiri Kosina * Analyse a received field, and fetch the data from it. The field 902dde5845aSJiri Kosina * content is stored for next report processing (we do differential 903dde5845aSJiri Kosina * reporting to the layer). 904dde5845aSJiri Kosina */ 905dde5845aSJiri Kosina 906abdff0f7SAdrian Bunk static void hid_input_field(struct hid_device *hid, struct hid_field *field, 907abdff0f7SAdrian Bunk __u8 *data, int interrupt) 908dde5845aSJiri Kosina { 909dde5845aSJiri Kosina unsigned n; 910dde5845aSJiri Kosina unsigned count = field->report_count; 911dde5845aSJiri Kosina unsigned offset = field->report_offset; 912dde5845aSJiri Kosina unsigned size = field->report_size; 913dde5845aSJiri Kosina __s32 min = field->logical_minimum; 914dde5845aSJiri Kosina __s32 max = field->logical_maximum; 915dde5845aSJiri Kosina __s32 *value; 916dde5845aSJiri Kosina 917a3789a17SJoe Perches value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC); 918a3789a17SJoe Perches if (!value) 919dde5845aSJiri Kosina return; 920dde5845aSJiri Kosina 921dde5845aSJiri Kosina for (n = 0; n < count; n++) { 922dde5845aSJiri Kosina 9234291ee30SJoe Perches value[n] = min < 0 ? 9244291ee30SJoe Perches snto32(extract(hid, data, offset + n * size, size), 9254291ee30SJoe Perches size) : 9264291ee30SJoe Perches extract(hid, data, offset + n * size, size); 927dde5845aSJiri Kosina 9284291ee30SJoe Perches /* Ignore report if ErrorRollOver */ 9294291ee30SJoe Perches if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && 9304291ee30SJoe Perches value[n] >= min && value[n] <= max && 9314291ee30SJoe Perches field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) 932dde5845aSJiri Kosina goto exit; 933dde5845aSJiri Kosina } 934dde5845aSJiri Kosina 935dde5845aSJiri Kosina for (n = 0; n < count; n++) { 936dde5845aSJiri Kosina 937dde5845aSJiri Kosina if (HID_MAIN_ITEM_VARIABLE & field->flags) { 938dde5845aSJiri Kosina hid_process_event(hid, field, &field->usage[n], value[n], interrupt); 939dde5845aSJiri Kosina continue; 940dde5845aSJiri Kosina } 941dde5845aSJiri Kosina 942dde5845aSJiri Kosina if (field->value[n] >= min && field->value[n] <= max 943dde5845aSJiri Kosina && field->usage[field->value[n] - min].hid 944dde5845aSJiri Kosina && search(value, field->value[n], count)) 945dde5845aSJiri Kosina hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); 946dde5845aSJiri Kosina 947dde5845aSJiri Kosina if (value[n] >= min && value[n] <= max 948dde5845aSJiri Kosina && field->usage[value[n] - min].hid 949dde5845aSJiri Kosina && search(field->value, value[n], count)) 950dde5845aSJiri Kosina hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); 951dde5845aSJiri Kosina } 952dde5845aSJiri Kosina 953dde5845aSJiri Kosina memcpy(field->value, value, count * sizeof(__s32)); 954dde5845aSJiri Kosina exit: 955dde5845aSJiri Kosina kfree(value); 956dde5845aSJiri Kosina } 957dde5845aSJiri Kosina 958dde5845aSJiri Kosina /* 959dde5845aSJiri Kosina * Output the field into the report. 960dde5845aSJiri Kosina */ 961dde5845aSJiri Kosina 9624291ee30SJoe Perches static void hid_output_field(const struct hid_device *hid, 9634291ee30SJoe Perches struct hid_field *field, __u8 *data) 964dde5845aSJiri Kosina { 965dde5845aSJiri Kosina unsigned count = field->report_count; 966dde5845aSJiri Kosina unsigned offset = field->report_offset; 967dde5845aSJiri Kosina unsigned size = field->report_size; 968dde5845aSJiri Kosina unsigned n; 969dde5845aSJiri Kosina 970dde5845aSJiri Kosina for (n = 0; n < count; n++) { 971dde5845aSJiri Kosina if (field->logical_minimum < 0) /* signed values */ 9724291ee30SJoe Perches implement(hid, data, offset + n * size, size, 9734291ee30SJoe Perches s32ton(field->value[n], size)); 974dde5845aSJiri Kosina else /* unsigned values */ 9754291ee30SJoe Perches implement(hid, data, offset + n * size, size, 9764291ee30SJoe Perches field->value[n]); 977dde5845aSJiri Kosina } 978dde5845aSJiri Kosina } 979dde5845aSJiri Kosina 980dde5845aSJiri Kosina /* 981dde5845aSJiri Kosina * Create a report. 982dde5845aSJiri Kosina */ 983dde5845aSJiri Kosina 984229695e5SJiri Kosina void hid_output_report(struct hid_report *report, __u8 *data) 985dde5845aSJiri Kosina { 986dde5845aSJiri Kosina unsigned n; 987dde5845aSJiri Kosina 988dde5845aSJiri Kosina if (report->id > 0) 989dde5845aSJiri Kosina *data++ = report->id; 990dde5845aSJiri Kosina 99175c28df8SPete Zaitcev memset(data, 0, ((report->size - 1) >> 3) + 1); 992dde5845aSJiri Kosina for (n = 0; n < report->maxfield; n++) 9934291ee30SJoe Perches hid_output_field(report->device, report->field[n], data); 994dde5845aSJiri Kosina } 995229695e5SJiri Kosina EXPORT_SYMBOL_GPL(hid_output_report); 996dde5845aSJiri Kosina 997dde5845aSJiri Kosina /* 998dde5845aSJiri Kosina * Set a field value. The report this field belongs to has to be 999dde5845aSJiri Kosina * created and transferred to the device, to set this value in the 1000dde5845aSJiri Kosina * device. 1001dde5845aSJiri Kosina */ 1002dde5845aSJiri Kosina 1003dde5845aSJiri Kosina int hid_set_field(struct hid_field *field, unsigned offset, __s32 value) 1004dde5845aSJiri Kosina { 1005dde5845aSJiri Kosina unsigned size = field->report_size; 1006dde5845aSJiri Kosina 1007cd667ce2SJiri Kosina hid_dump_input(field->report->device, field->usage + offset, value); 1008dde5845aSJiri Kosina 1009dde5845aSJiri Kosina if (offset >= field->report_count) { 10108c3d52fcSJiri Kosina hid_err(field->report->device, "offset (%d) exceeds report_count (%d)\n", 10118c3d52fcSJiri Kosina offset, field->report_count); 1012dde5845aSJiri Kosina return -1; 1013dde5845aSJiri Kosina } 1014dde5845aSJiri Kosina if (field->logical_minimum < 0) { 1015dde5845aSJiri Kosina if (value != snto32(s32ton(value, size), size)) { 10168c3d52fcSJiri Kosina hid_err(field->report->device, "value %d is out of range\n", value); 1017dde5845aSJiri Kosina return -1; 1018dde5845aSJiri Kosina } 1019dde5845aSJiri Kosina } 1020dde5845aSJiri Kosina field->value[offset] = value; 1021dde5845aSJiri Kosina return 0; 1022dde5845aSJiri Kosina } 1023229695e5SJiri Kosina EXPORT_SYMBOL_GPL(hid_set_field); 1024dde5845aSJiri Kosina 102585cdaf52SJiri Slaby static struct hid_report *hid_get_report(struct hid_report_enum *report_enum, 102685cdaf52SJiri Slaby const u8 *data) 102785cdaf52SJiri Slaby { 102885cdaf52SJiri Slaby struct hid_report *report; 102985cdaf52SJiri Slaby unsigned int n = 0; /* Normally report number is 0 */ 103085cdaf52SJiri Slaby 103185cdaf52SJiri Slaby /* Device uses numbered reports, data[0] is report number */ 103285cdaf52SJiri Slaby if (report_enum->numbered) 103385cdaf52SJiri Slaby n = *data; 103485cdaf52SJiri Slaby 103585cdaf52SJiri Slaby report = report_enum->report_id_hash[n]; 103685cdaf52SJiri Slaby if (report == NULL) 103785cdaf52SJiri Slaby dbg_hid("undefined report_id %u received\n", n); 103885cdaf52SJiri Slaby 103985cdaf52SJiri Slaby return report; 104085cdaf52SJiri Slaby } 104185cdaf52SJiri Slaby 1042b6787242SJiri Kosina int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, 104385cdaf52SJiri Slaby int interrupt) 1044aa8de2f0SJiri Kosina { 1045aa8de2f0SJiri Kosina struct hid_report_enum *report_enum = hid->report_enum + type; 1046aa8de2f0SJiri Kosina struct hid_report *report; 104785cdaf52SJiri Slaby unsigned int a; 104885cdaf52SJiri Slaby int rsize, csize = size; 104985cdaf52SJiri Slaby u8 *cdata = data; 1050b6787242SJiri Kosina int ret = 0; 1051aa8de2f0SJiri Kosina 105285cdaf52SJiri Slaby report = hid_get_report(report_enum, data); 105385cdaf52SJiri Slaby if (!report) 1054b6787242SJiri Kosina goto out; 1055aa8de2f0SJiri Kosina 105685cdaf52SJiri Slaby if (report_enum->numbered) { 105785cdaf52SJiri Slaby cdata++; 105885cdaf52SJiri Slaby csize--; 1059aa8de2f0SJiri Kosina } 1060aa8de2f0SJiri Kosina 1061aa8de2f0SJiri Kosina rsize = ((report->size - 1) >> 3) + 1; 1062aa8de2f0SJiri Kosina 1063966922f2SArmando Visconti if (rsize > HID_MAX_BUFFER_SIZE) 1064966922f2SArmando Visconti rsize = HID_MAX_BUFFER_SIZE; 1065966922f2SArmando Visconti 106685cdaf52SJiri Slaby if (csize < rsize) { 106785cdaf52SJiri Slaby dbg_hid("report %d is too short, (%d < %d)\n", report->id, 106885cdaf52SJiri Slaby csize, rsize); 106985cdaf52SJiri Slaby memset(cdata + csize, 0, rsize - csize); 1070aa8de2f0SJiri Kosina } 1071aa8de2f0SJiri Kosina 1072aa8de2f0SJiri Kosina if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) 1073aa8de2f0SJiri Kosina hid->hiddev_report_event(hid, report); 1074b6787242SJiri Kosina if (hid->claimed & HID_CLAIMED_HIDRAW) { 1075b6787242SJiri Kosina ret = hidraw_report_event(hid, data, size); 1076b6787242SJiri Kosina if (ret) 1077b6787242SJiri Kosina goto out; 1078b6787242SJiri Kosina } 1079aa8de2f0SJiri Kosina 108085cdaf52SJiri Slaby for (a = 0; a < report->maxfield; a++) 108185cdaf52SJiri Slaby hid_input_field(hid, report->field[a], cdata, interrupt); 1082aa8de2f0SJiri Kosina 1083aa8de2f0SJiri Kosina if (hid->claimed & HID_CLAIMED_INPUT) 1084aa8de2f0SJiri Kosina hidinput_report_event(hid, report); 1085b6787242SJiri Kosina out: 1086b6787242SJiri Kosina return ret; 108785cdaf52SJiri Slaby } 108885cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_report_raw_event); 108985cdaf52SJiri Slaby 109085cdaf52SJiri Slaby /** 109185cdaf52SJiri Slaby * hid_input_report - report data from lower layer (usb, bt...) 109285cdaf52SJiri Slaby * 109385cdaf52SJiri Slaby * @hid: hid device 109485cdaf52SJiri Slaby * @type: HID report type (HID_*_REPORT) 109585cdaf52SJiri Slaby * @data: report contents 109685cdaf52SJiri Slaby * @size: size of data parameter 1097ff9b00a2SJiri Kosina * @interrupt: distinguish between interrupt and control transfers 109885cdaf52SJiri Slaby * 109985cdaf52SJiri Slaby * This is data entry for lower layers. 110085cdaf52SJiri Slaby */ 110185cdaf52SJiri Slaby int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) 110285cdaf52SJiri Slaby { 110376c317d6SJulia Lawall struct hid_report_enum *report_enum; 110476c317d6SJulia Lawall struct hid_driver *hdrv; 110585cdaf52SJiri Slaby struct hid_report *report; 1106cd667ce2SJiri Kosina char *buf; 110785cdaf52SJiri Slaby unsigned int i; 110845dc1ac7SJiri Kosina int ret = 0; 110985cdaf52SJiri Slaby 11104ea54542SDavid Herrmann if (!hid) 111185cdaf52SJiri Slaby return -ENODEV; 11124ea54542SDavid Herrmann 11134ea54542SDavid Herrmann if (down_trylock(&hid->driver_lock)) 11144ea54542SDavid Herrmann return -EBUSY; 11154ea54542SDavid Herrmann 11164ea54542SDavid Herrmann if (!hid->driver) { 11174ea54542SDavid Herrmann ret = -ENODEV; 11184ea54542SDavid Herrmann goto unlock; 11194ea54542SDavid Herrmann } 112076c317d6SJulia Lawall report_enum = hid->report_enum + type; 112176c317d6SJulia Lawall hdrv = hid->driver; 112285cdaf52SJiri Slaby 112385cdaf52SJiri Slaby if (!size) { 112485cdaf52SJiri Slaby dbg_hid("empty report\n"); 11254ea54542SDavid Herrmann ret = -1; 11264ea54542SDavid Herrmann goto unlock; 112785cdaf52SJiri Slaby } 112885cdaf52SJiri Slaby 1129d1ff6522SJiri Kosina buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC); 1130cd667ce2SJiri Kosina 1131f77e347bSJiri Kosina if (!buf) 1132cd667ce2SJiri Kosina goto nomem; 113385cdaf52SJiri Slaby 113485cdaf52SJiri Slaby /* dump the report */ 1135cd667ce2SJiri Kosina snprintf(buf, HID_DEBUG_BUFSIZE - 1, 11361caea61eSJiri Kosina "\nreport (size %u) (%snumbered) = ", size, report_enum->numbered ? "" : "un"); 1137cd667ce2SJiri Kosina hid_debug_event(hid, buf); 11381caea61eSJiri Kosina 1139cd667ce2SJiri Kosina for (i = 0; i < size; i++) { 1140cd667ce2SJiri Kosina snprintf(buf, HID_DEBUG_BUFSIZE - 1, 1141cd667ce2SJiri Kosina " %02x", data[i]); 1142cd667ce2SJiri Kosina hid_debug_event(hid, buf); 1143cd667ce2SJiri Kosina } 1144cd667ce2SJiri Kosina hid_debug_event(hid, "\n"); 1145cd667ce2SJiri Kosina kfree(buf); 1146cd667ce2SJiri Kosina 1147cd667ce2SJiri Kosina nomem: 1148f77e347bSJiri Kosina report = hid_get_report(report_enum, data); 1149f77e347bSJiri Kosina 11504ea54542SDavid Herrmann if (!report) { 11514ea54542SDavid Herrmann ret = -1; 11524ea54542SDavid Herrmann goto unlock; 11534ea54542SDavid Herrmann } 1154f77e347bSJiri Kosina 115585cdaf52SJiri Slaby if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { 115685cdaf52SJiri Slaby ret = hdrv->raw_event(hid, report, data, size); 11574ea54542SDavid Herrmann if (ret != 0) { 11584ea54542SDavid Herrmann ret = ret < 0 ? ret : 0; 11594ea54542SDavid Herrmann goto unlock; 11604ea54542SDavid Herrmann } 116185cdaf52SJiri Slaby } 116285cdaf52SJiri Slaby 1163b6787242SJiri Kosina ret = hid_report_raw_event(hid, type, data, size, interrupt); 1164aa8de2f0SJiri Kosina 11654ea54542SDavid Herrmann unlock: 11664ea54542SDavid Herrmann up(&hid->driver_lock); 116745dc1ac7SJiri Kosina return ret; 1168aa8de2f0SJiri Kosina } 1169aa8de2f0SJiri Kosina EXPORT_SYMBOL_GPL(hid_input_report); 1170aa8de2f0SJiri Kosina 11710f37cd03SJiri Kosina static bool hid_match_one_id(struct hid_device *hdev, 11720f37cd03SJiri Kosina const struct hid_device_id *id) 11730f37cd03SJiri Kosina { 11740f37cd03SJiri Kosina return id->bus == hdev->bus && 11750f37cd03SJiri Kosina (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && 11760f37cd03SJiri Kosina (id->product == HID_ANY_ID || id->product == hdev->product); 11770f37cd03SJiri Kosina } 11780f37cd03SJiri Kosina 1179bbc21cfdSJeremy Fitzhardinge const struct hid_device_id *hid_match_id(struct hid_device *hdev, 11800f37cd03SJiri Kosina const struct hid_device_id *id) 11810f37cd03SJiri Kosina { 11820f37cd03SJiri Kosina for (; id->bus; id++) 11830f37cd03SJiri Kosina if (hid_match_one_id(hdev, id)) 11840f37cd03SJiri Kosina return id; 11850f37cd03SJiri Kosina 11860f37cd03SJiri Kosina return NULL; 11870f37cd03SJiri Kosina } 11880f37cd03SJiri Kosina 11890f37cd03SJiri Kosina static const struct hid_device_id hid_hiddev_list[] = { 1190c0bd6a42SRichard Hughes { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, 1191c0bd6a42SRichard Hughes { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, 11920f37cd03SJiri Kosina { } 11930f37cd03SJiri Kosina }; 11940f37cd03SJiri Kosina 11950f37cd03SJiri Kosina static bool hid_hiddev(struct hid_device *hdev) 11960f37cd03SJiri Kosina { 11970f37cd03SJiri Kosina return !!hid_match_id(hdev, hid_hiddev_list); 11980f37cd03SJiri Kosina } 11990f37cd03SJiri Kosina 12006d3bfb74SAlan Ott 12016d3bfb74SAlan Ott static ssize_t 12026d3bfb74SAlan Ott read_report_descriptor(struct file *filp, struct kobject *kobj, 12036d3bfb74SAlan Ott struct bin_attribute *attr, 12046d3bfb74SAlan Ott char *buf, loff_t off, size_t count) 12056d3bfb74SAlan Ott { 12066d3bfb74SAlan Ott struct device *dev = container_of(kobj, struct device, kobj); 12076d3bfb74SAlan Ott struct hid_device *hdev = container_of(dev, struct hid_device, dev); 12086d3bfb74SAlan Ott 12096d3bfb74SAlan Ott if (off >= hdev->rsize) 12106d3bfb74SAlan Ott return 0; 12116d3bfb74SAlan Ott 12126d3bfb74SAlan Ott if (off + count > hdev->rsize) 12136d3bfb74SAlan Ott count = hdev->rsize - off; 12146d3bfb74SAlan Ott 12156d3bfb74SAlan Ott memcpy(buf, hdev->rdesc + off, count); 12166d3bfb74SAlan Ott 12176d3bfb74SAlan Ott return count; 12186d3bfb74SAlan Ott } 12196d3bfb74SAlan Ott 12206d3bfb74SAlan Ott static struct bin_attribute dev_bin_attr_report_desc = { 12216d3bfb74SAlan Ott .attr = { .name = "report_descriptor", .mode = 0444 }, 12226d3bfb74SAlan Ott .read = read_report_descriptor, 12236d3bfb74SAlan Ott .size = HID_MAX_DESCRIPTOR_SIZE, 12246d3bfb74SAlan Ott }; 12256d3bfb74SAlan Ott 122693c10132SJiri Slaby int hid_connect(struct hid_device *hdev, unsigned int connect_mask) 122793c10132SJiri Slaby { 122893c10132SJiri Slaby static const char *types[] = { "Device", "Pointer", "Mouse", "Device", 122993c10132SJiri Slaby "Joystick", "Gamepad", "Keyboard", "Keypad", 123093c10132SJiri Slaby "Multi-Axis Controller" 123193c10132SJiri Slaby }; 123293c10132SJiri Slaby const char *type, *bus; 123393c10132SJiri Slaby char buf[64]; 123493c10132SJiri Slaby unsigned int i; 123593c10132SJiri Slaby int len; 12366d3bfb74SAlan Ott int ret; 123793c10132SJiri Slaby 1238b5e5a37eSBastien Nocera if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) 1239b5e5a37eSBastien Nocera connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV); 12403a343ee4SDaniel Mack if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE) 12413a343ee4SDaniel Mack connect_mask |= HID_CONNECT_HIDINPUT_FORCE; 124293c10132SJiri Slaby if (hdev->bus != BUS_USB) 124393c10132SJiri Slaby connect_mask &= ~HID_CONNECT_HIDDEV; 12440f37cd03SJiri Kosina if (hid_hiddev(hdev)) 12450f37cd03SJiri Kosina connect_mask |= HID_CONNECT_HIDDEV_FORCE; 124693c10132SJiri Slaby 124793c10132SJiri Slaby if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev, 124893c10132SJiri Slaby connect_mask & HID_CONNECT_HIDINPUT_FORCE)) 124993c10132SJiri Slaby hdev->claimed |= HID_CLAIMED_INPUT; 1250b77c3920SBenjamin Tissoires if (hdev->quirks & HID_QUIRK_MULTITOUCH) { 1251b77c3920SBenjamin Tissoires /* this device should be handled by hid-multitouch, skip it */ 1252b77c3920SBenjamin Tissoires return -ENODEV; 1253b77c3920SBenjamin Tissoires } 1254b77c3920SBenjamin Tissoires 125593c10132SJiri Slaby if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect && 125693c10132SJiri Slaby !hdev->hiddev_connect(hdev, 125793c10132SJiri Slaby connect_mask & HID_CONNECT_HIDDEV_FORCE)) 125893c10132SJiri Slaby hdev->claimed |= HID_CLAIMED_HIDDEV; 125993c10132SJiri Slaby if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev)) 126093c10132SJiri Slaby hdev->claimed |= HID_CLAIMED_HIDRAW; 126193c10132SJiri Slaby 126293c10132SJiri Slaby if (!hdev->claimed) { 12634291ee30SJoe Perches hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n"); 126493c10132SJiri Slaby return -ENODEV; 126593c10132SJiri Slaby } 126693c10132SJiri Slaby 126793c10132SJiri Slaby if ((hdev->claimed & HID_CLAIMED_INPUT) && 126893c10132SJiri Slaby (connect_mask & HID_CONNECT_FF) && hdev->ff_init) 126993c10132SJiri Slaby hdev->ff_init(hdev); 127093c10132SJiri Slaby 127193c10132SJiri Slaby len = 0; 127293c10132SJiri Slaby if (hdev->claimed & HID_CLAIMED_INPUT) 127393c10132SJiri Slaby len += sprintf(buf + len, "input"); 127493c10132SJiri Slaby if (hdev->claimed & HID_CLAIMED_HIDDEV) 127593c10132SJiri Slaby len += sprintf(buf + len, "%shiddev%d", len ? "," : "", 127693c10132SJiri Slaby hdev->minor); 127793c10132SJiri Slaby if (hdev->claimed & HID_CLAIMED_HIDRAW) 127893c10132SJiri Slaby len += sprintf(buf + len, "%shidraw%d", len ? "," : "", 127993c10132SJiri Slaby ((struct hidraw *)hdev->hidraw)->minor); 128093c10132SJiri Slaby 128193c10132SJiri Slaby type = "Device"; 128293c10132SJiri Slaby for (i = 0; i < hdev->maxcollection; i++) { 128393c10132SJiri Slaby struct hid_collection *col = &hdev->collection[i]; 128493c10132SJiri Slaby if (col->type == HID_COLLECTION_APPLICATION && 128593c10132SJiri Slaby (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK && 128693c10132SJiri Slaby (col->usage & 0xffff) < ARRAY_SIZE(types)) { 128793c10132SJiri Slaby type = types[col->usage & 0xffff]; 128893c10132SJiri Slaby break; 128993c10132SJiri Slaby } 129093c10132SJiri Slaby } 129193c10132SJiri Slaby 129293c10132SJiri Slaby switch (hdev->bus) { 129393c10132SJiri Slaby case BUS_USB: 129493c10132SJiri Slaby bus = "USB"; 129593c10132SJiri Slaby break; 129693c10132SJiri Slaby case BUS_BLUETOOTH: 129793c10132SJiri Slaby bus = "BLUETOOTH"; 129893c10132SJiri Slaby break; 129993c10132SJiri Slaby default: 130093c10132SJiri Slaby bus = "<UNKNOWN>"; 130193c10132SJiri Slaby } 130293c10132SJiri Slaby 13036d3bfb74SAlan Ott ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc); 13046d3bfb74SAlan Ott if (ret) 13056d3bfb74SAlan Ott hid_warn(hdev, 13066d3bfb74SAlan Ott "can't create sysfs report descriptor attribute err: %d\n", ret); 13076d3bfb74SAlan Ott 13084291ee30SJoe Perches hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", 130993c10132SJiri Slaby buf, bus, hdev->version >> 8, hdev->version & 0xff, 131093c10132SJiri Slaby type, hdev->name, hdev->phys); 131193c10132SJiri Slaby 131293c10132SJiri Slaby return 0; 131393c10132SJiri Slaby } 131493c10132SJiri Slaby EXPORT_SYMBOL_GPL(hid_connect); 131593c10132SJiri Slaby 1316c4c259bcSJiri Kosina void hid_disconnect(struct hid_device *hdev) 1317c4c259bcSJiri Kosina { 13186d3bfb74SAlan Ott device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc); 1319c4c259bcSJiri Kosina if (hdev->claimed & HID_CLAIMED_INPUT) 1320c4c259bcSJiri Kosina hidinput_disconnect(hdev); 1321c4c259bcSJiri Kosina if (hdev->claimed & HID_CLAIMED_HIDDEV) 1322c4c259bcSJiri Kosina hdev->hiddev_disconnect(hdev); 1323c4c259bcSJiri Kosina if (hdev->claimed & HID_CLAIMED_HIDRAW) 1324c4c259bcSJiri Kosina hidraw_disconnect(hdev); 1325c4c259bcSJiri Kosina } 1326c4c259bcSJiri Kosina EXPORT_SYMBOL_GPL(hid_disconnect); 1327c4c259bcSJiri Kosina 1328bae7eb33SJiri Kosina /* a list of devices for which there is a specialized driver on HID bus */ 1329ce06b9d6SDmitry Torokhov static const struct hid_device_id hid_have_special_driver[] = { 1330b6353f4fSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, 13316dec143aSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, 133214a21cd4SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 133314a21cd4SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1334b7e1b203SLech Perczak { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, 1335c0dbcc33SSergei Kolzun { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) }, 1336e6aac342SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR, USB_DEVICE_ID_ACTIONSTAR_1011) }, 1337df9bcaceSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, 13388c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, 13398c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, 1340128537ceSMichael Poole { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) }, 1341a462230eSChase Douglas { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) }, 13428c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 13438c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 13448c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 13458c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 13468c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 13478c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 13488c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 13498c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 13508c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 13518c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 13528c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1353fef3f571SRyan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI) }, 1354fef3f571SRyan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO) }, 1355fef3f571SRyan Finnie { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS) }, 13568c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) }, 13578c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) }, 13588c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) }, 13598c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 13608c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 13618c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1362ee8a1a0aSJan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, 1363ee8a1a0aSJan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, 1364ee8a1a0aSJan Scholz { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, 13658c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 13668c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 13678c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 13688c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 13698c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 13708c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1371a96d6ef3SHenrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1372a96d6ef3SHenrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1373a96d6ef3SHenrik Rydberg { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 137499b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 137599b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 137699b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 137799b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 137899b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 137999b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 138047340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, 138147340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, 138247340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, 1383213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) }, 1384213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) }, 1385213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) }, 13864a4c8799SDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) }, 13874a4c8799SDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) }, 13884a4c8799SDan Bastone { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) }, 1389f6f554f0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) }, 1390f6f554f0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) }, 1391f6f554f0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) }, 1392d762cc29SNobuhiro Iwamatsu { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 1393d762cc29SNobuhiro Iwamatsu { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 1394d762cc29SNobuhiro Iwamatsu { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 139523aeb61eSChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, 139623aeb61eSChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, 139723aeb61eSChristian Schuerer-Waldheim { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 1398ad734bc1SAndreas Krist { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) }, 13998c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 14008c19a515SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1401eaca1386SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) }, 1402cec15a0eSRoland Baum { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) }, 1403212da74dSJosenivaldo Benito Junior { HID_USB_DEVICE(USB_VENDOR_ID_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) }, 1404b5635b12SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1405bf280628SWayne Thomas { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, 1406c3dc66deSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, 14075519cab4SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, 140836213e1eSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) }, 1409bc5ab083SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) }, 1410ba4d8abbSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) }, 1411272036edSFrançois Jaouen { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, 14123b239cd7SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 14131ce31b25SRaphaël Doursenaud { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, 1414fcfacfd3SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1415b9e4b1e0SDennis Kügler { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, 14163596bb92SKeng-Yu Lin { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) }, 1417942fd422SAustin Zhang { HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, 14183a370ca1SDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, 141979603dc9SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, USB_DEVICE_ID_CVTOUCH_SCREEN) }, 14200f221320SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 14210f221320SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, 1422e8d0eab4SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) }, 14230f221320SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, 1424a3b5e577SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, 14253f866fbdSRichard Walmsley { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, 1426e05eefb9SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) }, 1427e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) }, 1428e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) }, 1429e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) }, 1430fd1d1525SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) }, 1431fd1d1525SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) }, 1432e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) }, 1433e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) }, 1434bb9ff210SMarek Vasut { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) }, 1435e36f690bSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) }, 143664b386eaSRichard Nauber { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 1437c04abeefSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2515) }, 143804561c5aSIgnaz Forster { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) }, 14391f243e30SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 14404d5df5d1SAndreas Nielsen { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_FRUCTEL, USB_DEVICE_ID_GAMETEL_MT_MODE) }, 14415181e594SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, 1442578f3a35SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, 14435572da08SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, 1444ee0fbd14SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH, USB_DEVICE_ID_GOODTOUCH_000f) }, 14455181e594SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, 144642859e0bSLukasz Lubojanski { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) }, 1447949f8fefSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, 14481e093206SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, 1449c2fd1a4eSCory Maccarrone { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, 14505519cab4SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_HANVON, USB_DEVICE_ID_HANVON_MULTITOUCH) }, 145154580365SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT, USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) }, 1452a062cc5aSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM, USB_DEVICE_ID_IDEACOM_IDC6650) }, 1453d946e65eSAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) }, 14544e61f0d7SAustin Zhang { HID_USB_DEVICE(USB_VENDOR_ID_ILITEK, USB_DEVICE_ID_ILITEK_MULTITOUCH) }, 1455b2e7617eSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS, USB_DEVICE_ID_IRTOUCH_INFRARED_USB) }, 1456fdf93aa3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, 1457177900e8SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, 145879422741SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, 145922ca20b2SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) }, 146022ca20b2SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) }, 146122ca20b2SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) }, 1462b5635b12SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 146375b07022SChris Schlund { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) }, 1464c50bb1a4SJeff Brown { HID_USB_DEVICE(USB_VENDOR_ID_LG, USB_DEVICE_ID_LG_MULTITOUCH) }, 14655f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, 14665f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, 14675f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, 14685f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, 14695f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, 14705f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, 14715f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, 14725f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, 14735f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, 14745f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, 14755f22a799SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) }, 14762c6118e4SHendrik Iben { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) }, 1477606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) }, 1478606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) }, 1479606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, 1480fd30ea8cSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) }, 1481606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, 148274f292caSGary Stein { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) }, 1483606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) }, 1484606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) }, 14855623a24aSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL) }, 1486e00ddc9bSMichal Malý { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL) }, 1487243b706dSChristophe Borivant { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) }, 1488fdc6807fSPeter Gundermann { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G27_WHEEL) }, 14890944e964SKonstantin Khlebnikov #if IS_ENABLED(CONFIG_HID_LOGITECH_DJ) 1490534a7b8eSNestor Lopez Casado { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER) }, 1491534a7b8eSNestor Lopez Casado { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2) }, 14920944e964SKonstantin Khlebnikov #endif 149332c88cbcSSimon Wood { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) }, 1494606bd0a8SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, 149524985cf6SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) }, 149624985cf6SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) }, 1497df167c4aSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH) }, 1498c3ead6deSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH_DUAL) }, 1499236db47cSBruno Prémont { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, 1500236db47cSBruno Prémont { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) }, 1501b580169aSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) }, 150278a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, 150378a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, 150478a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, 150578a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, 1506f3b83d71SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) }, 150778a849a6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 15083b8006e5SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 150994011f93SRafi Rubin { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, 15106e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) }, 15116e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) }, 15126e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) }, 15136e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) }, 15146e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) }, 15156e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) }, 15166e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) }, 15176e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) }, 15186e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) }, 15196e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) }, 15206e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) }, 15216e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) }, 15226e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) }, 15236e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) }, 15246e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) }, 15256e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) }, 15266e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) }, 15276e32819eSmicki { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) }, 1528270fdc07SHerton Ronaldo Krzesinski { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) }, 1529cd9ec30dSJohnathon Harris { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, 15302258e863SDenis Kovalev { HID_USB_DEVICE(USB_VENDOR_ID_PANASONIC, USB_DEVICE_ID_PANABOARD_UBT780) }, 15312258e863SDenis Kovalev { HID_USB_DEVICE(USB_VENDOR_ID_PANASONIC, USB_DEVICE_ID_PANABOARD_UBT880) }, 15326ab3a9a6SJohn Sung { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_PCI) }, 15331e762532SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 1534b7ea95ffSAaron Tian { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) }, 1535b7ea95ffSAaron Tian { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) }, 1536b7ea95ffSAaron Tian { HID_USB_DEVICE(USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) }, 1537f6a04605STerry Lambert { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) }, 153849e4739aSStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, 1539f54405dbSAlex Neblett { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, 154014bf62cdSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, 1541e68cc603SStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) }, 1542d41c2a70SStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) }, 154347dbdbffSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, 15440e70f97fSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) }, 1545cb7cf3daSStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, 15463fce2246SStefan Achatz { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) }, 15471e93674aSAndreas Hübner { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000) }, 1548980a3da6SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1549b355850bSDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, 1550d586dca0SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) }, 1551bd28ce00SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 155235dca5b4SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) }, 1553f9ce7c28SBastien Nocera { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1554cc6e0bbbSJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1555d3fb5454SStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) }, 1556b6dc7992SPascal Auriel - Stantum { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) }, 1557b6dc7992SPascal Auriel - Stantum { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) }, 155890231e7eSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1559daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1560daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, 15617a84b133SRuben Aos Garralda { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, 15627a84b133SRuben Aos Garralda { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) }, 1563daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, 15643ee8f0a2SMarkus Rathgeb { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) }, 1565daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, 1566d65c3768SSimon Wood { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) }, 1567740363fbSJiri Kosina { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_BT) }, 156844ea35c1SJarod Wilson { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE) }, 1569f14f526dSLev Babiev { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, 157054001081SKees Bakker { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) }, 15715e74e56dSBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL, USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) }, 1572711a680eSBruno Premont { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, 1573c64f6f93SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) }, 157441fa9230SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, 1575f8a489ccSNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) }, 1576f8a489ccSNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) }, 1577f8a489ccSNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) }, 15786be914f1SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) }, 1579*d1257081SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850) }, 1580617b64f9SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) }, 1581617b64f9SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_UNITEC, USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, 1582fac733f0SJussi Kivilinna { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, 158342fc04e5SSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SUPER_JOY_BOX_3) }, 1584ad395ccaSSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) }, 15851bcc2067SSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) }, 15861bcc2067SSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) }, 15871bcc2067SSean Young { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) }, 1588ca2dcd40SBastien Nocera { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, 158978761ff9SPrzemo Firszt { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, 159072a46344SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, 159100e7f964SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, 15924fdc18d1SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_Q_PAD) }, 1593a786e83cSNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_PID_0038) }, 159472a46344SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, 15958f1acc32SNikolai Kondrashov { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, 1596bc8a2a9bSice chien { HID_USB_DEVICE(USB_VENDOR_ID_XAT, USB_DEVICE_ID_XAT_CSR) }, 159711576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX) }, 159811576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX) }, 159911576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR) }, 160011576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX1) }, 160111576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX1) }, 160211576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR1) }, 160311576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_SPX2) }, 160411576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_MPX2) }, 160511576c61SMasatoshi Hoshikawa { HID_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR2) }, 160674bc6953SStefan Kriwanek { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) }, 1607daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, 1608daedb3d6SAnssi Hannula { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, 1609a9885c8fSDon Prince { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, 16108c19a515SJiri Slaby 161178a849a6SJiri Slaby { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, 161202fb72a0SDavid Herrmann { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) }, 161385cdaf52SJiri Slaby { } 161485cdaf52SJiri Slaby }; 161585cdaf52SJiri Slaby 16163a6f82f7SJiri Slaby struct hid_dynid { 16173a6f82f7SJiri Slaby struct list_head list; 16183a6f82f7SJiri Slaby struct hid_device_id id; 16193a6f82f7SJiri Slaby }; 16203a6f82f7SJiri Slaby 16213a6f82f7SJiri Slaby /** 16223a6f82f7SJiri Slaby * store_new_id - add a new HID device ID to this driver and re-probe devices 16233a6f82f7SJiri Slaby * @driver: target device driver 16243a6f82f7SJiri Slaby * @buf: buffer for scanning device ID data 16253a6f82f7SJiri Slaby * @count: input size 16263a6f82f7SJiri Slaby * 16273a6f82f7SJiri Slaby * Adds a new dynamic hid device ID to this driver, 16283a6f82f7SJiri Slaby * and causes the driver to probe for all devices again. 16293a6f82f7SJiri Slaby */ 16303a6f82f7SJiri Slaby static ssize_t store_new_id(struct device_driver *drv, const char *buf, 16313a6f82f7SJiri Slaby size_t count) 16323a6f82f7SJiri Slaby { 16333a6f82f7SJiri Slaby struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 16343a6f82f7SJiri Slaby struct hid_dynid *dynid; 16353a6f82f7SJiri Slaby __u32 bus, vendor, product; 16363a6f82f7SJiri Slaby unsigned long driver_data = 0; 16373a6f82f7SJiri Slaby int ret; 16383a6f82f7SJiri Slaby 16393a6f82f7SJiri Slaby ret = sscanf(buf, "%x %x %x %lx", 16403a6f82f7SJiri Slaby &bus, &vendor, &product, &driver_data); 16413a6f82f7SJiri Slaby if (ret < 3) 16423a6f82f7SJiri Slaby return -EINVAL; 16433a6f82f7SJiri Slaby 16443a6f82f7SJiri Slaby dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 16453a6f82f7SJiri Slaby if (!dynid) 16463a6f82f7SJiri Slaby return -ENOMEM; 16473a6f82f7SJiri Slaby 16483a6f82f7SJiri Slaby dynid->id.bus = bus; 16493a6f82f7SJiri Slaby dynid->id.vendor = vendor; 16503a6f82f7SJiri Slaby dynid->id.product = product; 16513a6f82f7SJiri Slaby dynid->id.driver_data = driver_data; 16523a6f82f7SJiri Slaby 16533a6f82f7SJiri Slaby spin_lock(&hdrv->dyn_lock); 16543a6f82f7SJiri Slaby list_add_tail(&dynid->list, &hdrv->dyn_list); 16553a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16563a6f82f7SJiri Slaby 16573a6f82f7SJiri Slaby ret = driver_attach(&hdrv->driver); 16583a6f82f7SJiri Slaby 16593a6f82f7SJiri Slaby return ret ? : count; 16603a6f82f7SJiri Slaby } 16613a6f82f7SJiri Slaby static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); 16623a6f82f7SJiri Slaby 16633a6f82f7SJiri Slaby static void hid_free_dynids(struct hid_driver *hdrv) 16643a6f82f7SJiri Slaby { 16653a6f82f7SJiri Slaby struct hid_dynid *dynid, *n; 16663a6f82f7SJiri Slaby 16673a6f82f7SJiri Slaby spin_lock(&hdrv->dyn_lock); 16683a6f82f7SJiri Slaby list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) { 16693a6f82f7SJiri Slaby list_del(&dynid->list); 16703a6f82f7SJiri Slaby kfree(dynid); 16713a6f82f7SJiri Slaby } 16723a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16733a6f82f7SJiri Slaby } 16743a6f82f7SJiri Slaby 16753a6f82f7SJiri Slaby static const struct hid_device_id *hid_match_device(struct hid_device *hdev, 16763a6f82f7SJiri Slaby struct hid_driver *hdrv) 16773a6f82f7SJiri Slaby { 16783a6f82f7SJiri Slaby struct hid_dynid *dynid; 16793a6f82f7SJiri Slaby 16803a6f82f7SJiri Slaby spin_lock(&hdrv->dyn_lock); 16813a6f82f7SJiri Slaby list_for_each_entry(dynid, &hdrv->dyn_list, list) { 16823a6f82f7SJiri Slaby if (hid_match_one_id(hdev, &dynid->id)) { 16833a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16843a6f82f7SJiri Slaby return &dynid->id; 16853a6f82f7SJiri Slaby } 16863a6f82f7SJiri Slaby } 16873a6f82f7SJiri Slaby spin_unlock(&hdrv->dyn_lock); 16883a6f82f7SJiri Slaby 16893a6f82f7SJiri Slaby return hid_match_id(hdev, hdrv->id_table); 16903a6f82f7SJiri Slaby } 16913a6f82f7SJiri Slaby 169285cdaf52SJiri Slaby static int hid_bus_match(struct device *dev, struct device_driver *drv) 169385cdaf52SJiri Slaby { 169485cdaf52SJiri Slaby struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 169585cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 169685cdaf52SJiri Slaby 16978d179a9eSBenjamin Tissoires if ((hdev->quirks & HID_QUIRK_MULTITOUCH) && 16988d179a9eSBenjamin Tissoires !strncmp(hdrv->name, "hid-multitouch", 14)) 16998d179a9eSBenjamin Tissoires return 1; 17008d179a9eSBenjamin Tissoires 17013a6f82f7SJiri Slaby if (!hid_match_device(hdev, hdrv)) 170285cdaf52SJiri Slaby return 0; 170385cdaf52SJiri Slaby 1704ce06b9d6SDmitry Torokhov /* generic wants all that don't have specialized driver */ 17056b1968d5SJiri Kosina if (!strncmp(hdrv->name, "generic-", 8) && !hid_ignore_special_drivers) 1706ce06b9d6SDmitry Torokhov return !hid_match_id(hdev, hid_have_special_driver); 170785cdaf52SJiri Slaby 170885cdaf52SJiri Slaby return 1; 170985cdaf52SJiri Slaby } 171085cdaf52SJiri Slaby 171185cdaf52SJiri Slaby static int hid_device_probe(struct device *dev) 171285cdaf52SJiri Slaby { 171385cdaf52SJiri Slaby struct hid_driver *hdrv = container_of(dev->driver, 171485cdaf52SJiri Slaby struct hid_driver, driver); 171585cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 171685cdaf52SJiri Slaby const struct hid_device_id *id; 171785cdaf52SJiri Slaby int ret = 0; 171885cdaf52SJiri Slaby 17194ea54542SDavid Herrmann if (down_interruptible(&hdev->driver_lock)) 17204ea54542SDavid Herrmann return -EINTR; 17214ea54542SDavid Herrmann 172285cdaf52SJiri Slaby if (!hdev->driver) { 17233a6f82f7SJiri Slaby id = hid_match_device(hdev, hdrv); 1724ba623a77SDan Carpenter if (id == NULL) { 17258d179a9eSBenjamin Tissoires if (!((hdev->quirks & HID_QUIRK_MULTITOUCH) && 17268d179a9eSBenjamin Tissoires !strncmp(hdrv->name, "hid-multitouch", 14))) { 1727ba623a77SDan Carpenter ret = -ENODEV; 1728ba623a77SDan Carpenter goto unlock; 1729ba623a77SDan Carpenter } 17308d179a9eSBenjamin Tissoires } 1731c500c971SJiri Slaby 173285cdaf52SJiri Slaby hdev->driver = hdrv; 1733c500c971SJiri Slaby if (hdrv->probe) { 1734c500c971SJiri Slaby ret = hdrv->probe(hdev, id); 1735c500c971SJiri Slaby } else { /* default probe */ 1736c500c971SJiri Slaby ret = hid_parse(hdev); 1737c500c971SJiri Slaby if (!ret) 173893c10132SJiri Slaby ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 1739c500c971SJiri Slaby } 1740c500c971SJiri Slaby if (ret) 1741c500c971SJiri Slaby hdev->driver = NULL; 174285cdaf52SJiri Slaby } 1743ba623a77SDan Carpenter unlock: 17444ea54542SDavid Herrmann up(&hdev->driver_lock); 174585cdaf52SJiri Slaby return ret; 174685cdaf52SJiri Slaby } 174785cdaf52SJiri Slaby 174885cdaf52SJiri Slaby static int hid_device_remove(struct device *dev) 174985cdaf52SJiri Slaby { 175085cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 17514ea54542SDavid Herrmann struct hid_driver *hdrv; 175285cdaf52SJiri Slaby 17534ea54542SDavid Herrmann if (down_interruptible(&hdev->driver_lock)) 17544ea54542SDavid Herrmann return -EINTR; 17554ea54542SDavid Herrmann 17564ea54542SDavid Herrmann hdrv = hdev->driver; 175785cdaf52SJiri Slaby if (hdrv) { 175885cdaf52SJiri Slaby if (hdrv->remove) 175985cdaf52SJiri Slaby hdrv->remove(hdev); 1760c500c971SJiri Slaby else /* default remove */ 1761c500c971SJiri Slaby hid_hw_stop(hdev); 176285cdaf52SJiri Slaby hdev->driver = NULL; 176385cdaf52SJiri Slaby } 176485cdaf52SJiri Slaby 17654ea54542SDavid Herrmann up(&hdev->driver_lock); 176685cdaf52SJiri Slaby return 0; 176785cdaf52SJiri Slaby } 176885cdaf52SJiri Slaby 176985cdaf52SJiri Slaby static int hid_uevent(struct device *dev, struct kobj_uevent_env *env) 177085cdaf52SJiri Slaby { 177185cdaf52SJiri Slaby struct hid_device *hdev = container_of(dev, struct hid_device, dev); 177285cdaf52SJiri Slaby 177385cdaf52SJiri Slaby if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", 177485cdaf52SJiri Slaby hdev->bus, hdev->vendor, hdev->product)) 177585cdaf52SJiri Slaby return -ENOMEM; 177685cdaf52SJiri Slaby 177785cdaf52SJiri Slaby if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) 177885cdaf52SJiri Slaby return -ENOMEM; 177985cdaf52SJiri Slaby 178085cdaf52SJiri Slaby if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) 178185cdaf52SJiri Slaby return -ENOMEM; 178285cdaf52SJiri Slaby 178385cdaf52SJiri Slaby if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) 178485cdaf52SJiri Slaby return -ENOMEM; 178585cdaf52SJiri Slaby 178685cdaf52SJiri Slaby if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X", 178785cdaf52SJiri Slaby hdev->bus, hdev->vendor, hdev->product)) 178885cdaf52SJiri Slaby return -ENOMEM; 178985cdaf52SJiri Slaby 179085cdaf52SJiri Slaby return 0; 179185cdaf52SJiri Slaby } 179285cdaf52SJiri Slaby 179385cdaf52SJiri Slaby static struct bus_type hid_bus_type = { 179485cdaf52SJiri Slaby .name = "hid", 179585cdaf52SJiri Slaby .match = hid_bus_match, 179685cdaf52SJiri Slaby .probe = hid_device_probe, 179785cdaf52SJiri Slaby .remove = hid_device_remove, 179885cdaf52SJiri Slaby .uevent = hid_uevent, 179985cdaf52SJiri Slaby }; 180085cdaf52SJiri Slaby 1801bae7eb33SJiri Kosina /* a list of devices that shouldn't be handled by HID core at all */ 1802d458a9dfSJiri Slaby static const struct hid_device_id hid_ignore_list[] = { 1803d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, 1804d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, 1805d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, 1806d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, 1807d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, 1808d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, 1809d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, 1810d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, 1811d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, 1812d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, 1813d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, 1814d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, 181577f720b7SStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)}, 181677f720b7SStephane Chatty { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)}, 181762a56582SAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, 1818d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, 1819d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, 1820d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, 1821d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, 1822d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, 1823d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, 18245f6108cfSAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) }, 1825d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, 1826d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 182773bc7d31SMelchior FRANZ { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) }, 1828789aaa2eSDan Delaney { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x000a) }, 1829d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 183070c66567SPetr Štetiar { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) }, 1831df506f2cSPetr Štetiar { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) }, 1832b1807719SBenjamin Tissoires { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, 1833d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 1834d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, 1835d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, 1836d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, 1837d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, 1838d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, 1839d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, 1840d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, 1841d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, 1842d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, 1843d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, 1844d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, 1845d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, 1846d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, 1847d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, 1848d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, 1849d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, 1850d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, 1851d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, 1852d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, 1853d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, 1854d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, 1855d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, 1856d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, 1857d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, 1858d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, 1859d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, 1860d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, 1861d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, 1862d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, 1863d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, 1864d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, 1865d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, 1866d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, 1867d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, 1868d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, 1869d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, 1870d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, 1871d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, 1872d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, 1873d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, 1874d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, 1875d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, 1876d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, 1877d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, 1878d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, 1879d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, 1880d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, 1881d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, 1882d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, 1883d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, 1884d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, 1885d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, 1886d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, 1887d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, 1888d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, 1889d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, 1890d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, 1891d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, 1892d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, 1893d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, 1894d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, 1895d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, 1896d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, 1897c91c21c5SAlexey Klimov { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, 1898d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, 1899eb8141ccSLamarque Vieira Souza { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) }, 1900d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, 1901ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) }, 1902d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, 1903ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) }, 1904d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, 1905ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) }, 1906ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) }, 1907ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) }, 1908ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, 1909ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, 1910ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, 1911d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, 1912d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, 1913d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, 1914ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) }, 1915ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) }, 1916ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) }, 1917d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, 1918d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, 1919ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) }, 1920d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, 1921d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, 1922d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, 1923d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, 1924d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, 1925ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) }, 1926ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) }, 1927ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) }, 1928ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) }, 1929ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) }, 1930ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) }, 1931ce97cac8SMichael Hund { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) }, 1932d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, 1933d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, 1934d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, 1935d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, 1936d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, 1937d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, 1938d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, 1939d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, 1940d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, 1941d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, 1942d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, 1943d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, 1944d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, 1945d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, 1946d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, 1947d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, 1948d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, 1949d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, 1950d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, 19514cfae3e8SHenning Glawe { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, 195235cfd1d9SMichael Tokarev { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, 1953d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, 1954d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 1955d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 1956d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 1957d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 1958d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, 1959d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, 1960d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, 1961d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, 1962d458a9dfSJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, 1963d458a9dfSJiri Slaby { } 1964d458a9dfSJiri Slaby }; 1965d458a9dfSJiri Slaby 1966b4d8e473SJiri Slaby /** 1967b4d8e473SJiri Slaby * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer 1968b4d8e473SJiri Slaby * 1969b4d8e473SJiri Slaby * There are composite devices for which we want to ignore only a certain 1970b4d8e473SJiri Slaby * interface. This is a list of devices for which only the mouse interface will 1971b4d8e473SJiri Slaby * be ignored. This allows a dedicated driver to take care of the interface. 1972b4d8e473SJiri Slaby */ 1973b4d8e473SJiri Slaby static const struct hid_device_id hid_mouse_ignore_list[] = { 1974b4d8e473SJiri Slaby /* appletouch driver */ 1975b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, 1976b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, 1977b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, 1978b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, 1979b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, 1980b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, 1981b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, 1982b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, 1983b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, 1984b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, 1985b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, 1986b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, 1987b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, 1988b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, 1989b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, 1990b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, 1991b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, 1992b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1993b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1994b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1995ac26fca3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, 1996ac26fca3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, 1997ac26fca3SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, 199899b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, 199999b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, 200099b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, 200199b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, 200299b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, 200399b9f758SEdgar (gimli) Hucek { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, 200447340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, 200547340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, 200647340bd9SAndy Botting { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, 2007213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) }, 2008213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) }, 2009213f9da8SGökçen Eraslan { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) }, 20104b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) }, 20114b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) }, 20124b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) }, 20134b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, 20144b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, 20154b086910SJiri Kosina { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, 2016b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 2017b4d8e473SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 2018b4d8e473SJiri Slaby { } 2019b4d8e473SJiri Slaby }; 2020b4d8e473SJiri Slaby 2021d458a9dfSJiri Slaby static bool hid_ignore(struct hid_device *hdev) 2022d458a9dfSJiri Slaby { 2023d458a9dfSJiri Slaby switch (hdev->vendor) { 2024d458a9dfSJiri Slaby case USB_VENDOR_ID_CODEMERCS: 2025d458a9dfSJiri Slaby /* ignore all Code Mercenaries IOWarrior devices */ 2026d458a9dfSJiri Slaby if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && 2027d458a9dfSJiri Slaby hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) 2028d458a9dfSJiri Slaby return true; 2029d458a9dfSJiri Slaby break; 2030d458a9dfSJiri Slaby case USB_VENDOR_ID_LOGITECH: 2031d458a9dfSJiri Slaby if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && 2032d458a9dfSJiri Slaby hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) 2033d458a9dfSJiri Slaby return true; 2034d458a9dfSJiri Slaby break; 203531f7fd79SJarod Wilson case USB_VENDOR_ID_SOUNDGRAPH: 203631f7fd79SJarod Wilson if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST && 203731f7fd79SJarod Wilson hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST) 203831f7fd79SJarod Wilson return true; 203931f7fd79SJarod Wilson break; 2040bba5394aSXing Wei case USB_VENDOR_ID_HANWANG: 2041bba5394aSXing Wei if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST && 2042bba5394aSXing Wei hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST) 2043bba5394aSXing Wei return true; 2044bba5394aSXing Wei break; 20456dc1418eSTomoki Sekiyama case USB_VENDOR_ID_JESS: 20466dc1418eSTomoki Sekiyama if (hdev->product == USB_DEVICE_ID_JESS_YUREX && 20476dc1418eSTomoki Sekiyama hdev->type == HID_TYPE_USBNONE) 20486dc1418eSTomoki Sekiyama return true; 20496dc1418eSTomoki Sekiyama break; 2050d458a9dfSJiri Slaby } 2051d458a9dfSJiri Slaby 2052b4d8e473SJiri Slaby if (hdev->type == HID_TYPE_USBMOUSE && 2053b4d8e473SJiri Slaby hid_match_id(hdev, hid_mouse_ignore_list)) 2054b4d8e473SJiri Slaby return true; 2055b4d8e473SJiri Slaby 2056d458a9dfSJiri Slaby return !!hid_match_id(hdev, hid_ignore_list); 2057d458a9dfSJiri Slaby } 2058d458a9dfSJiri Slaby 205985cdaf52SJiri Slaby int hid_add_device(struct hid_device *hdev) 206085cdaf52SJiri Slaby { 206185cdaf52SJiri Slaby static atomic_t id = ATOMIC_INIT(0); 206285cdaf52SJiri Slaby int ret; 206385cdaf52SJiri Slaby 206485cdaf52SJiri Slaby if (WARN_ON(hdev->status & HID_STAT_ADDED)) 206585cdaf52SJiri Slaby return -EBUSY; 206685cdaf52SJiri Slaby 2067d458a9dfSJiri Slaby /* we need to kill them here, otherwise they will stay allocated to 2068d458a9dfSJiri Slaby * wait for coming driver */ 2069e5a2a04cSJindrich Makovicka if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) 2070e5a2a04cSJindrich Makovicka && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE))) 2071d458a9dfSJiri Slaby return -ENODEV; 2072d458a9dfSJiri Slaby 20736bbe586fSKay Sievers /* XXX hack, any other cleaner solution after the driver core 20746bbe586fSKay Sievers * is converted to allow more than 20 bytes as the device name? */ 20756bbe586fSKay Sievers dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, 207685cdaf52SJiri Slaby hdev->vendor, hdev->product, atomic_inc_return(&id)); 207785cdaf52SJiri Slaby 20784da361b6SBruno Prémont hid_debug_register(hdev, dev_name(&hdev->dev)); 207985cdaf52SJiri Slaby ret = device_add(&hdev->dev); 208085cdaf52SJiri Slaby if (!ret) 208185cdaf52SJiri Slaby hdev->status |= HID_STAT_ADDED; 20824da361b6SBruno Prémont else 20834da361b6SBruno Prémont hid_debug_unregister(hdev); 2084a635f9ddSJiri Kosina 208585cdaf52SJiri Slaby return ret; 208685cdaf52SJiri Slaby } 208785cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_add_device); 208885cdaf52SJiri Slaby 208985cdaf52SJiri Slaby /** 209085cdaf52SJiri Slaby * hid_allocate_device - allocate new hid device descriptor 209185cdaf52SJiri Slaby * 209285cdaf52SJiri Slaby * Allocate and initialize hid device, so that hid_destroy_device might be 209385cdaf52SJiri Slaby * used to free it. 209485cdaf52SJiri Slaby * 209585cdaf52SJiri Slaby * New hid_device pointer is returned on success, otherwise ERR_PTR encoded 209685cdaf52SJiri Slaby * error value. 209785cdaf52SJiri Slaby */ 209885cdaf52SJiri Slaby struct hid_device *hid_allocate_device(void) 209985cdaf52SJiri Slaby { 210085cdaf52SJiri Slaby struct hid_device *hdev; 210185cdaf52SJiri Slaby unsigned int i; 210285cdaf52SJiri Slaby int ret = -ENOMEM; 210385cdaf52SJiri Slaby 210485cdaf52SJiri Slaby hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); 210585cdaf52SJiri Slaby if (hdev == NULL) 210685cdaf52SJiri Slaby return ERR_PTR(ret); 210785cdaf52SJiri Slaby 210885cdaf52SJiri Slaby device_initialize(&hdev->dev); 210985cdaf52SJiri Slaby hdev->dev.release = hid_device_release; 211085cdaf52SJiri Slaby hdev->dev.bus = &hid_bus_type; 211185cdaf52SJiri Slaby 211285cdaf52SJiri Slaby hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, 211385cdaf52SJiri Slaby sizeof(struct hid_collection), GFP_KERNEL); 211485cdaf52SJiri Slaby if (hdev->collection == NULL) 211585cdaf52SJiri Slaby goto err; 211685cdaf52SJiri Slaby hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS; 211785cdaf52SJiri Slaby 211885cdaf52SJiri Slaby for (i = 0; i < HID_REPORT_TYPES; i++) 211985cdaf52SJiri Slaby INIT_LIST_HEAD(&hdev->report_enum[i].report_list); 212085cdaf52SJiri Slaby 2121cd667ce2SJiri Kosina init_waitqueue_head(&hdev->debug_wait); 2122cd667ce2SJiri Kosina INIT_LIST_HEAD(&hdev->debug_list); 21234ea54542SDavid Herrmann sema_init(&hdev->driver_lock, 1); 2124cd667ce2SJiri Kosina 212585cdaf52SJiri Slaby return hdev; 212685cdaf52SJiri Slaby err: 212785cdaf52SJiri Slaby put_device(&hdev->dev); 212885cdaf52SJiri Slaby return ERR_PTR(ret); 212985cdaf52SJiri Slaby } 213085cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_allocate_device); 213185cdaf52SJiri Slaby 213285cdaf52SJiri Slaby static void hid_remove_device(struct hid_device *hdev) 213385cdaf52SJiri Slaby { 213485cdaf52SJiri Slaby if (hdev->status & HID_STAT_ADDED) { 213585cdaf52SJiri Slaby device_del(&hdev->dev); 2136a635f9ddSJiri Kosina hid_debug_unregister(hdev); 213785cdaf52SJiri Slaby hdev->status &= ~HID_STAT_ADDED; 213885cdaf52SJiri Slaby } 213985cdaf52SJiri Slaby } 214085cdaf52SJiri Slaby 214185cdaf52SJiri Slaby /** 214285cdaf52SJiri Slaby * hid_destroy_device - free previously allocated device 214385cdaf52SJiri Slaby * 214485cdaf52SJiri Slaby * @hdev: hid device 214585cdaf52SJiri Slaby * 214685cdaf52SJiri Slaby * If you allocate hid_device through hid_allocate_device, you should ever 214785cdaf52SJiri Slaby * free by this function. 214885cdaf52SJiri Slaby */ 214985cdaf52SJiri Slaby void hid_destroy_device(struct hid_device *hdev) 215085cdaf52SJiri Slaby { 215185cdaf52SJiri Slaby hid_remove_device(hdev); 215285cdaf52SJiri Slaby put_device(&hdev->dev); 215385cdaf52SJiri Slaby } 215485cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_destroy_device); 215585cdaf52SJiri Slaby 215685cdaf52SJiri Slaby int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, 215785cdaf52SJiri Slaby const char *mod_name) 215885cdaf52SJiri Slaby { 21593a6f82f7SJiri Slaby int ret; 21603a6f82f7SJiri Slaby 216185cdaf52SJiri Slaby hdrv->driver.name = hdrv->name; 216285cdaf52SJiri Slaby hdrv->driver.bus = &hid_bus_type; 216385cdaf52SJiri Slaby hdrv->driver.owner = owner; 216485cdaf52SJiri Slaby hdrv->driver.mod_name = mod_name; 216585cdaf52SJiri Slaby 21663a6f82f7SJiri Slaby INIT_LIST_HEAD(&hdrv->dyn_list); 21673a6f82f7SJiri Slaby spin_lock_init(&hdrv->dyn_lock); 21683a6f82f7SJiri Slaby 21693a6f82f7SJiri Slaby ret = driver_register(&hdrv->driver); 21703a6f82f7SJiri Slaby if (ret) 21713a6f82f7SJiri Slaby return ret; 21723a6f82f7SJiri Slaby 21733a6f82f7SJiri Slaby ret = driver_create_file(&hdrv->driver, &driver_attr_new_id); 21743a6f82f7SJiri Slaby if (ret) 21753a6f82f7SJiri Slaby driver_unregister(&hdrv->driver); 21763a6f82f7SJiri Slaby 21773a6f82f7SJiri Slaby return ret; 217885cdaf52SJiri Slaby } 217985cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(__hid_register_driver); 218085cdaf52SJiri Slaby 218185cdaf52SJiri Slaby void hid_unregister_driver(struct hid_driver *hdrv) 218285cdaf52SJiri Slaby { 21833a6f82f7SJiri Slaby driver_remove_file(&hdrv->driver, &driver_attr_new_id); 218485cdaf52SJiri Slaby driver_unregister(&hdrv->driver); 21853a6f82f7SJiri Slaby hid_free_dynids(hdrv); 218685cdaf52SJiri Slaby } 218785cdaf52SJiri Slaby EXPORT_SYMBOL_GPL(hid_unregister_driver); 218885cdaf52SJiri Slaby 21890361a28dSOliver Neukum int hid_check_keys_pressed(struct hid_device *hid) 21900361a28dSOliver Neukum { 21910361a28dSOliver Neukum struct hid_input *hidinput; 21920361a28dSOliver Neukum int i; 21930361a28dSOliver Neukum 2194e5288eb5SJiri Kosina if (!(hid->claimed & HID_CLAIMED_INPUT)) 2195e5288eb5SJiri Kosina return 0; 2196e5288eb5SJiri Kosina 21970361a28dSOliver Neukum list_for_each_entry(hidinput, &hid->inputs, list) { 21980361a28dSOliver Neukum for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++) 21990361a28dSOliver Neukum if (hidinput->input->key[i]) 22000361a28dSOliver Neukum return 1; 22010361a28dSOliver Neukum } 22020361a28dSOliver Neukum 22030361a28dSOliver Neukum return 0; 22040361a28dSOliver Neukum } 22050361a28dSOliver Neukum 22060361a28dSOliver Neukum EXPORT_SYMBOL_GPL(hid_check_keys_pressed); 22070361a28dSOliver Neukum 220886166b7bSJiri Kosina static int __init hid_init(void) 220986166b7bSJiri Kosina { 221085cdaf52SJiri Slaby int ret; 221185cdaf52SJiri Slaby 2212a635f9ddSJiri Kosina if (hid_debug) 22134291ee30SJoe Perches pr_warn("hid_debug is now used solely for parser and driver debugging.\n" 22144291ee30SJoe Perches "debugfs is now used for inspecting the device (report descriptor, reports)\n"); 2215a635f9ddSJiri Kosina 221685cdaf52SJiri Slaby ret = bus_register(&hid_bus_type); 221785cdaf52SJiri Slaby if (ret) { 22184291ee30SJoe Perches pr_err("can't register hid bus\n"); 221985cdaf52SJiri Slaby goto err; 222085cdaf52SJiri Slaby } 222185cdaf52SJiri Slaby 222285cdaf52SJiri Slaby ret = hidraw_init(); 222385cdaf52SJiri Slaby if (ret) 222485cdaf52SJiri Slaby goto err_bus; 222585cdaf52SJiri Slaby 2226a635f9ddSJiri Kosina hid_debug_init(); 2227a635f9ddSJiri Kosina 222885cdaf52SJiri Slaby return 0; 222985cdaf52SJiri Slaby err_bus: 223085cdaf52SJiri Slaby bus_unregister(&hid_bus_type); 223185cdaf52SJiri Slaby err: 223285cdaf52SJiri Slaby return ret; 223386166b7bSJiri Kosina } 223486166b7bSJiri Kosina 223586166b7bSJiri Kosina static void __exit hid_exit(void) 223686166b7bSJiri Kosina { 2237a635f9ddSJiri Kosina hid_debug_exit(); 223886166b7bSJiri Kosina hidraw_exit(); 223985cdaf52SJiri Slaby bus_unregister(&hid_bus_type); 224086166b7bSJiri Kosina } 224186166b7bSJiri Kosina 224286166b7bSJiri Kosina module_init(hid_init); 224386166b7bSJiri Kosina module_exit(hid_exit); 224486166b7bSJiri Kosina 224588adb72bSJiri Kosina MODULE_AUTHOR("Andreas Gal"); 224688adb72bSJiri Kosina MODULE_AUTHOR("Vojtech Pavlik"); 224788adb72bSJiri Kosina MODULE_AUTHOR("Jiri Kosina"); 2248aa938f79SJiri Kosina MODULE_LICENSE(DRIVER_LICENSE); 2249aa938f79SJiri Kosina 2250