hid-core.c 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871
  1. /*
  2. * HID support for Linux
  3. *
  4. * Copyright (c) 1999 Andreas Gal
  5. * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
  6. * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
  7. * Copyright (c) 2006-2012 Jiri Kosina
  8. */
  9. /*
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the Free
  12. * Software Foundation; either version 2 of the License, or (at your option)
  13. * any later version.
  14. */
  15. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  16. #include <linux/module.h>
  17. #include <linux/slab.h>
  18. #include <linux/init.h>
  19. #include <linux/kernel.h>
  20. #include <linux/list.h>
  21. #include <linux/mm.h>
  22. #include <linux/spinlock.h>
  23. #include <asm/unaligned.h>
  24. #include <asm/byteorder.h>
  25. #include <linux/input.h>
  26. #include <linux/wait.h>
  27. #include <linux/vmalloc.h>
  28. #include <linux/sched.h>
  29. #include <linux/semaphore.h>
  30. #include <linux/hid.h>
  31. #include <linux/hiddev.h>
  32. #include <linux/hid-debug.h>
  33. #include <linux/hidraw.h>
  34. #include "hid-ids.h"
  35. /*
  36. * Version Information
  37. */
  38. #define DRIVER_DESC "HID core driver"
  39. #define DRIVER_LICENSE "GPL"
  40. int hid_debug = 0;
  41. module_param_named(debug, hid_debug, int, 0600);
  42. MODULE_PARM_DESC(debug, "toggle HID debugging messages");
  43. EXPORT_SYMBOL_GPL(hid_debug);
  44. static int hid_ignore_special_drivers = 0;
  45. module_param_named(ignore_special_drivers, hid_ignore_special_drivers, int, 0600);
  46. MODULE_PARM_DESC(ignore_special_drivers, "Ignore any special drivers and handle all devices by generic driver");
  47. /*
  48. * Register a new report for a device.
  49. */
  50. struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id)
  51. {
  52. struct hid_report_enum *report_enum = device->report_enum + type;
  53. struct hid_report *report;
  54. if (id >= HID_MAX_IDS)
  55. return NULL;
  56. if (report_enum->report_id_hash[id])
  57. return report_enum->report_id_hash[id];
  58. report = kzalloc(sizeof(struct hid_report), GFP_KERNEL);
  59. if (!report)
  60. return NULL;
  61. if (id != 0)
  62. report_enum->numbered = 1;
  63. report->id = id;
  64. report->type = type;
  65. report->size = 0;
  66. report->device = device;
  67. report_enum->report_id_hash[id] = report;
  68. list_add_tail(&report->list, &report_enum->report_list);
  69. return report;
  70. }
  71. EXPORT_SYMBOL_GPL(hid_register_report);
  72. /*
  73. * Register a new field for this report.
  74. */
  75. static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
  76. {
  77. struct hid_field *field;
  78. if (report->maxfield == HID_MAX_FIELDS) {
  79. hid_err(report->device, "too many fields in report\n");
  80. return NULL;
  81. }
  82. field = kzalloc((sizeof(struct hid_field) +
  83. usages * sizeof(struct hid_usage) +
  84. values * sizeof(unsigned)), GFP_KERNEL);
  85. if (!field)
  86. return NULL;
  87. field->index = report->maxfield++;
  88. report->field[field->index] = field;
  89. field->usage = (struct hid_usage *)(field + 1);
  90. field->value = (s32 *)(field->usage + usages);
  91. field->report = report;
  92. return field;
  93. }
  94. /*
  95. * Open a collection. The type/usage is pushed on the stack.
  96. */
  97. static int open_collection(struct hid_parser *parser, unsigned type)
  98. {
  99. struct hid_collection *collection;
  100. unsigned usage;
  101. usage = parser->local.usage[0];
  102. if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) {
  103. hid_err(parser->device, "collection stack overflow\n");
  104. return -EINVAL;
  105. }
  106. if (parser->device->maxcollection == parser->device->collection_size) {
  107. collection = kmalloc(sizeof(struct hid_collection) *
  108. parser->device->collection_size * 2, GFP_KERNEL);
  109. if (collection == NULL) {
  110. hid_err(parser->device, "failed to reallocate collection array\n");
  111. return -ENOMEM;
  112. }
  113. memcpy(collection, parser->device->collection,
  114. sizeof(struct hid_collection) *
  115. parser->device->collection_size);
  116. memset(collection + parser->device->collection_size, 0,
  117. sizeof(struct hid_collection) *
  118. parser->device->collection_size);
  119. kfree(parser->device->collection);
  120. parser->device->collection = collection;
  121. parser->device->collection_size *= 2;
  122. }
  123. parser->collection_stack[parser->collection_stack_ptr++] =
  124. parser->device->maxcollection;
  125. collection = parser->device->collection +
  126. parser->device->maxcollection++;
  127. collection->type = type;
  128. collection->usage = usage;
  129. collection->level = parser->collection_stack_ptr - 1;
  130. if (type == HID_COLLECTION_APPLICATION)
  131. parser->device->maxapplication++;
  132. return 0;
  133. }
  134. /*
  135. * Close a collection.
  136. */
  137. static int close_collection(struct hid_parser *parser)
  138. {
  139. if (!parser->collection_stack_ptr) {
  140. hid_err(parser->device, "collection stack underflow\n");
  141. return -EINVAL;
  142. }
  143. parser->collection_stack_ptr--;
  144. return 0;
  145. }
  146. /*
  147. * Climb up the stack, search for the specified collection type
  148. * and return the usage.
  149. */
  150. static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
  151. {
  152. struct hid_collection *collection = parser->device->collection;
  153. int n;
  154. for (n = parser->collection_stack_ptr - 1; n >= 0; n--) {
  155. unsigned index = parser->collection_stack[n];
  156. if (collection[index].type == type)
  157. return collection[index].usage;
  158. }
  159. return 0; /* we know nothing about this usage type */
  160. }
  161. /*
  162. * Add a usage to the temporary parser table.
  163. */
  164. static int hid_add_usage(struct hid_parser *parser, unsigned usage)
  165. {
  166. if (parser->local.usage_index >= HID_MAX_USAGES) {
  167. hid_err(parser->device, "usage index exceeded\n");
  168. return -1;
  169. }
  170. parser->local.usage[parser->local.usage_index] = usage;
  171. parser->local.collection_index[parser->local.usage_index] =
  172. parser->collection_stack_ptr ?
  173. parser->collection_stack[parser->collection_stack_ptr - 1] : 0;
  174. parser->local.usage_index++;
  175. return 0;
  176. }
  177. /*
  178. * Register a new field for this report.
  179. */
  180. static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags)
  181. {
  182. struct hid_report *report;
  183. struct hid_field *field;
  184. unsigned usages;
  185. unsigned offset;
  186. unsigned i;
  187. report = hid_register_report(parser->device, report_type, parser->global.report_id);
  188. if (!report) {
  189. hid_err(parser->device, "hid_register_report failed\n");
  190. return -1;
  191. }
  192. /* Handle both signed and unsigned cases properly */
  193. if ((parser->global.logical_minimum < 0 &&
  194. parser->global.logical_maximum <
  195. parser->global.logical_minimum) ||
  196. (parser->global.logical_minimum >= 0 &&
  197. (__u32)parser->global.logical_maximum <
  198. (__u32)parser->global.logical_minimum)) {
  199. dbg_hid("logical range invalid 0x%x 0x%x\n",
  200. parser->global.logical_minimum,
  201. parser->global.logical_maximum);
  202. return -1;
  203. }
  204. offset = report->size;
  205. report->size += parser->global.report_size * parser->global.report_count;
  206. if (!parser->local.usage_index) /* Ignore padding fields */
  207. return 0;
  208. usages = max_t(unsigned, parser->local.usage_index,
  209. parser->global.report_count);
  210. field = hid_register_field(report, usages, parser->global.report_count);
  211. if (!field)
  212. return 0;
  213. field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL);
  214. field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL);
  215. field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION);
  216. for (i = 0; i < usages; i++) {
  217. unsigned j = i;
  218. /* Duplicate the last usage we parsed if we have excess values */
  219. if (i >= parser->local.usage_index)
  220. j = parser->local.usage_index - 1;
  221. field->usage[i].hid = parser->local.usage[j];
  222. field->usage[i].collection_index =
  223. parser->local.collection_index[j];
  224. field->usage[i].usage_index = i;
  225. }
  226. field->maxusage = usages;
  227. field->flags = flags;
  228. field->report_offset = offset;
  229. field->report_type = report_type;
  230. field->report_size = parser->global.report_size;
  231. field->report_count = parser->global.report_count;
  232. field->logical_minimum = parser->global.logical_minimum;
  233. field->logical_maximum = parser->global.logical_maximum;
  234. field->physical_minimum = parser->global.physical_minimum;
  235. field->physical_maximum = parser->global.physical_maximum;
  236. field->unit_exponent = parser->global.unit_exponent;
  237. field->unit = parser->global.unit;
  238. return 0;
  239. }
  240. /*
  241. * Read data value from item.
  242. */
  243. static u32 item_udata(struct hid_item *item)
  244. {
  245. switch (item->size) {
  246. case 1: return item->data.u8;
  247. case 2: return item->data.u16;
  248. case 4: return item->data.u32;
  249. }
  250. return 0;
  251. }
  252. static s32 item_sdata(struct hid_item *item)
  253. {
  254. switch (item->size) {
  255. case 1: return item->data.s8;
  256. case 2: return item->data.s16;
  257. case 4: return item->data.s32;
  258. }
  259. return 0;
  260. }
  261. /*
  262. * Process a global item.
  263. */
  264. static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
  265. {
  266. __s32 raw_value;
  267. switch (item->tag) {
  268. case HID_GLOBAL_ITEM_TAG_PUSH:
  269. if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) {
  270. hid_err(parser->device, "global environment stack overflow\n");
  271. return -1;
  272. }
  273. memcpy(parser->global_stack + parser->global_stack_ptr++,
  274. &parser->global, sizeof(struct hid_global));
  275. return 0;
  276. case HID_GLOBAL_ITEM_TAG_POP:
  277. if (!parser->global_stack_ptr) {
  278. hid_err(parser->device, "global environment stack underflow\n");
  279. return -1;
  280. }
  281. memcpy(&parser->global, parser->global_stack +
  282. --parser->global_stack_ptr, sizeof(struct hid_global));
  283. return 0;
  284. case HID_GLOBAL_ITEM_TAG_USAGE_PAGE:
  285. parser->global.usage_page = item_udata(item);
  286. return 0;
  287. case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM:
  288. parser->global.logical_minimum = item_sdata(item);
  289. return 0;
  290. case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM:
  291. if (parser->global.logical_minimum < 0)
  292. parser->global.logical_maximum = item_sdata(item);
  293. else
  294. parser->global.logical_maximum = item_udata(item);
  295. return 0;
  296. case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM:
  297. parser->global.physical_minimum = item_sdata(item);
  298. return 0;
  299. case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM:
  300. if (parser->global.physical_minimum < 0)
  301. parser->global.physical_maximum = item_sdata(item);
  302. else
  303. parser->global.physical_maximum = item_udata(item);
  304. return 0;
  305. case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT:
  306. /* Many devices provide unit exponent as a two's complement
  307. * nibble due to the common misunderstanding of HID
  308. * specification 1.11, 6.2.2.7 Global Items. Attempt to handle
  309. * both this and the standard encoding. */
  310. raw_value = item_sdata(item);
  311. if (!(raw_value & 0xfffffff0))
  312. parser->global.unit_exponent = hid_snto32(raw_value, 4);
  313. else
  314. parser->global.unit_exponent = raw_value;
  315. return 0;
  316. case HID_GLOBAL_ITEM_TAG_UNIT:
  317. parser->global.unit = item_udata(item);
  318. return 0;
  319. case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
  320. parser->global.report_size = item_udata(item);
  321. if (parser->global.report_size > 128) {
  322. hid_err(parser->device, "invalid report_size %d\n",
  323. parser->global.report_size);
  324. return -1;
  325. }
  326. return 0;
  327. case HID_GLOBAL_ITEM_TAG_REPORT_COUNT:
  328. parser->global.report_count = item_udata(item);
  329. if (parser->global.report_count > HID_MAX_USAGES) {
  330. hid_err(parser->device, "invalid report_count %d\n",
  331. parser->global.report_count);
  332. return -1;
  333. }
  334. return 0;
  335. case HID_GLOBAL_ITEM_TAG_REPORT_ID:
  336. parser->global.report_id = item_udata(item);
  337. if (parser->global.report_id == 0 ||
  338. parser->global.report_id >= HID_MAX_IDS) {
  339. hid_err(parser->device, "report_id %u is invalid\n",
  340. parser->global.report_id);
  341. return -1;
  342. }
  343. return 0;
  344. default:
  345. hid_err(parser->device, "unknown global tag 0x%x\n", item->tag);
  346. return -1;
  347. }
  348. }
  349. /*
  350. * Process a local item.
  351. */
  352. static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
  353. {
  354. __u32 data;
  355. unsigned n;
  356. __u32 count;
  357. data = item_udata(item);
  358. switch (item->tag) {
  359. case HID_LOCAL_ITEM_TAG_DELIMITER:
  360. if (data) {
  361. /*
  362. * We treat items before the first delimiter
  363. * as global to all usage sets (branch 0).
  364. * In the moment we process only these global
  365. * items and the first delimiter set.
  366. */
  367. if (parser->local.delimiter_depth != 0) {
  368. hid_err(parser->device, "nested delimiters\n");
  369. return -1;
  370. }
  371. parser->local.delimiter_depth++;
  372. parser->local.delimiter_branch++;
  373. } else {
  374. if (parser->local.delimiter_depth < 1) {
  375. hid_err(parser->device, "bogus close delimiter\n");
  376. return -1;
  377. }
  378. parser->local.delimiter_depth--;
  379. }
  380. return 0;
  381. case HID_LOCAL_ITEM_TAG_USAGE:
  382. if (parser->local.delimiter_branch > 1) {
  383. dbg_hid("alternative usage ignored\n");
  384. return 0;
  385. }
  386. if (item->size <= 2)
  387. data = (parser->global.usage_page << 16) + data;
  388. return hid_add_usage(parser, data);
  389. case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
  390. if (parser->local.delimiter_branch > 1) {
  391. dbg_hid("alternative usage ignored\n");
  392. return 0;
  393. }
  394. if (item->size <= 2)
  395. data = (parser->global.usage_page << 16) + data;
  396. parser->local.usage_minimum = data;
  397. return 0;
  398. case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
  399. if (parser->local.delimiter_branch > 1) {
  400. dbg_hid("alternative usage ignored\n");
  401. return 0;
  402. }
  403. if (item->size <= 2)
  404. data = (parser->global.usage_page << 16) + data;
  405. count = data - parser->local.usage_minimum;
  406. if (count + parser->local.usage_index >= HID_MAX_USAGES) {
  407. /*
  408. * We do not warn if the name is not set, we are
  409. * actually pre-scanning the device.
  410. */
  411. if (dev_name(&parser->device->dev))
  412. hid_warn(parser->device,
  413. "ignoring exceeding usage max\n");
  414. data = HID_MAX_USAGES - parser->local.usage_index +
  415. parser->local.usage_minimum - 1;
  416. if (data <= 0) {
  417. hid_err(parser->device,
  418. "no more usage index available\n");
  419. return -1;
  420. }
  421. }
  422. for (n = parser->local.usage_minimum; n <= data; n++)
  423. if (hid_add_usage(parser, n)) {
  424. dbg_hid("hid_add_usage failed\n");
  425. return -1;
  426. }
  427. return 0;
  428. default:
  429. dbg_hid("unknown local item tag 0x%x\n", item->tag);
  430. return 0;
  431. }
  432. return 0;
  433. }
  434. /*
  435. * Process a main item.
  436. */
  437. static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
  438. {
  439. __u32 data;
  440. int ret;
  441. data = item_udata(item);
  442. switch (item->tag) {
  443. case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION:
  444. ret = open_collection(parser, data & 0xff);
  445. break;
  446. case HID_MAIN_ITEM_TAG_END_COLLECTION:
  447. ret = close_collection(parser);
  448. break;
  449. case HID_MAIN_ITEM_TAG_INPUT:
  450. ret = hid_add_field(parser, HID_INPUT_REPORT, data);
  451. break;
  452. case HID_MAIN_ITEM_TAG_OUTPUT:
  453. ret = hid_add_field(parser, HID_OUTPUT_REPORT, data);
  454. break;
  455. case HID_MAIN_ITEM_TAG_FEATURE:
  456. ret = hid_add_field(parser, HID_FEATURE_REPORT, data);
  457. break;
  458. default:
  459. hid_err(parser->device, "unknown main item tag 0x%x\n", item->tag);
  460. ret = 0;
  461. }
  462. memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */
  463. return ret;
  464. }
  465. /*
  466. * Process a reserved item.
  467. */
  468. static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item)
  469. {
  470. dbg_hid("reserved item type, tag 0x%x\n", item->tag);
  471. return 0;
  472. }
  473. /*
  474. * Free a report and all registered fields. The field->usage and
  475. * field->value table's are allocated behind the field, so we need
  476. * only to free(field) itself.
  477. */
  478. static void hid_free_report(struct hid_report *report)
  479. {
  480. unsigned n;
  481. for (n = 0; n < report->maxfield; n++)
  482. kfree(report->field[n]);
  483. kfree(report);
  484. }
  485. /*
  486. * Close report. This function returns the device
  487. * state to the point prior to hid_open_report().
  488. */
  489. static void hid_close_report(struct hid_device *device)
  490. {
  491. unsigned i, j;
  492. for (i = 0; i < HID_REPORT_TYPES; i++) {
  493. struct hid_report_enum *report_enum = device->report_enum + i;
  494. for (j = 0; j < HID_MAX_IDS; j++) {
  495. struct hid_report *report = report_enum->report_id_hash[j];
  496. if (report)
  497. hid_free_report(report);
  498. }
  499. memset(report_enum, 0, sizeof(*report_enum));
  500. INIT_LIST_HEAD(&report_enum->report_list);
  501. }
  502. kfree(device->rdesc);
  503. device->rdesc = NULL;
  504. device->rsize = 0;
  505. kfree(device->collection);
  506. device->collection = NULL;
  507. device->collection_size = 0;
  508. device->maxcollection = 0;
  509. device->maxapplication = 0;
  510. device->status &= ~HID_STAT_PARSED;
  511. }
  512. /*
  513. * Free a device structure, all reports, and all fields.
  514. */
  515. static void hid_device_release(struct device *dev)
  516. {
  517. struct hid_device *hid = to_hid_device(dev);
  518. hid_close_report(hid);
  519. kfree(hid->dev_rdesc);
  520. kfree(hid);
  521. }
  522. /*
  523. * Fetch a report description item from the data stream. We support long
  524. * items, though they are not used yet.
  525. */
  526. static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
  527. {
  528. u8 b;
  529. if ((end - start) <= 0)
  530. return NULL;
  531. b = *start++;
  532. item->type = (b >> 2) & 3;
  533. item->tag = (b >> 4) & 15;
  534. if (item->tag == HID_ITEM_TAG_LONG) {
  535. item->format = HID_ITEM_FORMAT_LONG;
  536. if ((end - start) < 2)
  537. return NULL;
  538. item->size = *start++;
  539. item->tag = *start++;
  540. if ((end - start) < item->size)
  541. return NULL;
  542. item->data.longdata = start;
  543. start += item->size;
  544. return start;
  545. }
  546. item->format = HID_ITEM_FORMAT_SHORT;
  547. item->size = b & 3;
  548. switch (item->size) {
  549. case 0:
  550. return start;
  551. case 1:
  552. if ((end - start) < 1)
  553. return NULL;
  554. item->data.u8 = *start++;
  555. return start;
  556. case 2:
  557. if ((end - start) < 2)
  558. return NULL;
  559. item->data.u16 = get_unaligned_le16(start);
  560. start = (__u8 *)((__le16 *)start + 1);
  561. return start;
  562. case 3:
  563. item->size++;
  564. if ((end - start) < 4)
  565. return NULL;
  566. item->data.u32 = get_unaligned_le32(start);
  567. start = (__u8 *)((__le32 *)start + 1);
  568. return start;
  569. }
  570. return NULL;
  571. }
  572. static void hid_scan_input_usage(struct hid_parser *parser, u32 usage)
  573. {
  574. struct hid_device *hid = parser->device;
  575. if (usage == HID_DG_CONTACTID)
  576. hid->group = HID_GROUP_MULTITOUCH;
  577. }
  578. static void hid_scan_feature_usage(struct hid_parser *parser, u32 usage)
  579. {
  580. if (usage == 0xff0000c5 && parser->global.report_count == 256 &&
  581. parser->global.report_size == 8)
  582. parser->scan_flags |= HID_SCAN_FLAG_MT_WIN_8;
  583. }
  584. static void hid_scan_collection(struct hid_parser *parser, unsigned type)
  585. {
  586. struct hid_device *hid = parser->device;
  587. int i;
  588. if (((parser->global.usage_page << 16) == HID_UP_SENSOR) &&
  589. type == HID_COLLECTION_PHYSICAL)
  590. hid->group = HID_GROUP_SENSOR_HUB;
  591. if (hid->vendor == USB_VENDOR_ID_MICROSOFT &&
  592. (hid->product == USB_DEVICE_ID_MS_TYPE_COVER_PRO_3 ||
  593. hid->product == USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_2 ||
  594. hid->product == USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP ||
  595. hid->product == USB_DEVICE_ID_MS_TYPE_COVER_PRO_4 ||
  596. hid->product == USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_2 ||
  597. hid->product == USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_JP ||
  598. hid->product == USB_DEVICE_ID_MS_POWER_COVER) &&
  599. hid->group == HID_GROUP_MULTITOUCH)
  600. hid->group = HID_GROUP_GENERIC;
  601. if ((parser->global.usage_page << 16) == HID_UP_GENDESK)
  602. for (i = 0; i < parser->local.usage_index; i++)
  603. if (parser->local.usage[i] == HID_GD_POINTER)
  604. parser->scan_flags |= HID_SCAN_FLAG_GD_POINTER;
  605. if ((parser->global.usage_page << 16) >= HID_UP_MSVENDOR)
  606. parser->scan_flags |= HID_SCAN_FLAG_VENDOR_SPECIFIC;
  607. }
  608. static int hid_scan_main(struct hid_parser *parser, struct hid_item *item)
  609. {
  610. __u32 data;
  611. int i;
  612. data = item_udata(item);
  613. switch (item->tag) {
  614. case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION:
  615. hid_scan_collection(parser, data & 0xff);
  616. break;
  617. case HID_MAIN_ITEM_TAG_END_COLLECTION:
  618. break;
  619. case HID_MAIN_ITEM_TAG_INPUT:
  620. /* ignore constant inputs, they will be ignored by hid-input */
  621. if (data & HID_MAIN_ITEM_CONSTANT)
  622. break;
  623. for (i = 0; i < parser->local.usage_index; i++)
  624. hid_scan_input_usage(parser, parser->local.usage[i]);
  625. break;
  626. case HID_MAIN_ITEM_TAG_OUTPUT:
  627. break;
  628. case HID_MAIN_ITEM_TAG_FEATURE:
  629. for (i = 0; i < parser->local.usage_index; i++)
  630. hid_scan_feature_usage(parser, parser->local.usage[i]);
  631. break;
  632. }
  633. /* Reset the local parser environment */
  634. memset(&parser->local, 0, sizeof(parser->local));
  635. return 0;
  636. }
  637. /*
  638. * Scan a report descriptor before the device is added to the bus.
  639. * Sets device groups and other properties that determine what driver
  640. * to load.
  641. */
  642. static int hid_scan_report(struct hid_device *hid)
  643. {
  644. struct hid_parser *parser;
  645. struct hid_item item;
  646. __u8 *start = hid->dev_rdesc;
  647. __u8 *end = start + hid->dev_rsize;
  648. static int (*dispatch_type[])(struct hid_parser *parser,
  649. struct hid_item *item) = {
  650. hid_scan_main,
  651. hid_parser_global,
  652. hid_parser_local,
  653. hid_parser_reserved
  654. };
  655. parser = vzalloc(sizeof(struct hid_parser));
  656. if (!parser)
  657. return -ENOMEM;
  658. parser->device = hid;
  659. hid->group = HID_GROUP_GENERIC;
  660. /*
  661. * The parsing is simpler than the one in hid_open_report() as we should
  662. * be robust against hid errors. Those errors will be raised by
  663. * hid_open_report() anyway.
  664. */
  665. while ((start = fetch_item(start, end, &item)) != NULL)
  666. dispatch_type[item.type](parser, &item);
  667. /*
  668. * Handle special flags set during scanning.
  669. */
  670. if ((parser->scan_flags & HID_SCAN_FLAG_MT_WIN_8) &&
  671. (hid->group == HID_GROUP_MULTITOUCH))
  672. hid->group = HID_GROUP_MULTITOUCH_WIN_8;
  673. /*
  674. * Vendor specific handlings
  675. */
  676. switch (hid->vendor) {
  677. case USB_VENDOR_ID_WACOM:
  678. hid->group = HID_GROUP_WACOM;
  679. break;
  680. case USB_VENDOR_ID_SYNAPTICS:
  681. if (hid->group == HID_GROUP_GENERIC)
  682. if ((parser->scan_flags & HID_SCAN_FLAG_VENDOR_SPECIFIC)
  683. && (parser->scan_flags & HID_SCAN_FLAG_GD_POINTER))
  684. /*
  685. * hid-rmi should take care of them,
  686. * not hid-generic
  687. */
  688. hid->group = HID_GROUP_RMI;
  689. break;
  690. }
  691. vfree(parser);
  692. return 0;
  693. }
  694. /**
  695. * hid_parse_report - parse device report
  696. *
  697. * @device: hid device
  698. * @start: report start
  699. * @size: report size
  700. *
  701. * Allocate the device report as read by the bus driver. This function should
  702. * only be called from parse() in ll drivers.
  703. */
  704. int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size)
  705. {
  706. hid->dev_rdesc = kmemdup(start, size, GFP_KERNEL);
  707. if (!hid->dev_rdesc)
  708. return -ENOMEM;
  709. hid->dev_rsize = size;
  710. return 0;
  711. }
  712. EXPORT_SYMBOL_GPL(hid_parse_report);
  713. static const char * const hid_report_names[] = {
  714. "HID_INPUT_REPORT",
  715. "HID_OUTPUT_REPORT",
  716. "HID_FEATURE_REPORT",
  717. };
  718. /**
  719. * hid_validate_values - validate existing device report's value indexes
  720. *
  721. * @device: hid device
  722. * @type: which report type to examine
  723. * @id: which report ID to examine (0 for first)
  724. * @field_index: which report field to examine
  725. * @report_counts: expected number of values
  726. *
  727. * Validate the number of values in a given field of a given report, after
  728. * parsing.
  729. */
  730. struct hid_report *hid_validate_values(struct hid_device *hid,
  731. unsigned int type, unsigned int id,
  732. unsigned int field_index,
  733. unsigned int report_counts)
  734. {
  735. struct hid_report *report;
  736. if (type > HID_FEATURE_REPORT) {
  737. hid_err(hid, "invalid HID report type %u\n", type);
  738. return NULL;
  739. }
  740. if (id >= HID_MAX_IDS) {
  741. hid_err(hid, "invalid HID report id %u\n", id);
  742. return NULL;
  743. }
  744. /*
  745. * Explicitly not using hid_get_report() here since it depends on
  746. * ->numbered being checked, which may not always be the case when
  747. * drivers go to access report values.
  748. */
  749. if (id == 0) {
  750. /*
  751. * Validating on id 0 means we should examine the first
  752. * report in the list.
  753. */
  754. report = list_entry(
  755. hid->report_enum[type].report_list.next,
  756. struct hid_report, list);
  757. } else {
  758. report = hid->report_enum[type].report_id_hash[id];
  759. }
  760. if (!report) {
  761. hid_err(hid, "missing %s %u\n", hid_report_names[type], id);
  762. return NULL;
  763. }
  764. if (report->maxfield <= field_index) {
  765. hid_err(hid, "not enough fields in %s %u\n",
  766. hid_report_names[type], id);
  767. return NULL;
  768. }
  769. if (report->field[field_index]->report_count < report_counts) {
  770. hid_err(hid, "not enough values in %s %u field %u\n",
  771. hid_report_names[type], id, field_index);
  772. return NULL;
  773. }
  774. return report;
  775. }
  776. EXPORT_SYMBOL_GPL(hid_validate_values);
  777. /**
  778. * hid_open_report - open a driver-specific device report
  779. *
  780. * @device: hid device
  781. *
  782. * Parse a report description into a hid_device structure. Reports are
  783. * enumerated, fields are attached to these reports.
  784. * 0 returned on success, otherwise nonzero error value.
  785. *
  786. * This function (or the equivalent hid_parse() macro) should only be
  787. * called from probe() in drivers, before starting the device.
  788. */
  789. int hid_open_report(struct hid_device *device)
  790. {
  791. struct hid_parser *parser;
  792. struct hid_item item;
  793. unsigned int size;
  794. __u8 *start;
  795. __u8 *buf;
  796. __u8 *end;
  797. int ret;
  798. static int (*dispatch_type[])(struct hid_parser *parser,
  799. struct hid_item *item) = {
  800. hid_parser_main,
  801. hid_parser_global,
  802. hid_parser_local,
  803. hid_parser_reserved
  804. };
  805. if (WARN_ON(device->status & HID_STAT_PARSED))
  806. return -EBUSY;
  807. start = device->dev_rdesc;
  808. if (WARN_ON(!start))
  809. return -ENODEV;
  810. size = device->dev_rsize;
  811. buf = kmemdup(start, size, GFP_KERNEL);
  812. if (buf == NULL)
  813. return -ENOMEM;
  814. if (device->driver->report_fixup)
  815. start = device->driver->report_fixup(device, buf, &size);
  816. else
  817. start = buf;
  818. start = kmemdup(start, size, GFP_KERNEL);
  819. kfree(buf);
  820. if (start == NULL)
  821. return -ENOMEM;
  822. device->rdesc = start;
  823. device->rsize = size;
  824. parser = vzalloc(sizeof(struct hid_parser));
  825. if (!parser) {
  826. ret = -ENOMEM;
  827. goto err;
  828. }
  829. parser->device = device;
  830. end = start + size;
  831. device->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS,
  832. sizeof(struct hid_collection), GFP_KERNEL);
  833. if (!device->collection) {
  834. ret = -ENOMEM;
  835. goto err;
  836. }
  837. device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
  838. ret = -EINVAL;
  839. while ((start = fetch_item(start, end, &item)) != NULL) {
  840. if (item.format != HID_ITEM_FORMAT_SHORT) {
  841. hid_err(device, "unexpected long global item\n");
  842. goto err;
  843. }
  844. if (dispatch_type[item.type](parser, &item)) {
  845. hid_err(device, "item %u %u %u %u parsing failed\n",
  846. item.format, (unsigned)item.size,
  847. (unsigned)item.type, (unsigned)item.tag);
  848. goto err;
  849. }
  850. if (start == end) {
  851. if (parser->collection_stack_ptr) {
  852. hid_err(device, "unbalanced collection at end of report description\n");
  853. goto err;
  854. }
  855. if (parser->local.delimiter_depth) {
  856. hid_err(device, "unbalanced delimiter at end of report description\n");
  857. goto err;
  858. }
  859. vfree(parser);
  860. device->status |= HID_STAT_PARSED;
  861. return 0;
  862. }
  863. }
  864. hid_err(device, "item fetching failed at offset %d\n", (int)(end - start));
  865. err:
  866. vfree(parser);
  867. hid_close_report(device);
  868. return ret;
  869. }
  870. EXPORT_SYMBOL_GPL(hid_open_report);
  871. /*
  872. * Convert a signed n-bit integer to signed 32-bit integer. Common
  873. * cases are done through the compiler, the screwed things has to be
  874. * done by hand.
  875. */
  876. static s32 snto32(__u32 value, unsigned n)
  877. {
  878. switch (n) {
  879. case 8: return ((__s8)value);
  880. case 16: return ((__s16)value);
  881. case 32: return ((__s32)value);
  882. }
  883. return value & (1 << (n - 1)) ? value | (-1 << n) : value;
  884. }
  885. s32 hid_snto32(__u32 value, unsigned n)
  886. {
  887. return snto32(value, n);
  888. }
  889. EXPORT_SYMBOL_GPL(hid_snto32);
  890. /*
  891. * Convert a signed 32-bit integer to a signed n-bit integer.
  892. */
  893. static u32 s32ton(__s32 value, unsigned n)
  894. {
  895. s32 a = value >> (n - 1);
  896. if (a && a != -1)
  897. return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
  898. return value & ((1 << n) - 1);
  899. }
  900. /*
  901. * Extract/implement a data field from/to a little endian report (bit array).
  902. *
  903. * Code sort-of follows HID spec:
  904. * http://www.usb.org/developers/hidpage/HID1_11.pdf
  905. *
  906. * While the USB HID spec allows unlimited length bit fields in "report
  907. * descriptors", most devices never use more than 16 bits.
  908. * One model of UPS is claimed to report "LINEV" as a 32-bit field.
  909. * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
  910. */
  911. static u32 __extract(u8 *report, unsigned offset, int n)
  912. {
  913. unsigned int idx = offset / 8;
  914. unsigned int bit_nr = 0;
  915. unsigned int bit_shift = offset % 8;
  916. int bits_to_copy = 8 - bit_shift;
  917. u32 value = 0;
  918. u32 mask = n < 32 ? (1U << n) - 1 : ~0U;
  919. while (n > 0) {
  920. value |= ((u32)report[idx] >> bit_shift) << bit_nr;
  921. n -= bits_to_copy;
  922. bit_nr += bits_to_copy;
  923. bits_to_copy = 8;
  924. bit_shift = 0;
  925. idx++;
  926. }
  927. return value & mask;
  928. }
  929. u32 hid_field_extract(const struct hid_device *hid, u8 *report,
  930. unsigned offset, unsigned n)
  931. {
  932. if (n > 32) {
  933. hid_warn(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
  934. n, current->comm);
  935. n = 32;
  936. }
  937. return __extract(report, offset, n);
  938. }
  939. EXPORT_SYMBOL_GPL(hid_field_extract);
  940. /*
  941. * "implement" : set bits in a little endian bit stream.
  942. * Same concepts as "extract" (see comments above).
  943. * The data mangled in the bit stream remains in little endian
  944. * order the whole time. It make more sense to talk about
  945. * endianness of register values by considering a register
  946. * a "cached" copy of the little endian bit stream.
  947. */
  948. static void __implement(u8 *report, unsigned offset, int n, u32 value)
  949. {
  950. unsigned int idx = offset / 8;
  951. unsigned int bit_shift = offset % 8;
  952. int bits_to_set = 8 - bit_shift;
  953. while (n - bits_to_set >= 0) {
  954. report[idx] &= ~(0xff << bit_shift);
  955. report[idx] |= value << bit_shift;
  956. value >>= bits_to_set;
  957. n -= bits_to_set;
  958. bits_to_set = 8;
  959. bit_shift = 0;
  960. idx++;
  961. }
  962. /* last nibble */
  963. if (n) {
  964. u8 bit_mask = ((1U << n) - 1);
  965. report[idx] &= ~(bit_mask << bit_shift);
  966. report[idx] |= value << bit_shift;
  967. }
  968. }
  969. static void implement(const struct hid_device *hid, u8 *report,
  970. unsigned offset, unsigned n, u32 value)
  971. {
  972. if (unlikely(n > 32)) {
  973. hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n",
  974. __func__, n, current->comm);
  975. n = 32;
  976. } else if (n < 32) {
  977. u32 m = (1U << n) - 1;
  978. if (unlikely(value > m)) {
  979. hid_warn(hid,
  980. "%s() called with too large value %d (n: %d)! (%s)\n",
  981. __func__, value, n, current->comm);
  982. WARN_ON(1);
  983. value &= m;
  984. }
  985. }
  986. __implement(report, offset, n, value);
  987. }
  988. /*
  989. * Search an array for a value.
  990. */
  991. static int search(__s32 *array, __s32 value, unsigned n)
  992. {
  993. while (n--) {
  994. if (*array++ == value)
  995. return 0;
  996. }
  997. return -1;
  998. }
  999. /**
  1000. * hid_match_report - check if driver's raw_event should be called
  1001. *
  1002. * @hid: hid device
  1003. * @report_type: type to match against
  1004. *
  1005. * compare hid->driver->report_table->report_type to report->type
  1006. */
  1007. static int hid_match_report(struct hid_device *hid, struct hid_report *report)
  1008. {
  1009. const struct hid_report_id *id = hid->driver->report_table;
  1010. if (!id) /* NULL means all */
  1011. return 1;
  1012. for (; id->report_type != HID_TERMINATOR; id++)
  1013. if (id->report_type == HID_ANY_ID ||
  1014. id->report_type == report->type)
  1015. return 1;
  1016. return 0;
  1017. }
  1018. /**
  1019. * hid_match_usage - check if driver's event should be called
  1020. *
  1021. * @hid: hid device
  1022. * @usage: usage to match against
  1023. *
  1024. * compare hid->driver->usage_table->usage_{type,code} to
  1025. * usage->usage_{type,code}
  1026. */
  1027. static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage)
  1028. {
  1029. const struct hid_usage_id *id = hid->driver->usage_table;
  1030. if (!id) /* NULL means all */
  1031. return 1;
  1032. for (; id->usage_type != HID_ANY_ID - 1; id++)
  1033. if ((id->usage_hid == HID_ANY_ID ||
  1034. id->usage_hid == usage->hid) &&
  1035. (id->usage_type == HID_ANY_ID ||
  1036. id->usage_type == usage->type) &&
  1037. (id->usage_code == HID_ANY_ID ||
  1038. id->usage_code == usage->code))
  1039. return 1;
  1040. return 0;
  1041. }
  1042. static void hid_process_event(struct hid_device *hid, struct hid_field *field,
  1043. struct hid_usage *usage, __s32 value, int interrupt)
  1044. {
  1045. struct hid_driver *hdrv = hid->driver;
  1046. int ret;
  1047. if (!list_empty(&hid->debug_list))
  1048. hid_dump_input(hid, usage, value);
  1049. if (hdrv && hdrv->event && hid_match_usage(hid, usage)) {
  1050. ret = hdrv->event(hid, field, usage, value);
  1051. if (ret != 0) {
  1052. if (ret < 0)
  1053. hid_err(hid, "%s's event failed with %d\n",
  1054. hdrv->name, ret);
  1055. return;
  1056. }
  1057. }
  1058. if (hid->claimed & HID_CLAIMED_INPUT)
  1059. hidinput_hid_event(hid, field, usage, value);
  1060. if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event)
  1061. hid->hiddev_hid_event(hid, field, usage, value);
  1062. }
  1063. /*
  1064. * Analyse a received field, and fetch the data from it. The field
  1065. * content is stored for next report processing (we do differential
  1066. * reporting to the layer).
  1067. */
  1068. static void hid_input_field(struct hid_device *hid, struct hid_field *field,
  1069. __u8 *data, int interrupt)
  1070. {
  1071. unsigned n;
  1072. unsigned count = field->report_count;
  1073. unsigned offset = field->report_offset;
  1074. unsigned size = field->report_size;
  1075. __s32 min = field->logical_minimum;
  1076. __s32 max = field->logical_maximum;
  1077. __s32 *value;
  1078. value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC);
  1079. if (!value)
  1080. return;
  1081. for (n = 0; n < count; n++) {
  1082. value[n] = min < 0 ?
  1083. snto32(hid_field_extract(hid, data, offset + n * size,
  1084. size), size) :
  1085. hid_field_extract(hid, data, offset + n * size, size);
  1086. /* Ignore report if ErrorRollOver */
  1087. if (!(field->flags & HID_MAIN_ITEM_VARIABLE) &&
  1088. value[n] >= min && value[n] <= max &&
  1089. value[n] - min < field->maxusage &&
  1090. field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1)
  1091. goto exit;
  1092. }
  1093. for (n = 0; n < count; n++) {
  1094. if (HID_MAIN_ITEM_VARIABLE & field->flags) {
  1095. hid_process_event(hid, field, &field->usage[n], value[n], interrupt);
  1096. continue;
  1097. }
  1098. if (field->value[n] >= min && field->value[n] <= max
  1099. && field->value[n] - min < field->maxusage
  1100. && field->usage[field->value[n] - min].hid
  1101. && search(value, field->value[n], count))
  1102. hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt);
  1103. if (value[n] >= min && value[n] <= max
  1104. && value[n] - min < field->maxusage
  1105. && field->usage[value[n] - min].hid
  1106. && search(field->value, value[n], count))
  1107. hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt);
  1108. }
  1109. memcpy(field->value, value, count * sizeof(__s32));
  1110. exit:
  1111. kfree(value);
  1112. }
  1113. /*
  1114. * Output the field into the report.
  1115. */
  1116. static void hid_output_field(const struct hid_device *hid,
  1117. struct hid_field *field, __u8 *data)
  1118. {
  1119. unsigned count = field->report_count;
  1120. unsigned offset = field->report_offset;
  1121. unsigned size = field->report_size;
  1122. unsigned n;
  1123. for (n = 0; n < count; n++) {
  1124. if (field->logical_minimum < 0) /* signed values */
  1125. implement(hid, data, offset + n * size, size,
  1126. s32ton(field->value[n], size));
  1127. else /* unsigned values */
  1128. implement(hid, data, offset + n * size, size,
  1129. field->value[n]);
  1130. }
  1131. }
  1132. /*
  1133. * Create a report. 'data' has to be allocated using
  1134. * hid_alloc_report_buf() so that it has proper size.
  1135. */
  1136. void hid_output_report(struct hid_report *report, __u8 *data)
  1137. {
  1138. unsigned n;
  1139. if (report->id > 0)
  1140. *data++ = report->id;
  1141. memset(data, 0, ((report->size - 1) >> 3) + 1);
  1142. for (n = 0; n < report->maxfield; n++)
  1143. hid_output_field(report->device, report->field[n], data);
  1144. }
  1145. EXPORT_SYMBOL_GPL(hid_output_report);
  1146. /*
  1147. * Allocator for buffer that is going to be passed to hid_output_report()
  1148. */
  1149. u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags)
  1150. {
  1151. /*
  1152. * 7 extra bytes are necessary to achieve proper functionality
  1153. * of implement() working on 8 byte chunks
  1154. */
  1155. int len = hid_report_len(report) + 7;
  1156. return kmalloc(len, flags);
  1157. }
  1158. EXPORT_SYMBOL_GPL(hid_alloc_report_buf);
  1159. /*
  1160. * Set a field value. The report this field belongs to has to be
  1161. * created and transferred to the device, to set this value in the
  1162. * device.
  1163. */
  1164. int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
  1165. {
  1166. unsigned size;
  1167. if (!field)
  1168. return -1;
  1169. size = field->report_size;
  1170. hid_dump_input(field->report->device, field->usage + offset, value);
  1171. if (offset >= field->report_count) {
  1172. hid_err(field->report->device, "offset (%d) exceeds report_count (%d)\n",
  1173. offset, field->report_count);
  1174. return -1;
  1175. }
  1176. if (field->logical_minimum < 0) {
  1177. if (value != snto32(s32ton(value, size), size)) {
  1178. hid_err(field->report->device, "value %d is out of range\n", value);
  1179. return -1;
  1180. }
  1181. }
  1182. field->value[offset] = value;
  1183. return 0;
  1184. }
  1185. EXPORT_SYMBOL_GPL(hid_set_field);
  1186. static struct hid_report *hid_get_report(struct hid_report_enum *report_enum,
  1187. const u8 *data)
  1188. {
  1189. struct hid_report *report;
  1190. unsigned int n = 0; /* Normally report number is 0 */
  1191. /* Device uses numbered reports, data[0] is report number */
  1192. if (report_enum->numbered)
  1193. n = *data;
  1194. report = report_enum->report_id_hash[n];
  1195. if (report == NULL)
  1196. dbg_hid("undefined report_id %u received\n", n);
  1197. return report;
  1198. }
  1199. /*
  1200. * Implement a generic .request() callback, using .raw_request()
  1201. * DO NOT USE in hid drivers directly, but through hid_hw_request instead.
  1202. */
  1203. void __hid_request(struct hid_device *hid, struct hid_report *report,
  1204. int reqtype)
  1205. {
  1206. char *buf;
  1207. int ret;
  1208. int len;
  1209. buf = hid_alloc_report_buf(report, GFP_KERNEL);
  1210. if (!buf)
  1211. return;
  1212. len = hid_report_len(report);
  1213. if (reqtype == HID_REQ_SET_REPORT)
  1214. hid_output_report(report, buf);
  1215. ret = hid->ll_driver->raw_request(hid, report->id, buf, len,
  1216. report->type, reqtype);
  1217. if (ret < 0) {
  1218. dbg_hid("unable to complete request: %d\n", ret);
  1219. goto out;
  1220. }
  1221. if (reqtype == HID_REQ_GET_REPORT)
  1222. hid_input_report(hid, report->type, buf, ret, 0);
  1223. out:
  1224. kfree(buf);
  1225. }
  1226. EXPORT_SYMBOL_GPL(__hid_request);
  1227. int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
  1228. int interrupt)
  1229. {
  1230. struct hid_report_enum *report_enum = hid->report_enum + type;
  1231. struct hid_report *report;
  1232. struct hid_driver *hdrv;
  1233. unsigned int a;
  1234. int rsize, csize = size;
  1235. u8 *cdata = data;
  1236. int ret = 0;
  1237. report = hid_get_report(report_enum, data);
  1238. if (!report)
  1239. goto out;
  1240. if (report_enum->numbered) {
  1241. cdata++;
  1242. csize--;
  1243. }
  1244. rsize = ((report->size - 1) >> 3) + 1;
  1245. if (rsize > HID_MAX_BUFFER_SIZE)
  1246. rsize = HID_MAX_BUFFER_SIZE;
  1247. if (csize < rsize) {
  1248. dbg_hid("report %d is too short, (%d < %d)\n", report->id,
  1249. csize, rsize);
  1250. memset(cdata + csize, 0, rsize - csize);
  1251. }
  1252. if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
  1253. hid->hiddev_report_event(hid, report);
  1254. if (hid->claimed & HID_CLAIMED_HIDRAW) {
  1255. ret = hidraw_report_event(hid, data, size);
  1256. if (ret)
  1257. goto out;
  1258. }
  1259. if (hid->claimed != HID_CLAIMED_HIDRAW && report->maxfield) {
  1260. for (a = 0; a < report->maxfield; a++)
  1261. hid_input_field(hid, report->field[a], cdata, interrupt);
  1262. hdrv = hid->driver;
  1263. if (hdrv && hdrv->report)
  1264. hdrv->report(hid, report);
  1265. }
  1266. if (hid->claimed & HID_CLAIMED_INPUT)
  1267. hidinput_report_event(hid, report);
  1268. out:
  1269. return ret;
  1270. }
  1271. EXPORT_SYMBOL_GPL(hid_report_raw_event);
  1272. /**
  1273. * hid_input_report - report data from lower layer (usb, bt...)
  1274. *
  1275. * @hid: hid device
  1276. * @type: HID report type (HID_*_REPORT)
  1277. * @data: report contents
  1278. * @size: size of data parameter
  1279. * @interrupt: distinguish between interrupt and control transfers
  1280. *
  1281. * This is data entry for lower layers.
  1282. */
  1283. int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt)
  1284. {
  1285. struct hid_report_enum *report_enum;
  1286. struct hid_driver *hdrv;
  1287. struct hid_report *report;
  1288. int ret = 0;
  1289. if (!hid)
  1290. return -ENODEV;
  1291. if (down_trylock(&hid->driver_input_lock))
  1292. return -EBUSY;
  1293. if (!hid->driver) {
  1294. ret = -ENODEV;
  1295. goto unlock;
  1296. }
  1297. report_enum = hid->report_enum + type;
  1298. hdrv = hid->driver;
  1299. if (!size) {
  1300. dbg_hid("empty report\n");
  1301. ret = -1;
  1302. goto unlock;
  1303. }
  1304. /* Avoid unnecessary overhead if debugfs is disabled */
  1305. if (!list_empty(&hid->debug_list))
  1306. hid_dump_report(hid, type, data, size);
  1307. report = hid_get_report(report_enum, data);
  1308. if (!report) {
  1309. ret = -1;
  1310. goto unlock;
  1311. }
  1312. if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) {
  1313. ret = hdrv->raw_event(hid, report, data, size);
  1314. if (ret < 0)
  1315. goto unlock;
  1316. }
  1317. ret = hid_report_raw_event(hid, type, data, size, interrupt);
  1318. unlock:
  1319. up(&hid->driver_input_lock);
  1320. return ret;
  1321. }
  1322. EXPORT_SYMBOL_GPL(hid_input_report);
  1323. static bool hid_match_one_id(struct hid_device *hdev,
  1324. const struct hid_device_id *id)
  1325. {
  1326. return (id->bus == HID_BUS_ANY || id->bus == hdev->bus) &&
  1327. (id->group == HID_GROUP_ANY || id->group == hdev->group) &&
  1328. (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) &&
  1329. (id->product == HID_ANY_ID || id->product == hdev->product);
  1330. }
  1331. const struct hid_device_id *hid_match_id(struct hid_device *hdev,
  1332. const struct hid_device_id *id)
  1333. {
  1334. for (; id->bus; id++)
  1335. if (hid_match_one_id(hdev, id))
  1336. return id;
  1337. return NULL;
  1338. }
  1339. static const struct hid_device_id hid_hiddev_list[] = {
  1340. { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) },
  1341. { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) },
  1342. { }
  1343. };
  1344. static bool hid_hiddev(struct hid_device *hdev)
  1345. {
  1346. return !!hid_match_id(hdev, hid_hiddev_list);
  1347. }
  1348. static ssize_t
  1349. read_report_descriptor(struct file *filp, struct kobject *kobj,
  1350. struct bin_attribute *attr,
  1351. char *buf, loff_t off, size_t count)
  1352. {
  1353. struct device *dev = kobj_to_dev(kobj);
  1354. struct hid_device *hdev = to_hid_device(dev);
  1355. if (off >= hdev->rsize)
  1356. return 0;
  1357. if (off + count > hdev->rsize)
  1358. count = hdev->rsize - off;
  1359. memcpy(buf, hdev->rdesc + off, count);
  1360. return count;
  1361. }
  1362. static ssize_t
  1363. show_country(struct device *dev, struct device_attribute *attr,
  1364. char *buf)
  1365. {
  1366. struct hid_device *hdev = to_hid_device(dev);
  1367. return sprintf(buf, "%02x\n", hdev->country & 0xff);
  1368. }
  1369. static struct bin_attribute dev_bin_attr_report_desc = {
  1370. .attr = { .name = "report_descriptor", .mode = 0444 },
  1371. .read = read_report_descriptor,
  1372. .size = HID_MAX_DESCRIPTOR_SIZE,
  1373. };
  1374. static struct device_attribute dev_attr_country = {
  1375. .attr = { .name = "country", .mode = 0444 },
  1376. .show = show_country,
  1377. };
  1378. int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
  1379. {
  1380. static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
  1381. "Joystick", "Gamepad", "Keyboard", "Keypad",
  1382. "Multi-Axis Controller"
  1383. };
  1384. const char *type, *bus;
  1385. char buf[64] = "";
  1386. unsigned int i;
  1387. int len;
  1388. int ret;
  1389. if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE)
  1390. connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV);
  1391. if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE)
  1392. connect_mask |= HID_CONNECT_HIDINPUT_FORCE;
  1393. if (hdev->bus != BUS_USB)
  1394. connect_mask &= ~HID_CONNECT_HIDDEV;
  1395. if (hid_hiddev(hdev))
  1396. connect_mask |= HID_CONNECT_HIDDEV_FORCE;
  1397. if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev,
  1398. connect_mask & HID_CONNECT_HIDINPUT_FORCE))
  1399. hdev->claimed |= HID_CLAIMED_INPUT;
  1400. if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect &&
  1401. !hdev->hiddev_connect(hdev,
  1402. connect_mask & HID_CONNECT_HIDDEV_FORCE))
  1403. hdev->claimed |= HID_CLAIMED_HIDDEV;
  1404. if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev))
  1405. hdev->claimed |= HID_CLAIMED_HIDRAW;
  1406. if (connect_mask & HID_CONNECT_DRIVER)
  1407. hdev->claimed |= HID_CLAIMED_DRIVER;
  1408. /* Drivers with the ->raw_event callback set are not required to connect
  1409. * to any other listener. */
  1410. if (!hdev->claimed && !hdev->driver->raw_event) {
  1411. hid_err(hdev, "device has no listeners, quitting\n");
  1412. return -ENODEV;
  1413. }
  1414. if ((hdev->claimed & HID_CLAIMED_INPUT) &&
  1415. (connect_mask & HID_CONNECT_FF) && hdev->ff_init)
  1416. hdev->ff_init(hdev);
  1417. len = 0;
  1418. if (hdev->claimed & HID_CLAIMED_INPUT)
  1419. len += sprintf(buf + len, "input");
  1420. if (hdev->claimed & HID_CLAIMED_HIDDEV)
  1421. len += sprintf(buf + len, "%shiddev%d", len ? "," : "",
  1422. hdev->minor);
  1423. if (hdev->claimed & HID_CLAIMED_HIDRAW)
  1424. len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
  1425. ((struct hidraw *)hdev->hidraw)->minor);
  1426. type = "Device";
  1427. for (i = 0; i < hdev->maxcollection; i++) {
  1428. struct hid_collection *col = &hdev->collection[i];
  1429. if (col->type == HID_COLLECTION_APPLICATION &&
  1430. (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK &&
  1431. (col->usage & 0xffff) < ARRAY_SIZE(types)) {
  1432. type = types[col->usage & 0xffff];
  1433. break;
  1434. }
  1435. }
  1436. switch (hdev->bus) {
  1437. case BUS_USB:
  1438. bus = "USB";
  1439. break;
  1440. case BUS_BLUETOOTH:
  1441. bus = "BLUETOOTH";
  1442. break;
  1443. case BUS_I2C:
  1444. bus = "I2C";
  1445. break;
  1446. default:
  1447. bus = "<UNKNOWN>";
  1448. }
  1449. ret = device_create_file(&hdev->dev, &dev_attr_country);
  1450. if (ret)
  1451. hid_warn(hdev,
  1452. "can't create sysfs country code attribute err: %d\n", ret);
  1453. hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
  1454. buf, bus, hdev->version >> 8, hdev->version & 0xff,
  1455. type, hdev->name, hdev->phys);
  1456. return 0;
  1457. }
  1458. EXPORT_SYMBOL_GPL(hid_connect);
  1459. void hid_disconnect(struct hid_device *hdev)
  1460. {
  1461. device_remove_file(&hdev->dev, &dev_attr_country);
  1462. if (hdev->claimed & HID_CLAIMED_INPUT)
  1463. hidinput_disconnect(hdev);
  1464. if (hdev->claimed & HID_CLAIMED_HIDDEV)
  1465. hdev->hiddev_disconnect(hdev);
  1466. if (hdev->claimed & HID_CLAIMED_HIDRAW)
  1467. hidraw_disconnect(hdev);
  1468. hdev->claimed = 0;
  1469. }
  1470. EXPORT_SYMBOL_GPL(hid_disconnect);
  1471. /*
  1472. * A list of devices for which there is a specialized driver on HID bus.
  1473. *
  1474. * Please note that for multitouch devices (driven by hid-multitouch driver),
  1475. * there is a proper autodetection and autoloading in place (based on presence
  1476. * of HID_DG_CONTACTID), so those devices don't need to be added to this list,
  1477. * as we are doing the right thing in hid_scan_usage().
  1478. *
  1479. * Autodetection for (USB) HID sensor hubs exists too. If a collection of type
  1480. * physical is found inside a usage page of type sensor, hid-sensor-hub will be
  1481. * used as a driver. See hid_scan_report().
  1482. */
  1483. static const struct hid_device_id hid_have_special_driver[] = {
  1484. { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
  1485. { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
  1486. { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) },
  1487. { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) },
  1488. { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0xf705) },
  1489. { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_DUAL) },
  1490. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) },
  1491. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) },
  1492. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) },
  1493. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
  1494. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
  1495. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
  1496. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) },
  1497. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) },
  1498. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) },
  1499. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) },
  1500. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) },
  1501. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) },
  1502. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) },
  1503. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) },
  1504. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI) },
  1505. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO) },
  1506. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS) },
  1507. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) },
  1508. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) },
  1509. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) },
  1510. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) },
  1511. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) },
  1512. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) },
  1513. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) },
  1514. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL2) },
  1515. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL3) },
  1516. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
  1517. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL5) },
  1518. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) },
  1519. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) },
  1520. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) },
  1521. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) },
  1522. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) },
  1523. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) },
  1524. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
  1525. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
  1526. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
  1527. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
  1528. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
  1529. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
  1530. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) },
  1531. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) },
  1532. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) },
  1533. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) },
  1534. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) },
  1535. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) },
  1536. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
  1537. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
  1538. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
  1539. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
  1540. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
  1541. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
  1542. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) },
  1543. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) },
  1544. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) },
  1545. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) },
  1546. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) },
  1547. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) },
  1548. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
  1549. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
  1550. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
  1551. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI) },
  1552. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO) },
  1553. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS) },
  1554. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI) },
  1555. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO) },
  1556. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS) },
  1557. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI) },
  1558. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO) },
  1559. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS) },
  1560. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) },
  1561. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
  1562. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
  1563. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
  1564. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
  1565. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
  1566. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI) },
  1567. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) },
  1568. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS) },
  1569. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI) },
  1570. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
  1571. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
  1572. { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD) },
  1573. { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_TOUCHPAD) },
  1574. { HID_USB_DEVICE(USB_VENDOR_ID_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) },
  1575. { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
  1576. { HID_USB_DEVICE(USB_VENDOR_ID_BETOP_2185BFM, 0x2208) },
  1577. { HID_USB_DEVICE(USB_VENDOR_ID_BETOP_2185PC, 0x5506) },
  1578. { HID_USB_DEVICE(USB_VENDOR_ID_BETOP_2185V2PC, 0x1850) },
  1579. { HID_USB_DEVICE(USB_VENDOR_ID_BETOP_2185V2BFM, 0x5500) },
  1580. { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) },
  1581. { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) },
  1582. { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
  1583. { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) },
  1584. { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
  1585. { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) },
  1586. { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
  1587. { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) },
  1588. { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
  1589. { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K90) },
  1590. { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
  1591. { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_CP2112) },
  1592. { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
  1593. { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) },
  1594. { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) },
  1595. { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_4) },
  1596. { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
  1597. { HID_USB_DEVICE(USB_VENDOR_ID_DELCOM, USB_DEVICE_ID_DELCOM_VISUAL_IND) },
  1598. { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) },
  1599. { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) },
  1600. #if IS_ENABLED(CONFIG_HID_MAYFLASH)
  1601. { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_PS3) },
  1602. #endif
  1603. { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_WN) },
  1604. { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_FA) },
  1605. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
  1606. { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) },
  1607. { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0030) },
  1608. { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) },
  1609. { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
  1610. { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
  1611. { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) },
  1612. { HID_USB_DEVICE(USB_VENDOR_ID_GEMBIRD, USB_DEVICE_ID_GEMBIRD_JPD_DUALFORCE2) },
  1613. { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
  1614. { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) },
  1615. { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
  1616. { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) },
  1617. { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) },
  1618. { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) },
  1619. { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD) },
  1620. { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A04A) },
  1621. { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067) },
  1622. { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A070) },
  1623. { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A072) },
  1624. { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A081) },
  1625. { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A0C2) },
  1626. { HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_TABLET) },
  1627. { HID_USB_DEVICE(USB_VENDOR_ID_JESS2, USB_DEVICE_ID_JESS2_COLOR_RUMBLE_PAD) },
  1628. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ION, USB_DEVICE_ID_ICADE) },
  1629. { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) },
  1630. { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) },
  1631. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) },
  1632. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_MANTICORE) },
  1633. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_GX_IMPERATOR) },
  1634. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) },
  1635. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) },
  1636. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) },
  1637. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) },
  1638. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) },
  1639. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_PENSKETCH_M912) },
  1640. { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
  1641. { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) },
  1642. #if IS_ENABLED(CONFIG_HID_LENOVO)
  1643. { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) },
  1644. { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CUSBKBD) },
  1645. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CBTKBD) },
  1646. { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPPRODOCK) },
  1647. #endif
  1648. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) },
  1649. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) },
  1650. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) },
  1651. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) },
  1652. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3) },
  1653. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_T651) },
  1654. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) },
  1655. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) },
  1656. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) },
  1657. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) },
  1658. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) },
  1659. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) },
  1660. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DUAL_ACTION) },
  1661. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) },
  1662. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) },
  1663. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) },
  1664. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) },
  1665. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G29_WHEEL) },
  1666. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G920_WHEEL) },
  1667. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) },
  1668. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) },
  1669. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) },
  1670. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) },
  1671. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) },
  1672. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) },
  1673. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_VIBRATION_WHEEL) },
  1674. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL) },
  1675. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL) },
  1676. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) },
  1677. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G27_WHEEL) },
  1678. #if IS_ENABLED(CONFIG_HID_LOGITECH_DJ)
  1679. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER) },
  1680. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2) },
  1681. #endif
  1682. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) },
  1683. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) },
  1684. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) },
  1685. { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) },
  1686. { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) },
  1687. { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) },
  1688. { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_LUXAFOR) },
  1689. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) },
  1690. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_KEYBOARD) },
  1691. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
  1692. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) },
  1693. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K_JP) },
  1694. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE7K) },
  1695. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
  1696. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) },
  1697. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) },
  1698. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
  1699. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_OFFICE_KB) },
  1700. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3) },
  1701. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_2) },
  1702. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP) },
  1703. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_4) },
  1704. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_2) },
  1705. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_4_JP) },
  1706. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_7K) },
  1707. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_600) },
  1708. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3KV1) },
  1709. { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER) },
  1710. { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
  1711. { HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) },
  1712. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
  1713. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) },
  1714. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) },
  1715. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3) },
  1716. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4) },
  1717. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5) },
  1718. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6) },
  1719. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7) },
  1720. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8) },
  1721. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9) },
  1722. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10) },
  1723. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11) },
  1724. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12) },
  1725. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13) },
  1726. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14) },
  1727. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15) },
  1728. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) },
  1729. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) },
  1730. { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) },
  1731. { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) },
  1732. { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },
  1733. { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_6000) },
  1734. { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
  1735. { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, HID_ANY_ID) },
  1736. { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) },
  1737. { HID_USB_DEVICE(USB_VENDOR_ID_RISO_KAGAKU, USB_DEVICE_ID_RI_KA_WEBMAIL) },
  1738. #if IS_ENABLED(CONFIG_HID_ROCCAT)
  1739. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) },
  1740. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) },
  1741. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKUFX) },
  1742. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) },
  1743. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) },
  1744. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPURE) },
  1745. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPURE_OPTICAL) },
  1746. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEXTD) },
  1747. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) },
  1748. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_LUA) },
  1749. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
  1750. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) },
  1751. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_RYOS_MK) },
  1752. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_RYOS_MK_GLOW) },
  1753. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_RYOS_MK_PRO) },
  1754. { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_SAVU) },
  1755. #endif
  1756. #if IS_ENABLED(CONFIG_HID_SAITEK)
  1757. { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000) },
  1758. { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7_OLD) },
  1759. { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7) },
  1760. { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT9) },
  1761. { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_MMO7) },
  1762. { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT5) },
  1763. { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9) },
  1764. #endif
  1765. { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
  1766. { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
  1767. { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
  1768. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE) },
  1769. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER) },
  1770. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER) },
  1771. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER) },
  1772. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_MOTION_CONTROLLER) },
  1773. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
  1774. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
  1775. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) },
  1776. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
  1777. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
  1778. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
  1779. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
  1780. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2) },
  1781. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2) },
  1782. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) },
  1783. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
  1784. { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE) },
  1785. { HID_USB_DEVICE(USB_VENDOR_ID_SINO_LITE, USB_DEVICE_ID_SINO_LITE_CONTROLLER) },
  1786. { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_SRWS1) },
  1787. { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
  1788. { HID_USB_DEVICE(USB_VENDOR_ID_THINGM, USB_DEVICE_ID_BLINK1) },
  1789. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
  1790. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) },
  1791. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) },
  1792. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) },
  1793. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
  1794. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) },
  1795. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
  1796. { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) },
  1797. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_BT) },
  1798. { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE) },
  1799. { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_PRO) },
  1800. { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
  1801. { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) },
  1802. { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) },
  1803. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) },
  1804. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) },
  1805. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) },
  1806. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) },
  1807. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) },
  1808. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850) },
  1809. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60) },
  1810. { HID_USB_DEVICE(USB_VENDOR_ID_THQ, USB_DEVICE_ID_THQ_PS3_UDRAW) },
  1811. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_YIYNOVA_TABLET) },
  1812. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_81) },
  1813. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_45) },
  1814. { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) },
  1815. { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) },
  1816. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) },
  1817. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SUPER_JOY_BOX_3) },
  1818. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) },
  1819. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) },
  1820. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) },
  1821. { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) },
  1822. { HID_USB_DEVICE(USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII) },
  1823. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
  1824. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
  1825. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_Q_PAD) },
  1826. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_PID_0038) },
  1827. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
  1828. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
  1829. { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) },
  1830. { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) },
  1831. { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) },
  1832. { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
  1833. { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
  1834. { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
  1835. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) },
  1836. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) },
  1837. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE2) },
  1838. { HID_USB_DEVICE(USB_VENDOR_ID_RAZER, USB_DEVICE_ID_RAZER_BLADE_14) },
  1839. { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM6533) },
  1840. { }
  1841. };
  1842. struct hid_dynid {
  1843. struct list_head list;
  1844. struct hid_device_id id;
  1845. };
  1846. /**
  1847. * store_new_id - add a new HID device ID to this driver and re-probe devices
  1848. * @driver: target device driver
  1849. * @buf: buffer for scanning device ID data
  1850. * @count: input size
  1851. *
  1852. * Adds a new dynamic hid device ID to this driver,
  1853. * and causes the driver to probe for all devices again.
  1854. */
  1855. static ssize_t store_new_id(struct device_driver *drv, const char *buf,
  1856. size_t count)
  1857. {
  1858. struct hid_driver *hdrv = to_hid_driver(drv);
  1859. struct hid_dynid *dynid;
  1860. __u32 bus, vendor, product;
  1861. unsigned long driver_data = 0;
  1862. int ret;
  1863. ret = sscanf(buf, "%x %x %x %lx",
  1864. &bus, &vendor, &product, &driver_data);
  1865. if (ret < 3)
  1866. return -EINVAL;
  1867. dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
  1868. if (!dynid)
  1869. return -ENOMEM;
  1870. dynid->id.bus = bus;
  1871. dynid->id.group = HID_GROUP_ANY;
  1872. dynid->id.vendor = vendor;
  1873. dynid->id.product = product;
  1874. dynid->id.driver_data = driver_data;
  1875. spin_lock(&hdrv->dyn_lock);
  1876. list_add_tail(&dynid->list, &hdrv->dyn_list);
  1877. spin_unlock(&hdrv->dyn_lock);
  1878. ret = driver_attach(&hdrv->driver);
  1879. return ret ? : count;
  1880. }
  1881. static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
  1882. static void hid_free_dynids(struct hid_driver *hdrv)
  1883. {
  1884. struct hid_dynid *dynid, *n;
  1885. spin_lock(&hdrv->dyn_lock);
  1886. list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) {
  1887. list_del(&dynid->list);
  1888. kfree(dynid);
  1889. }
  1890. spin_unlock(&hdrv->dyn_lock);
  1891. }
  1892. static const struct hid_device_id *hid_match_device(struct hid_device *hdev,
  1893. struct hid_driver *hdrv)
  1894. {
  1895. struct hid_dynid *dynid;
  1896. spin_lock(&hdrv->dyn_lock);
  1897. list_for_each_entry(dynid, &hdrv->dyn_list, list) {
  1898. if (hid_match_one_id(hdev, &dynid->id)) {
  1899. spin_unlock(&hdrv->dyn_lock);
  1900. return &dynid->id;
  1901. }
  1902. }
  1903. spin_unlock(&hdrv->dyn_lock);
  1904. return hid_match_id(hdev, hdrv->id_table);
  1905. }
  1906. static int hid_bus_match(struct device *dev, struct device_driver *drv)
  1907. {
  1908. struct hid_driver *hdrv = to_hid_driver(drv);
  1909. struct hid_device *hdev = to_hid_device(dev);
  1910. return hid_match_device(hdev, hdrv) != NULL;
  1911. }
  1912. static int hid_device_probe(struct device *dev)
  1913. {
  1914. struct hid_driver *hdrv = to_hid_driver(dev->driver);
  1915. struct hid_device *hdev = to_hid_device(dev);
  1916. const struct hid_device_id *id;
  1917. int ret = 0;
  1918. if (down_interruptible(&hdev->driver_lock))
  1919. return -EINTR;
  1920. if (down_interruptible(&hdev->driver_input_lock)) {
  1921. ret = -EINTR;
  1922. goto unlock_driver_lock;
  1923. }
  1924. hdev->io_started = false;
  1925. if (!hdev->driver) {
  1926. id = hid_match_device(hdev, hdrv);
  1927. if (id == NULL) {
  1928. ret = -ENODEV;
  1929. goto unlock;
  1930. }
  1931. hdev->driver = hdrv;
  1932. if (hdrv->probe) {
  1933. ret = hdrv->probe(hdev, id);
  1934. } else { /* default probe */
  1935. ret = hid_open_report(hdev);
  1936. if (!ret)
  1937. ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  1938. }
  1939. if (ret) {
  1940. hid_close_report(hdev);
  1941. hdev->driver = NULL;
  1942. }
  1943. }
  1944. unlock:
  1945. if (!hdev->io_started)
  1946. up(&hdev->driver_input_lock);
  1947. unlock_driver_lock:
  1948. up(&hdev->driver_lock);
  1949. return ret;
  1950. }
  1951. static int hid_device_remove(struct device *dev)
  1952. {
  1953. struct hid_device *hdev = to_hid_device(dev);
  1954. struct hid_driver *hdrv;
  1955. int ret = 0;
  1956. if (down_interruptible(&hdev->driver_lock))
  1957. return -EINTR;
  1958. if (down_interruptible(&hdev->driver_input_lock)) {
  1959. ret = -EINTR;
  1960. goto unlock_driver_lock;
  1961. }
  1962. hdev->io_started = false;
  1963. hdrv = hdev->driver;
  1964. if (hdrv) {
  1965. if (hdrv->remove)
  1966. hdrv->remove(hdev);
  1967. else /* default remove */
  1968. hid_hw_stop(hdev);
  1969. hid_close_report(hdev);
  1970. hdev->driver = NULL;
  1971. }
  1972. if (!hdev->io_started)
  1973. up(&hdev->driver_input_lock);
  1974. unlock_driver_lock:
  1975. up(&hdev->driver_lock);
  1976. return ret;
  1977. }
  1978. static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
  1979. char *buf)
  1980. {
  1981. struct hid_device *hdev = container_of(dev, struct hid_device, dev);
  1982. return scnprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n",
  1983. hdev->bus, hdev->group, hdev->vendor, hdev->product);
  1984. }
  1985. static DEVICE_ATTR_RO(modalias);
  1986. static struct attribute *hid_dev_attrs[] = {
  1987. &dev_attr_modalias.attr,
  1988. NULL,
  1989. };
  1990. static struct bin_attribute *hid_dev_bin_attrs[] = {
  1991. &dev_bin_attr_report_desc,
  1992. NULL
  1993. };
  1994. static const struct attribute_group hid_dev_group = {
  1995. .attrs = hid_dev_attrs,
  1996. .bin_attrs = hid_dev_bin_attrs,
  1997. };
  1998. __ATTRIBUTE_GROUPS(hid_dev);
  1999. static int hid_uevent(struct device *dev, struct kobj_uevent_env *env)
  2000. {
  2001. struct hid_device *hdev = to_hid_device(dev);
  2002. if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X",
  2003. hdev->bus, hdev->vendor, hdev->product))
  2004. return -ENOMEM;
  2005. if (add_uevent_var(env, "HID_NAME=%s", hdev->name))
  2006. return -ENOMEM;
  2007. if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys))
  2008. return -ENOMEM;
  2009. if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq))
  2010. return -ENOMEM;
  2011. if (add_uevent_var(env, "MODALIAS=hid:b%04Xg%04Xv%08Xp%08X",
  2012. hdev->bus, hdev->group, hdev->vendor, hdev->product))
  2013. return -ENOMEM;
  2014. return 0;
  2015. }
  2016. static struct bus_type hid_bus_type = {
  2017. .name = "hid",
  2018. .dev_groups = hid_dev_groups,
  2019. .match = hid_bus_match,
  2020. .probe = hid_device_probe,
  2021. .remove = hid_device_remove,
  2022. .uevent = hid_uevent,
  2023. };
  2024. /* a list of devices that shouldn't be handled by HID core at all */
  2025. static const struct hid_device_id hid_ignore_list[] = {
  2026. { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) },
  2027. { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) },
  2028. { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) },
  2029. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) },
  2030. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) },
  2031. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) },
  2032. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) },
  2033. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) },
  2034. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) },
  2035. { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
  2036. { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
  2037. { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
  2038. { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)},
  2039. { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)},
  2040. { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },
  2041. { HID_USB_DEVICE(USB_VENDOR_ID_AXENTIA, USB_DEVICE_ID_AXENTIA_FM_RADIO) },
  2042. { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) },
  2043. { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) },
  2044. { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) },
  2045. { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI4713) },
  2046. { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) },
  2047. { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) },
  2048. { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) },
  2049. { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) },
  2050. { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
  2051. { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
  2052. { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, 0x0400) },
  2053. { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, 0x0401) },
  2054. { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
  2055. { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) },
  2056. { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) },
  2057. { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) },
  2058. { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) },
  2059. { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) },
  2060. { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) },
  2061. { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) },
  2062. { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) },
  2063. { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) },
  2064. { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) },
  2065. { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) },
  2066. { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_RADIOSHARK) },
  2067. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) },
  2068. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) },
  2069. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) },
  2070. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) },
  2071. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) },
  2072. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) },
  2073. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) },
  2074. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) },
  2075. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) },
  2076. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) },
  2077. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) },
  2078. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) },
  2079. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) },
  2080. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) },
  2081. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) },
  2082. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) },
  2083. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) },
  2084. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) },
  2085. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) },
  2086. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) },
  2087. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) },
  2088. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) },
  2089. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) },
  2090. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) },
  2091. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) },
  2092. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) },
  2093. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) },
  2094. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) },
  2095. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) },
  2096. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) },
  2097. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) },
  2098. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) },
  2099. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) },
  2100. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) },
  2101. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) },
  2102. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) },
  2103. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) },
  2104. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) },
  2105. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) },
  2106. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) },
  2107. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) },
  2108. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) },
  2109. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) },
  2110. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) },
  2111. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) },
  2112. { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
  2113. { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
  2114. { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, USB_DEVICE_ID_JABRA_SPEAK_410) },
  2115. { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, USB_DEVICE_ID_JABRA_SPEAK_510) },
  2116. { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, USB_DEVICE_ID_JABRA_GN9350E) },
  2117. { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
  2118. { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) },
  2119. { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
  2120. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) },
  2121. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) },
  2122. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) },
  2123. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) },
  2124. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) },
  2125. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) },
  2126. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) },
  2127. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) },
  2128. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) },
  2129. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) },
  2130. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) },
  2131. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) },
  2132. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) },
  2133. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) },
  2134. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
  2135. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) },
  2136. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) },
  2137. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) },
  2138. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) },
  2139. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) },
  2140. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) },
  2141. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) },
  2142. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) },
  2143. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) },
  2144. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) },
  2145. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) },
  2146. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) },
  2147. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) },
  2148. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) },
  2149. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) },
  2150. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) },
  2151. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) },
  2152. { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) },
  2153. { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_BEATPAD) },
  2154. { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) },
  2155. { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) },
  2156. { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) },
  2157. { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) },
  2158. { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICK16F1454) },
  2159. { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICK16F1454_V2) },
  2160. { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) },
  2161. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) },
  2162. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) },
  2163. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) },
  2164. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) },
  2165. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) },
  2166. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) },
  2167. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) },
  2168. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) },
  2169. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) },
  2170. { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) },
  2171. { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) },
  2172. { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) },
  2173. { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
  2174. { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
  2175. { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) },
  2176. { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
  2177. #if IS_ENABLED(CONFIG_MOUSE_SYNAPTICS_USB)
  2178. { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP) },
  2179. { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_INT_TP) },
  2180. { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_CPAD) },
  2181. { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_STICK) },
  2182. { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WP) },
  2183. { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_COMP_TP) },
  2184. { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WTP) },
  2185. { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DPAD) },
  2186. #endif
  2187. { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
  2188. { }
  2189. };
  2190. /**
  2191. * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer
  2192. *
  2193. * There are composite devices for which we want to ignore only a certain
  2194. * interface. This is a list of devices for which only the mouse interface will
  2195. * be ignored. This allows a dedicated driver to take care of the interface.
  2196. */
  2197. static const struct hid_device_id hid_mouse_ignore_list[] = {
  2198. /* appletouch driver */
  2199. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
  2200. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
  2201. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
  2202. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) },
  2203. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) },
  2204. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) },
  2205. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) },
  2206. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) },
  2207. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) },
  2208. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) },
  2209. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) },
  2210. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) },
  2211. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) },
  2212. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) },
  2213. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) },
  2214. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) },
  2215. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) },
  2216. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
  2217. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
  2218. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
  2219. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
  2220. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
  2221. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
  2222. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) },
  2223. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) },
  2224. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) },
  2225. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) },
  2226. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) },
  2227. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) },
  2228. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
  2229. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
  2230. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
  2231. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
  2232. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
  2233. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
  2234. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) },
  2235. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) },
  2236. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) },
  2237. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
  2238. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
  2239. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
  2240. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI) },
  2241. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO) },
  2242. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS) },
  2243. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI) },
  2244. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO) },
  2245. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS) },
  2246. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI) },
  2247. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO) },
  2248. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS) },
  2249. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) },
  2250. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
  2251. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
  2252. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
  2253. { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
  2254. { }
  2255. };
  2256. bool hid_ignore(struct hid_device *hdev)
  2257. {
  2258. if (hdev->quirks & HID_QUIRK_NO_IGNORE)
  2259. return false;
  2260. if (hdev->quirks & HID_QUIRK_IGNORE)
  2261. return true;
  2262. switch (hdev->vendor) {
  2263. case USB_VENDOR_ID_CODEMERCS:
  2264. /* ignore all Code Mercenaries IOWarrior devices */
  2265. if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST &&
  2266. hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST)
  2267. return true;
  2268. break;
  2269. case USB_VENDOR_ID_LOGITECH:
  2270. if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST &&
  2271. hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST)
  2272. return true;
  2273. /*
  2274. * The Keene FM transmitter USB device has the same USB ID as
  2275. * the Logitech AudioHub Speaker, but it should ignore the hid.
  2276. * Check if the name is that of the Keene device.
  2277. * For reference: the name of the AudioHub is
  2278. * "HOLTEK AudioHub Speaker".
  2279. */
  2280. if (hdev->product == USB_DEVICE_ID_LOGITECH_AUDIOHUB &&
  2281. !strcmp(hdev->name, "HOLTEK B-LINK USB Audio "))
  2282. return true;
  2283. break;
  2284. case USB_VENDOR_ID_SOUNDGRAPH:
  2285. if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST &&
  2286. hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST)
  2287. return true;
  2288. break;
  2289. case USB_VENDOR_ID_HANWANG:
  2290. if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST &&
  2291. hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST)
  2292. return true;
  2293. break;
  2294. case USB_VENDOR_ID_JESS:
  2295. if (hdev->product == USB_DEVICE_ID_JESS_YUREX &&
  2296. hdev->type == HID_TYPE_USBNONE)
  2297. return true;
  2298. break;
  2299. case USB_VENDOR_ID_VELLEMAN:
  2300. /* These are not HID devices. They are handled by comedi. */
  2301. if ((hdev->product >= USB_DEVICE_ID_VELLEMAN_K8055_FIRST &&
  2302. hdev->product <= USB_DEVICE_ID_VELLEMAN_K8055_LAST) ||
  2303. (hdev->product >= USB_DEVICE_ID_VELLEMAN_K8061_FIRST &&
  2304. hdev->product <= USB_DEVICE_ID_VELLEMAN_K8061_LAST))
  2305. return true;
  2306. break;
  2307. case USB_VENDOR_ID_ATMEL_V_USB:
  2308. /* Masterkit MA901 usb radio based on Atmel tiny85 chip and
  2309. * it has the same USB ID as many Atmel V-USB devices. This
  2310. * usb radio is handled by radio-ma901.c driver so we want
  2311. * ignore the hid. Check the name, bus, product and ignore
  2312. * if we have MA901 usb radio.
  2313. */
  2314. if (hdev->product == USB_DEVICE_ID_ATMEL_V_USB &&
  2315. hdev->bus == BUS_USB &&
  2316. strncmp(hdev->name, "www.masterkit.ru MA901", 22) == 0)
  2317. return true;
  2318. break;
  2319. }
  2320. if (hdev->type == HID_TYPE_USBMOUSE &&
  2321. hid_match_id(hdev, hid_mouse_ignore_list))
  2322. return true;
  2323. return !!hid_match_id(hdev, hid_ignore_list);
  2324. }
  2325. EXPORT_SYMBOL_GPL(hid_ignore);
  2326. int hid_add_device(struct hid_device *hdev)
  2327. {
  2328. static atomic_t id = ATOMIC_INIT(0);
  2329. int ret;
  2330. if (WARN_ON(hdev->status & HID_STAT_ADDED))
  2331. return -EBUSY;
  2332. /* we need to kill them here, otherwise they will stay allocated to
  2333. * wait for coming driver */
  2334. if (hid_ignore(hdev))
  2335. return -ENODEV;
  2336. /*
  2337. * Check for the mandatory transport channel.
  2338. */
  2339. if (!hdev->ll_driver->raw_request) {
  2340. hid_err(hdev, "transport driver missing .raw_request()\n");
  2341. return -EINVAL;
  2342. }
  2343. /*
  2344. * Read the device report descriptor once and use as template
  2345. * for the driver-specific modifications.
  2346. */
  2347. ret = hdev->ll_driver->parse(hdev);
  2348. if (ret)
  2349. return ret;
  2350. if (!hdev->dev_rdesc)
  2351. return -ENODEV;
  2352. /*
  2353. * Scan generic devices for group information
  2354. */
  2355. if (hid_ignore_special_drivers) {
  2356. hdev->group = HID_GROUP_GENERIC;
  2357. } else if (!hdev->group &&
  2358. !hid_match_id(hdev, hid_have_special_driver)) {
  2359. ret = hid_scan_report(hdev);
  2360. if (ret)
  2361. hid_warn(hdev, "bad device descriptor (%d)\n", ret);
  2362. }
  2363. /* XXX hack, any other cleaner solution after the driver core
  2364. * is converted to allow more than 20 bytes as the device name? */
  2365. dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
  2366. hdev->vendor, hdev->product, atomic_inc_return(&id));
  2367. hid_debug_register(hdev, dev_name(&hdev->dev));
  2368. ret = device_add(&hdev->dev);
  2369. if (!ret)
  2370. hdev->status |= HID_STAT_ADDED;
  2371. else
  2372. hid_debug_unregister(hdev);
  2373. return ret;
  2374. }
  2375. EXPORT_SYMBOL_GPL(hid_add_device);
  2376. /**
  2377. * hid_allocate_device - allocate new hid device descriptor
  2378. *
  2379. * Allocate and initialize hid device, so that hid_destroy_device might be
  2380. * used to free it.
  2381. *
  2382. * New hid_device pointer is returned on success, otherwise ERR_PTR encoded
  2383. * error value.
  2384. */
  2385. struct hid_device *hid_allocate_device(void)
  2386. {
  2387. struct hid_device *hdev;
  2388. int ret = -ENOMEM;
  2389. hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
  2390. if (hdev == NULL)
  2391. return ERR_PTR(ret);
  2392. device_initialize(&hdev->dev);
  2393. hdev->dev.release = hid_device_release;
  2394. hdev->dev.bus = &hid_bus_type;
  2395. device_enable_async_suspend(&hdev->dev);
  2396. hid_close_report(hdev);
  2397. init_waitqueue_head(&hdev->debug_wait);
  2398. INIT_LIST_HEAD(&hdev->debug_list);
  2399. spin_lock_init(&hdev->debug_list_lock);
  2400. sema_init(&hdev->driver_lock, 1);
  2401. sema_init(&hdev->driver_input_lock, 1);
  2402. return hdev;
  2403. }
  2404. EXPORT_SYMBOL_GPL(hid_allocate_device);
  2405. static void hid_remove_device(struct hid_device *hdev)
  2406. {
  2407. if (hdev->status & HID_STAT_ADDED) {
  2408. device_del(&hdev->dev);
  2409. hid_debug_unregister(hdev);
  2410. hdev->status &= ~HID_STAT_ADDED;
  2411. }
  2412. kfree(hdev->dev_rdesc);
  2413. hdev->dev_rdesc = NULL;
  2414. hdev->dev_rsize = 0;
  2415. }
  2416. /**
  2417. * hid_destroy_device - free previously allocated device
  2418. *
  2419. * @hdev: hid device
  2420. *
  2421. * If you allocate hid_device through hid_allocate_device, you should ever
  2422. * free by this function.
  2423. */
  2424. void hid_destroy_device(struct hid_device *hdev)
  2425. {
  2426. hid_remove_device(hdev);
  2427. put_device(&hdev->dev);
  2428. }
  2429. EXPORT_SYMBOL_GPL(hid_destroy_device);
  2430. int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
  2431. const char *mod_name)
  2432. {
  2433. int ret;
  2434. hdrv->driver.name = hdrv->name;
  2435. hdrv->driver.bus = &hid_bus_type;
  2436. hdrv->driver.owner = owner;
  2437. hdrv->driver.mod_name = mod_name;
  2438. INIT_LIST_HEAD(&hdrv->dyn_list);
  2439. spin_lock_init(&hdrv->dyn_lock);
  2440. ret = driver_register(&hdrv->driver);
  2441. if (ret)
  2442. return ret;
  2443. ret = driver_create_file(&hdrv->driver, &driver_attr_new_id);
  2444. if (ret)
  2445. driver_unregister(&hdrv->driver);
  2446. return ret;
  2447. }
  2448. EXPORT_SYMBOL_GPL(__hid_register_driver);
  2449. void hid_unregister_driver(struct hid_driver *hdrv)
  2450. {
  2451. driver_remove_file(&hdrv->driver, &driver_attr_new_id);
  2452. driver_unregister(&hdrv->driver);
  2453. hid_free_dynids(hdrv);
  2454. }
  2455. EXPORT_SYMBOL_GPL(hid_unregister_driver);
  2456. int hid_check_keys_pressed(struct hid_device *hid)
  2457. {
  2458. struct hid_input *hidinput;
  2459. int i;
  2460. if (!(hid->claimed & HID_CLAIMED_INPUT))
  2461. return 0;
  2462. list_for_each_entry(hidinput, &hid->inputs, list) {
  2463. for (i = 0; i < BITS_TO_LONGS(KEY_MAX); i++)
  2464. if (hidinput->input->key[i])
  2465. return 1;
  2466. }
  2467. return 0;
  2468. }
  2469. EXPORT_SYMBOL_GPL(hid_check_keys_pressed);
  2470. static int __init hid_init(void)
  2471. {
  2472. int ret;
  2473. if (hid_debug)
  2474. pr_warn("hid_debug is now used solely for parser and driver debugging.\n"
  2475. "debugfs is now used for inspecting the device (report descriptor, reports)\n");
  2476. ret = bus_register(&hid_bus_type);
  2477. if (ret) {
  2478. pr_err("can't register hid bus\n");
  2479. goto err;
  2480. }
  2481. ret = hidraw_init();
  2482. if (ret)
  2483. goto err_bus;
  2484. hid_debug_init();
  2485. return 0;
  2486. err_bus:
  2487. bus_unregister(&hid_bus_type);
  2488. err:
  2489. return ret;
  2490. }
  2491. static void __exit hid_exit(void)
  2492. {
  2493. hid_debug_exit();
  2494. hidraw_exit();
  2495. bus_unregister(&hid_bus_type);
  2496. }
  2497. module_init(hid_init);
  2498. module_exit(hid_exit);
  2499. MODULE_AUTHOR("Andreas Gal");
  2500. MODULE_AUTHOR("Vojtech Pavlik");
  2501. MODULE_AUTHOR("Jiri Kosina");
  2502. MODULE_LICENSE(DRIVER_LICENSE);