hid-debug.c 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * (c) 1999 Andreas Gal <[email protected]>
  4. * (c) 2000-2001 Vojtech Pavlik <[email protected]>
  5. * (c) 2007-2009 Jiri Kosina
  6. *
  7. * HID debugging support
  8. */
  9. /*
  10. *
  11. * Should you need to contact me, the author, you can do so either by
  12. * e-mail - mail your message to <[email protected]>, or by paper mail:
  13. * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
  14. */
  15. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  16. #include <linux/debugfs.h>
  17. #include <linux/seq_file.h>
  18. #include <linux/kfifo.h>
  19. #include <linux/sched/signal.h>
  20. #include <linux/export.h>
  21. #include <linux/slab.h>
  22. #include <linux/uaccess.h>
  23. #include <linux/poll.h>
  24. #include <linux/hid.h>
  25. #include <linux/hid-debug.h>
  26. static struct dentry *hid_debug_root;
  27. struct hid_usage_entry {
  28. unsigned page;
  29. unsigned usage;
  30. const char *description;
  31. };
  32. static const struct hid_usage_entry hid_usage_table[] = {
  33. { 0, 0, "Undefined" },
  34. { 1, 0, "GenericDesktop" },
  35. {0, 0x01, "Pointer"},
  36. {0, 0x02, "Mouse"},
  37. {0, 0x04, "Joystick"},
  38. {0, 0x05, "GamePad"},
  39. {0, 0x06, "Keyboard"},
  40. {0, 0x07, "Keypad"},
  41. {0, 0x08, "MultiAxis"},
  42. {0, 0x30, "X"},
  43. {0, 0x31, "Y"},
  44. {0, 0x32, "Z"},
  45. {0, 0x33, "Rx"},
  46. {0, 0x34, "Ry"},
  47. {0, 0x35, "Rz"},
  48. {0, 0x36, "Slider"},
  49. {0, 0x37, "Dial"},
  50. {0, 0x38, "Wheel"},
  51. {0, 0x39, "HatSwitch"},
  52. {0, 0x3a, "CountedBuffer"},
  53. {0, 0x3b, "ByteCount"},
  54. {0, 0x3c, "MotionWakeup"},
  55. {0, 0x3d, "Start"},
  56. {0, 0x3e, "Select"},
  57. {0, 0x40, "Vx"},
  58. {0, 0x41, "Vy"},
  59. {0, 0x42, "Vz"},
  60. {0, 0x43, "Vbrx"},
  61. {0, 0x44, "Vbry"},
  62. {0, 0x45, "Vbrz"},
  63. {0, 0x46, "Vno"},
  64. {0, 0x80, "SystemControl"},
  65. {0, 0x81, "SystemPowerDown"},
  66. {0, 0x82, "SystemSleep"},
  67. {0, 0x83, "SystemWakeUp"},
  68. {0, 0x84, "SystemContextMenu"},
  69. {0, 0x85, "SystemMainMenu"},
  70. {0, 0x86, "SystemAppMenu"},
  71. {0, 0x87, "SystemMenuHelp"},
  72. {0, 0x88, "SystemMenuExit"},
  73. {0, 0x89, "SystemMenuSelect"},
  74. {0, 0x8a, "SystemMenuRight"},
  75. {0, 0x8b, "SystemMenuLeft"},
  76. {0, 0x8c, "SystemMenuUp"},
  77. {0, 0x8d, "SystemMenuDown"},
  78. {0, 0x90, "D-PadUp"},
  79. {0, 0x91, "D-PadDown"},
  80. {0, 0x92, "D-PadRight"},
  81. {0, 0x93, "D-PadLeft"},
  82. { 2, 0, "Simulation" },
  83. {0, 0xb0, "Aileron"},
  84. {0, 0xb1, "AileronTrim"},
  85. {0, 0xb2, "Anti-Torque"},
  86. {0, 0xb3, "Autopilot"},
  87. {0, 0xb4, "Chaff"},
  88. {0, 0xb5, "Collective"},
  89. {0, 0xb6, "DiveBrake"},
  90. {0, 0xb7, "ElectronicCountermeasures"},
  91. {0, 0xb8, "Elevator"},
  92. {0, 0xb9, "ElevatorTrim"},
  93. {0, 0xba, "Rudder"},
  94. {0, 0xbb, "Throttle"},
  95. {0, 0xbc, "FlightCommunications"},
  96. {0, 0xbd, "FlareRelease"},
  97. {0, 0xbe, "LandingGear"},
  98. {0, 0xbf, "ToeBrake"},
  99. { 6, 0, "GenericDeviceControls" },
  100. {0, 0x20, "BatteryStrength" },
  101. {0, 0x21, "WirelessChannel" },
  102. {0, 0x22, "WirelessID" },
  103. {0, 0x23, "DiscoverWirelessControl" },
  104. {0, 0x24, "SecurityCodeCharacterEntered" },
  105. {0, 0x25, "SecurityCodeCharactedErased" },
  106. {0, 0x26, "SecurityCodeCleared" },
  107. { 7, 0, "Keyboard" },
  108. { 8, 0, "LED" },
  109. {0, 0x01, "NumLock"},
  110. {0, 0x02, "CapsLock"},
  111. {0, 0x03, "ScrollLock"},
  112. {0, 0x04, "Compose"},
  113. {0, 0x05, "Kana"},
  114. {0, 0x4b, "GenericIndicator"},
  115. { 9, 0, "Button" },
  116. { 10, 0, "Ordinal" },
  117. { 12, 0, "Consumer" },
  118. {0, 0x003, "ProgrammableButtons"},
  119. {0, 0x238, "HorizontalWheel"},
  120. { 13, 0, "Digitizers" },
  121. {0, 0x01, "Digitizer"},
  122. {0, 0x02, "Pen"},
  123. {0, 0x03, "LightPen"},
  124. {0, 0x04, "TouchScreen"},
  125. {0, 0x05, "TouchPad"},
  126. {0, 0x0e, "DeviceConfiguration"},
  127. {0, 0x20, "Stylus"},
  128. {0, 0x21, "Puck"},
  129. {0, 0x22, "Finger"},
  130. {0, 0x23, "DeviceSettings"},
  131. {0, 0x30, "TipPressure"},
  132. {0, 0x31, "BarrelPressure"},
  133. {0, 0x32, "InRange"},
  134. {0, 0x33, "Touch"},
  135. {0, 0x34, "UnTouch"},
  136. {0, 0x35, "Tap"},
  137. {0, 0x38, "Transducer Index"},
  138. {0, 0x39, "TabletFunctionKey"},
  139. {0, 0x3a, "ProgramChangeKey"},
  140. {0, 0x3B, "Battery Strength"},
  141. {0, 0x3c, "Invert"},
  142. {0, 0x42, "TipSwitch"},
  143. {0, 0x43, "SecondaryTipSwitch"},
  144. {0, 0x44, "BarrelSwitch"},
  145. {0, 0x45, "Eraser"},
  146. {0, 0x46, "TabletPick"},
  147. {0, 0x47, "Confidence"},
  148. {0, 0x48, "Width"},
  149. {0, 0x49, "Height"},
  150. {0, 0x51, "ContactID"},
  151. {0, 0x52, "InputMode"},
  152. {0, 0x53, "DeviceIndex"},
  153. {0, 0x54, "ContactCount"},
  154. {0, 0x55, "ContactMaximumNumber"},
  155. {0, 0x59, "ButtonType"},
  156. {0, 0x5A, "SecondaryBarrelSwitch"},
  157. {0, 0x5B, "TransducerSerialNumber"},
  158. {0, 0x5C, "Preferred Color"},
  159. {0, 0x5D, "Preferred Color is Locked"},
  160. {0, 0x5E, "Preferred Line Width"},
  161. {0, 0x5F, "Preferred Line Width is Locked"},
  162. {0, 0x6e, "TransducerSerialNumber2"},
  163. {0, 0x70, "Preferred Line Style"},
  164. {0, 0x71, "Preferred Line Style is Locked"},
  165. {0, 0x72, "Ink"},
  166. {0, 0x73, "Pencil"},
  167. {0, 0x74, "Highlighter"},
  168. {0, 0x75, "Chisel Marker"},
  169. {0, 0x76, "Brush"},
  170. {0, 0x77, "No Preference"},
  171. {0, 0x80, "Digitizer Diagnostic"},
  172. {0, 0x81, "Digitizer Error"},
  173. {0, 0x82, "Err Normal Status"},
  174. {0, 0x83, "Err Transducers Exceeded"},
  175. {0, 0x84, "Err Full Trans Features Unavailable"},
  176. {0, 0x85, "Err Charge Low"},
  177. {0, 0x90, "Transducer Software Info"},
  178. {0, 0x91, "Transducer Vendor Id"},
  179. {0, 0x92, "Transducer Product Id"},
  180. {0, 0x93, "Device Supported Protocols"},
  181. {0, 0x94, "Transducer Supported Protocols"},
  182. {0, 0x95, "No Protocol"},
  183. {0, 0x96, "Wacom AES Protocol"},
  184. {0, 0x97, "USI Protocol"},
  185. {0, 0x98, "Microsoft Pen Protocol"},
  186. {0, 0xA0, "Supported Report Rates"},
  187. {0, 0xA1, "Report Rate"},
  188. {0, 0xA2, "Transducer Connected"},
  189. {0, 0xA3, "Switch Disabled"},
  190. {0, 0xA4, "Switch Unimplemented"},
  191. {0, 0xA5, "Transducer Switches"},
  192. { 15, 0, "PhysicalInterfaceDevice" },
  193. {0, 0x00, "Undefined"},
  194. {0, 0x01, "Physical_Interface_Device"},
  195. {0, 0x20, "Normal"},
  196. {0, 0x21, "Set_Effect_Report"},
  197. {0, 0x22, "Effect_Block_Index"},
  198. {0, 0x23, "Parameter_Block_Offset"},
  199. {0, 0x24, "ROM_Flag"},
  200. {0, 0x25, "Effect_Type"},
  201. {0, 0x26, "ET_Constant_Force"},
  202. {0, 0x27, "ET_Ramp"},
  203. {0, 0x28, "ET_Custom_Force_Data"},
  204. {0, 0x30, "ET_Square"},
  205. {0, 0x31, "ET_Sine"},
  206. {0, 0x32, "ET_Triangle"},
  207. {0, 0x33, "ET_Sawtooth_Up"},
  208. {0, 0x34, "ET_Sawtooth_Down"},
  209. {0, 0x40, "ET_Spring"},
  210. {0, 0x41, "ET_Damper"},
  211. {0, 0x42, "ET_Inertia"},
  212. {0, 0x43, "ET_Friction"},
  213. {0, 0x50, "Duration"},
  214. {0, 0x51, "Sample_Period"},
  215. {0, 0x52, "Gain"},
  216. {0, 0x53, "Trigger_Button"},
  217. {0, 0x54, "Trigger_Repeat_Interval"},
  218. {0, 0x55, "Axes_Enable"},
  219. {0, 0x56, "Direction_Enable"},
  220. {0, 0x57, "Direction"},
  221. {0, 0x58, "Type_Specific_Block_Offset"},
  222. {0, 0x59, "Block_Type"},
  223. {0, 0x5A, "Set_Envelope_Report"},
  224. {0, 0x5B, "Attack_Level"},
  225. {0, 0x5C, "Attack_Time"},
  226. {0, 0x5D, "Fade_Level"},
  227. {0, 0x5E, "Fade_Time"},
  228. {0, 0x5F, "Set_Condition_Report"},
  229. {0, 0x60, "CP_Offset"},
  230. {0, 0x61, "Positive_Coefficient"},
  231. {0, 0x62, "Negative_Coefficient"},
  232. {0, 0x63, "Positive_Saturation"},
  233. {0, 0x64, "Negative_Saturation"},
  234. {0, 0x65, "Dead_Band"},
  235. {0, 0x66, "Download_Force_Sample"},
  236. {0, 0x67, "Isoch_Custom_Force_Enable"},
  237. {0, 0x68, "Custom_Force_Data_Report"},
  238. {0, 0x69, "Custom_Force_Data"},
  239. {0, 0x6A, "Custom_Force_Vendor_Defined_Data"},
  240. {0, 0x6B, "Set_Custom_Force_Report"},
  241. {0, 0x6C, "Custom_Force_Data_Offset"},
  242. {0, 0x6D, "Sample_Count"},
  243. {0, 0x6E, "Set_Periodic_Report"},
  244. {0, 0x6F, "Offset"},
  245. {0, 0x70, "Magnitude"},
  246. {0, 0x71, "Phase"},
  247. {0, 0x72, "Period"},
  248. {0, 0x73, "Set_Constant_Force_Report"},
  249. {0, 0x74, "Set_Ramp_Force_Report"},
  250. {0, 0x75, "Ramp_Start"},
  251. {0, 0x76, "Ramp_End"},
  252. {0, 0x77, "Effect_Operation_Report"},
  253. {0, 0x78, "Effect_Operation"},
  254. {0, 0x79, "Op_Effect_Start"},
  255. {0, 0x7A, "Op_Effect_Start_Solo"},
  256. {0, 0x7B, "Op_Effect_Stop"},
  257. {0, 0x7C, "Loop_Count"},
  258. {0, 0x7D, "Device_Gain_Report"},
  259. {0, 0x7E, "Device_Gain"},
  260. {0, 0x7F, "PID_Pool_Report"},
  261. {0, 0x80, "RAM_Pool_Size"},
  262. {0, 0x81, "ROM_Pool_Size"},
  263. {0, 0x82, "ROM_Effect_Block_Count"},
  264. {0, 0x83, "Simultaneous_Effects_Max"},
  265. {0, 0x84, "Pool_Alignment"},
  266. {0, 0x85, "PID_Pool_Move_Report"},
  267. {0, 0x86, "Move_Source"},
  268. {0, 0x87, "Move_Destination"},
  269. {0, 0x88, "Move_Length"},
  270. {0, 0x89, "PID_Block_Load_Report"},
  271. {0, 0x8B, "Block_Load_Status"},
  272. {0, 0x8C, "Block_Load_Success"},
  273. {0, 0x8D, "Block_Load_Full"},
  274. {0, 0x8E, "Block_Load_Error"},
  275. {0, 0x8F, "Block_Handle"},
  276. {0, 0x90, "PID_Block_Free_Report"},
  277. {0, 0x91, "Type_Specific_Block_Handle"},
  278. {0, 0x92, "PID_State_Report"},
  279. {0, 0x94, "Effect_Playing"},
  280. {0, 0x95, "PID_Device_Control_Report"},
  281. {0, 0x96, "PID_Device_Control"},
  282. {0, 0x97, "DC_Enable_Actuators"},
  283. {0, 0x98, "DC_Disable_Actuators"},
  284. {0, 0x99, "DC_Stop_All_Effects"},
  285. {0, 0x9A, "DC_Device_Reset"},
  286. {0, 0x9B, "DC_Device_Pause"},
  287. {0, 0x9C, "DC_Device_Continue"},
  288. {0, 0x9F, "Device_Paused"},
  289. {0, 0xA0, "Actuators_Enabled"},
  290. {0, 0xA4, "Safety_Switch"},
  291. {0, 0xA5, "Actuator_Override_Switch"},
  292. {0, 0xA6, "Actuator_Power"},
  293. {0, 0xA7, "Start_Delay"},
  294. {0, 0xA8, "Parameter_Block_Size"},
  295. {0, 0xA9, "Device_Managed_Pool"},
  296. {0, 0xAA, "Shared_Parameter_Blocks"},
  297. {0, 0xAB, "Create_New_Effect_Report"},
  298. {0, 0xAC, "RAM_Pool_Available"},
  299. { 0x20, 0, "Sensor" },
  300. { 0x20, 0x01, "Sensor" },
  301. { 0x20, 0x10, "Biometric" },
  302. { 0x20, 0x11, "BiometricHumanPresence" },
  303. { 0x20, 0x12, "BiometricHumanProximity" },
  304. { 0x20, 0x13, "BiometricHumanTouch" },
  305. { 0x20, 0x20, "Electrical" },
  306. { 0x20, 0x21, "ElectricalCapacitance" },
  307. { 0x20, 0x22, "ElectricalCurrent" },
  308. { 0x20, 0x23, "ElectricalPower" },
  309. { 0x20, 0x24, "ElectricalInductance" },
  310. { 0x20, 0x25, "ElectricalResistance" },
  311. { 0x20, 0x26, "ElectricalVoltage" },
  312. { 0x20, 0x27, "ElectricalPoteniometer" },
  313. { 0x20, 0x28, "ElectricalFrequency" },
  314. { 0x20, 0x29, "ElectricalPeriod" },
  315. { 0x20, 0x30, "Environmental" },
  316. { 0x20, 0x31, "EnvironmentalAtmosphericPressure" },
  317. { 0x20, 0x32, "EnvironmentalHumidity" },
  318. { 0x20, 0x33, "EnvironmentalTemperature" },
  319. { 0x20, 0x34, "EnvironmentalWindDirection" },
  320. { 0x20, 0x35, "EnvironmentalWindSpeed" },
  321. { 0x20, 0x40, "Light" },
  322. { 0x20, 0x41, "LightAmbientLight" },
  323. { 0x20, 0x42, "LightConsumerInfrared" },
  324. { 0x20, 0x50, "Location" },
  325. { 0x20, 0x51, "LocationBroadcast" },
  326. { 0x20, 0x52, "LocationDeadReckoning" },
  327. { 0x20, 0x53, "LocationGPS" },
  328. { 0x20, 0x54, "LocationLookup" },
  329. { 0x20, 0x55, "LocationOther" },
  330. { 0x20, 0x56, "LocationStatic" },
  331. { 0x20, 0x57, "LocationTriangulation" },
  332. { 0x20, 0x60, "Mechanical" },
  333. { 0x20, 0x61, "MechanicalBooleanSwitch" },
  334. { 0x20, 0x62, "MechanicalBooleanSwitchArray" },
  335. { 0x20, 0x63, "MechanicalMultivalueSwitch" },
  336. { 0x20, 0x64, "MechanicalForce" },
  337. { 0x20, 0x65, "MechanicalPressure" },
  338. { 0x20, 0x66, "MechanicalStrain" },
  339. { 0x20, 0x67, "MechanicalWeight" },
  340. { 0x20, 0x68, "MechanicalHapticVibrator" },
  341. { 0x20, 0x69, "MechanicalHallEffectSwitch" },
  342. { 0x20, 0x70, "Motion" },
  343. { 0x20, 0x71, "MotionAccelerometer1D" },
  344. { 0x20, 0x72, "MotionAccelerometer2D" },
  345. { 0x20, 0x73, "MotionAccelerometer3D" },
  346. { 0x20, 0x74, "MotionGyrometer1D" },
  347. { 0x20, 0x75, "MotionGyrometer2D" },
  348. { 0x20, 0x76, "MotionGyrometer3D" },
  349. { 0x20, 0x77, "MotionMotionDetector" },
  350. { 0x20, 0x78, "MotionSpeedometer" },
  351. { 0x20, 0x79, "MotionAccelerometer" },
  352. { 0x20, 0x7A, "MotionGyrometer" },
  353. { 0x20, 0x80, "Orientation" },
  354. { 0x20, 0x81, "OrientationCompass1D" },
  355. { 0x20, 0x82, "OrientationCompass2D" },
  356. { 0x20, 0x83, "OrientationCompass3D" },
  357. { 0x20, 0x84, "OrientationInclinometer1D" },
  358. { 0x20, 0x85, "OrientationInclinometer2D" },
  359. { 0x20, 0x86, "OrientationInclinometer3D" },
  360. { 0x20, 0x87, "OrientationDistance1D" },
  361. { 0x20, 0x88, "OrientationDistance2D" },
  362. { 0x20, 0x89, "OrientationDistance3D" },
  363. { 0x20, 0x8A, "OrientationDeviceOrientation" },
  364. { 0x20, 0x8B, "OrientationCompass" },
  365. { 0x20, 0x8C, "OrientationInclinometer" },
  366. { 0x20, 0x8D, "OrientationDistance" },
  367. { 0x20, 0x90, "Scanner" },
  368. { 0x20, 0x91, "ScannerBarcode" },
  369. { 0x20, 0x91, "ScannerRFID" },
  370. { 0x20, 0x91, "ScannerNFC" },
  371. { 0x20, 0xA0, "Time" },
  372. { 0x20, 0xA1, "TimeAlarmTimer" },
  373. { 0x20, 0xA2, "TimeRealTimeClock" },
  374. { 0x20, 0xE0, "Other" },
  375. { 0x20, 0xE1, "OtherCustom" },
  376. { 0x20, 0xE2, "OtherGeneric" },
  377. { 0x20, 0xE3, "OtherGenericEnumerator" },
  378. { 0x84, 0, "Power Device" },
  379. { 0x84, 0x02, "PresentStatus" },
  380. { 0x84, 0x03, "ChangeStatus" },
  381. { 0x84, 0x04, "UPS" },
  382. { 0x84, 0x05, "PowerSupply" },
  383. { 0x84, 0x10, "BatterySystem" },
  384. { 0x84, 0x11, "BatterySystemID" },
  385. { 0x84, 0x12, "Battery" },
  386. { 0x84, 0x13, "BatteryID" },
  387. { 0x84, 0x14, "Charger" },
  388. { 0x84, 0x15, "ChargerID" },
  389. { 0x84, 0x16, "PowerConverter" },
  390. { 0x84, 0x17, "PowerConverterID" },
  391. { 0x84, 0x18, "OutletSystem" },
  392. { 0x84, 0x19, "OutletSystemID" },
  393. { 0x84, 0x1a, "Input" },
  394. { 0x84, 0x1b, "InputID" },
  395. { 0x84, 0x1c, "Output" },
  396. { 0x84, 0x1d, "OutputID" },
  397. { 0x84, 0x1e, "Flow" },
  398. { 0x84, 0x1f, "FlowID" },
  399. { 0x84, 0x20, "Outlet" },
  400. { 0x84, 0x21, "OutletID" },
  401. { 0x84, 0x22, "Gang" },
  402. { 0x84, 0x24, "PowerSummary" },
  403. { 0x84, 0x25, "PowerSummaryID" },
  404. { 0x84, 0x30, "Voltage" },
  405. { 0x84, 0x31, "Current" },
  406. { 0x84, 0x32, "Frequency" },
  407. { 0x84, 0x33, "ApparentPower" },
  408. { 0x84, 0x35, "PercentLoad" },
  409. { 0x84, 0x40, "ConfigVoltage" },
  410. { 0x84, 0x41, "ConfigCurrent" },
  411. { 0x84, 0x43, "ConfigApparentPower" },
  412. { 0x84, 0x53, "LowVoltageTransfer" },
  413. { 0x84, 0x54, "HighVoltageTransfer" },
  414. { 0x84, 0x56, "DelayBeforeStartup" },
  415. { 0x84, 0x57, "DelayBeforeShutdown" },
  416. { 0x84, 0x58, "Test" },
  417. { 0x84, 0x5a, "AudibleAlarmControl" },
  418. { 0x84, 0x60, "Present" },
  419. { 0x84, 0x61, "Good" },
  420. { 0x84, 0x62, "InternalFailure" },
  421. { 0x84, 0x65, "Overload" },
  422. { 0x84, 0x66, "OverCharged" },
  423. { 0x84, 0x67, "OverTemperature" },
  424. { 0x84, 0x68, "ShutdownRequested" },
  425. { 0x84, 0x69, "ShutdownImminent" },
  426. { 0x84, 0x6b, "SwitchOn/Off" },
  427. { 0x84, 0x6c, "Switchable" },
  428. { 0x84, 0x6d, "Used" },
  429. { 0x84, 0x6e, "Boost" },
  430. { 0x84, 0x73, "CommunicationLost" },
  431. { 0x84, 0xfd, "iManufacturer" },
  432. { 0x84, 0xfe, "iProduct" },
  433. { 0x84, 0xff, "iSerialNumber" },
  434. { 0x85, 0, "Battery System" },
  435. { 0x85, 0x01, "SMBBatteryMode" },
  436. { 0x85, 0x02, "SMBBatteryStatus" },
  437. { 0x85, 0x03, "SMBAlarmWarning" },
  438. { 0x85, 0x04, "SMBChargerMode" },
  439. { 0x85, 0x05, "SMBChargerStatus" },
  440. { 0x85, 0x06, "SMBChargerSpecInfo" },
  441. { 0x85, 0x07, "SMBSelectorState" },
  442. { 0x85, 0x08, "SMBSelectorPresets" },
  443. { 0x85, 0x09, "SMBSelectorInfo" },
  444. { 0x85, 0x29, "RemainingCapacityLimit" },
  445. { 0x85, 0x2c, "CapacityMode" },
  446. { 0x85, 0x42, "BelowRemainingCapacityLimit" },
  447. { 0x85, 0x44, "Charging" },
  448. { 0x85, 0x45, "Discharging" },
  449. { 0x85, 0x4b, "NeedReplacement" },
  450. { 0x85, 0x65, "AbsoluteStateOfCharge" },
  451. { 0x85, 0x66, "RemainingCapacity" },
  452. { 0x85, 0x68, "RunTimeToEmpty" },
  453. { 0x85, 0x6a, "AverageTimeToFull" },
  454. { 0x85, 0x83, "DesignCapacity" },
  455. { 0x85, 0x85, "ManufacturerDate" },
  456. { 0x85, 0x89, "iDeviceChemistry" },
  457. { 0x85, 0x8b, "Rechargeable" },
  458. { 0x85, 0x8f, "iOEMInformation" },
  459. { 0x85, 0x8d, "CapacityGranularity1" },
  460. { 0x85, 0xd0, "ACPresent" },
  461. /* pages 0xff00 to 0xffff are vendor-specific */
  462. { 0xffff, 0, "Vendor-specific-FF" },
  463. { 0, 0, NULL }
  464. };
  465. /* Either output directly into simple seq_file, or (if f == NULL)
  466. * allocate a separate buffer that will then be passed to the 'events'
  467. * ringbuffer.
  468. *
  469. * This is because these functions can be called both for "one-shot"
  470. * "rdesc" while resolving, or for blocking "events".
  471. *
  472. * This holds both for resolv_usage_page() and hid_resolv_usage().
  473. */
  474. static char *resolv_usage_page(unsigned page, struct seq_file *f) {
  475. const struct hid_usage_entry *p;
  476. char *buf = NULL;
  477. if (!f) {
  478. buf = kzalloc(HID_DEBUG_BUFSIZE, GFP_ATOMIC);
  479. if (!buf)
  480. return ERR_PTR(-ENOMEM);
  481. }
  482. for (p = hid_usage_table; p->description; p++)
  483. if (p->page == page) {
  484. if (!f) {
  485. snprintf(buf, HID_DEBUG_BUFSIZE, "%s",
  486. p->description);
  487. return buf;
  488. }
  489. else {
  490. seq_printf(f, "%s", p->description);
  491. return NULL;
  492. }
  493. }
  494. if (!f)
  495. snprintf(buf, HID_DEBUG_BUFSIZE, "%04x", page);
  496. else
  497. seq_printf(f, "%04x", page);
  498. return buf;
  499. }
  500. char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
  501. const struct hid_usage_entry *p;
  502. char *buf = NULL;
  503. int len = 0;
  504. buf = resolv_usage_page(usage >> 16, f);
  505. if (IS_ERR(buf)) {
  506. pr_err("error allocating HID debug buffer\n");
  507. return NULL;
  508. }
  509. if (!f) {
  510. len = strlen(buf);
  511. len += scnprintf(buf + len, HID_DEBUG_BUFSIZE - len, ".");
  512. }
  513. else {
  514. seq_printf(f, ".");
  515. }
  516. for (p = hid_usage_table; p->description; p++)
  517. if (p->page == (usage >> 16)) {
  518. for(++p; p->description && p->usage != 0; p++)
  519. if (p->usage == (usage & 0xffff)) {
  520. if (!f)
  521. snprintf(buf + len,
  522. HID_DEBUG_BUFSIZE - len,
  523. "%s", p->description);
  524. else
  525. seq_printf(f,
  526. "%s",
  527. p->description);
  528. return buf;
  529. }
  530. break;
  531. }
  532. if (!f)
  533. snprintf(buf + len, HID_DEBUG_BUFSIZE - len, "%04x",
  534. usage & 0xffff);
  535. else
  536. seq_printf(f, "%04x", usage & 0xffff);
  537. return buf;
  538. }
  539. EXPORT_SYMBOL_GPL(hid_resolv_usage);
  540. static void tab(int n, struct seq_file *f) {
  541. seq_printf(f, "%*s", n, "");
  542. }
  543. void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
  544. int j;
  545. if (field->physical) {
  546. tab(n, f);
  547. seq_printf(f, "Physical(");
  548. hid_resolv_usage(field->physical, f); seq_printf(f, ")\n");
  549. }
  550. if (field->logical) {
  551. tab(n, f);
  552. seq_printf(f, "Logical(");
  553. hid_resolv_usage(field->logical, f); seq_printf(f, ")\n");
  554. }
  555. if (field->application) {
  556. tab(n, f);
  557. seq_printf(f, "Application(");
  558. hid_resolv_usage(field->application, f); seq_printf(f, ")\n");
  559. }
  560. tab(n, f); seq_printf(f, "Usage(%d)\n", field->maxusage);
  561. for (j = 0; j < field->maxusage; j++) {
  562. tab(n+2, f); hid_resolv_usage(field->usage[j].hid, f); seq_printf(f, "\n");
  563. }
  564. if (field->logical_minimum != field->logical_maximum) {
  565. tab(n, f); seq_printf(f, "Logical Minimum(%d)\n", field->logical_minimum);
  566. tab(n, f); seq_printf(f, "Logical Maximum(%d)\n", field->logical_maximum);
  567. }
  568. if (field->physical_minimum != field->physical_maximum) {
  569. tab(n, f); seq_printf(f, "Physical Minimum(%d)\n", field->physical_minimum);
  570. tab(n, f); seq_printf(f, "Physical Maximum(%d)\n", field->physical_maximum);
  571. }
  572. if (field->unit_exponent) {
  573. tab(n, f); seq_printf(f, "Unit Exponent(%d)\n", field->unit_exponent);
  574. }
  575. if (field->unit) {
  576. static const char *systems[5] = { "None", "SI Linear", "SI Rotation", "English Linear", "English Rotation" };
  577. static const char *units[5][8] = {
  578. { "None", "None", "None", "None", "None", "None", "None", "None" },
  579. { "None", "Centimeter", "Gram", "Seconds", "Kelvin", "Ampere", "Candela", "None" },
  580. { "None", "Radians", "Gram", "Seconds", "Kelvin", "Ampere", "Candela", "None" },
  581. { "None", "Inch", "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" },
  582. { "None", "Degrees", "Slug", "Seconds", "Fahrenheit", "Ampere", "Candela", "None" }
  583. };
  584. int i;
  585. int sys;
  586. __u32 data = field->unit;
  587. /* First nibble tells us which system we're in. */
  588. sys = data & 0xf;
  589. data >>= 4;
  590. if(sys > 4) {
  591. tab(n, f); seq_printf(f, "Unit(Invalid)\n");
  592. }
  593. else {
  594. int earlier_unit = 0;
  595. tab(n, f); seq_printf(f, "Unit(%s : ", systems[sys]);
  596. for (i=1 ; i<sizeof(__u32)*2 ; i++) {
  597. char nibble = data & 0xf;
  598. data >>= 4;
  599. if (nibble != 0) {
  600. if(earlier_unit++ > 0)
  601. seq_printf(f, "*");
  602. seq_printf(f, "%s", units[sys][i]);
  603. if(nibble != 1) {
  604. /* This is a _signed_ nibble(!) */
  605. int val = nibble & 0x7;
  606. if(nibble & 0x08)
  607. val = -((0x7 & ~val) +1);
  608. seq_printf(f, "^%d", val);
  609. }
  610. }
  611. }
  612. seq_printf(f, ")\n");
  613. }
  614. }
  615. tab(n, f); seq_printf(f, "Report Size(%u)\n", field->report_size);
  616. tab(n, f); seq_printf(f, "Report Count(%u)\n", field->report_count);
  617. tab(n, f); seq_printf(f, "Report Offset(%u)\n", field->report_offset);
  618. tab(n, f); seq_printf(f, "Flags( ");
  619. j = field->flags;
  620. seq_printf(f, "%s", HID_MAIN_ITEM_CONSTANT & j ? "Constant " : "");
  621. seq_printf(f, "%s", HID_MAIN_ITEM_VARIABLE & j ? "Variable " : "Array ");
  622. seq_printf(f, "%s", HID_MAIN_ITEM_RELATIVE & j ? "Relative " : "Absolute ");
  623. seq_printf(f, "%s", HID_MAIN_ITEM_WRAP & j ? "Wrap " : "");
  624. seq_printf(f, "%s", HID_MAIN_ITEM_NONLINEAR & j ? "NonLinear " : "");
  625. seq_printf(f, "%s", HID_MAIN_ITEM_NO_PREFERRED & j ? "NoPreferredState " : "");
  626. seq_printf(f, "%s", HID_MAIN_ITEM_NULL_STATE & j ? "NullState " : "");
  627. seq_printf(f, "%s", HID_MAIN_ITEM_VOLATILE & j ? "Volatile " : "");
  628. seq_printf(f, "%s", HID_MAIN_ITEM_BUFFERED_BYTE & j ? "BufferedByte " : "");
  629. seq_printf(f, ")\n");
  630. }
  631. EXPORT_SYMBOL_GPL(hid_dump_field);
  632. void hid_dump_device(struct hid_device *device, struct seq_file *f)
  633. {
  634. struct hid_report_enum *report_enum;
  635. struct hid_report *report;
  636. struct list_head *list;
  637. unsigned i,k;
  638. static const char *table[] = {"INPUT", "OUTPUT", "FEATURE"};
  639. for (i = 0; i < HID_REPORT_TYPES; i++) {
  640. report_enum = device->report_enum + i;
  641. list = report_enum->report_list.next;
  642. while (list != &report_enum->report_list) {
  643. report = (struct hid_report *) list;
  644. tab(2, f);
  645. seq_printf(f, "%s", table[i]);
  646. if (report->id)
  647. seq_printf(f, "(%d)", report->id);
  648. seq_printf(f, "[%s]", table[report->type]);
  649. seq_printf(f, "\n");
  650. for (k = 0; k < report->maxfield; k++) {
  651. tab(4, f);
  652. seq_printf(f, "Field(%d)\n", k);
  653. hid_dump_field(report->field[k], 6, f);
  654. }
  655. list = list->next;
  656. }
  657. }
  658. }
  659. EXPORT_SYMBOL_GPL(hid_dump_device);
  660. /* enqueue string to 'events' ring buffer */
  661. void hid_debug_event(struct hid_device *hdev, char *buf)
  662. {
  663. struct hid_debug_list *list;
  664. unsigned long flags;
  665. spin_lock_irqsave(&hdev->debug_list_lock, flags);
  666. list_for_each_entry(list, &hdev->debug_list, node)
  667. kfifo_in(&list->hid_debug_fifo, buf, strlen(buf));
  668. spin_unlock_irqrestore(&hdev->debug_list_lock, flags);
  669. wake_up_interruptible(&hdev->debug_wait);
  670. }
  671. EXPORT_SYMBOL_GPL(hid_debug_event);
  672. void hid_dump_report(struct hid_device *hid, int type, u8 *data,
  673. int size)
  674. {
  675. struct hid_report_enum *report_enum;
  676. char *buf;
  677. unsigned int i;
  678. buf = kmalloc(HID_DEBUG_BUFSIZE, GFP_ATOMIC);
  679. if (!buf)
  680. return;
  681. report_enum = hid->report_enum + type;
  682. /* dump the report */
  683. snprintf(buf, HID_DEBUG_BUFSIZE - 1,
  684. "\nreport (size %u) (%snumbered) = ", size,
  685. report_enum->numbered ? "" : "un");
  686. hid_debug_event(hid, buf);
  687. for (i = 0; i < size; i++) {
  688. snprintf(buf, HID_DEBUG_BUFSIZE - 1,
  689. " %02x", data[i]);
  690. hid_debug_event(hid, buf);
  691. }
  692. hid_debug_event(hid, "\n");
  693. kfree(buf);
  694. }
  695. EXPORT_SYMBOL_GPL(hid_dump_report);
  696. void hid_dump_input(struct hid_device *hdev, struct hid_usage *usage, __s32 value)
  697. {
  698. char *buf;
  699. int len;
  700. buf = hid_resolv_usage(usage->hid, NULL);
  701. if (!buf)
  702. return;
  703. len = strlen(buf);
  704. snprintf(buf + len, HID_DEBUG_BUFSIZE - len - 1, " = %d\n", value);
  705. hid_debug_event(hdev, buf);
  706. kfree(buf);
  707. wake_up_interruptible(&hdev->debug_wait);
  708. }
  709. EXPORT_SYMBOL_GPL(hid_dump_input);
  710. static const char *events[EV_MAX + 1] = {
  711. [EV_SYN] = "Sync", [EV_KEY] = "Key",
  712. [EV_REL] = "Relative", [EV_ABS] = "Absolute",
  713. [EV_MSC] = "Misc", [EV_LED] = "LED",
  714. [EV_SND] = "Sound", [EV_REP] = "Repeat",
  715. [EV_FF] = "ForceFeedback", [EV_PWR] = "Power",
  716. [EV_FF_STATUS] = "ForceFeedbackStatus",
  717. };
  718. static const char *syncs[3] = {
  719. [SYN_REPORT] = "Report", [SYN_CONFIG] = "Config",
  720. [SYN_MT_REPORT] = "MT Report",
  721. };
  722. static const char *keys[KEY_MAX + 1] = {
  723. [KEY_RESERVED] = "Reserved", [KEY_ESC] = "Esc",
  724. [KEY_1] = "1", [KEY_2] = "2",
  725. [KEY_3] = "3", [KEY_4] = "4",
  726. [KEY_5] = "5", [KEY_6] = "6",
  727. [KEY_7] = "7", [KEY_8] = "8",
  728. [KEY_9] = "9", [KEY_0] = "0",
  729. [KEY_MINUS] = "Minus", [KEY_EQUAL] = "Equal",
  730. [KEY_BACKSPACE] = "Backspace", [KEY_TAB] = "Tab",
  731. [KEY_Q] = "Q", [KEY_W] = "W",
  732. [KEY_E] = "E", [KEY_R] = "R",
  733. [KEY_T] = "T", [KEY_Y] = "Y",
  734. [KEY_U] = "U", [KEY_I] = "I",
  735. [KEY_O] = "O", [KEY_P] = "P",
  736. [KEY_LEFTBRACE] = "LeftBrace", [KEY_RIGHTBRACE] = "RightBrace",
  737. [KEY_ENTER] = "Enter", [KEY_LEFTCTRL] = "LeftControl",
  738. [KEY_A] = "A", [KEY_S] = "S",
  739. [KEY_D] = "D", [KEY_F] = "F",
  740. [KEY_G] = "G", [KEY_H] = "H",
  741. [KEY_J] = "J", [KEY_K] = "K",
  742. [KEY_L] = "L", [KEY_SEMICOLON] = "Semicolon",
  743. [KEY_APOSTROPHE] = "Apostrophe", [KEY_GRAVE] = "Grave",
  744. [KEY_LEFTSHIFT] = "LeftShift", [KEY_BACKSLASH] = "BackSlash",
  745. [KEY_Z] = "Z", [KEY_X] = "X",
  746. [KEY_C] = "C", [KEY_V] = "V",
  747. [KEY_B] = "B", [KEY_N] = "N",
  748. [KEY_M] = "M", [KEY_COMMA] = "Comma",
  749. [KEY_DOT] = "Dot", [KEY_SLASH] = "Slash",
  750. [KEY_RIGHTSHIFT] = "RightShift", [KEY_KPASTERISK] = "KPAsterisk",
  751. [KEY_LEFTALT] = "LeftAlt", [KEY_SPACE] = "Space",
  752. [KEY_CAPSLOCK] = "CapsLock", [KEY_F1] = "F1",
  753. [KEY_F2] = "F2", [KEY_F3] = "F3",
  754. [KEY_F4] = "F4", [KEY_F5] = "F5",
  755. [KEY_F6] = "F6", [KEY_F7] = "F7",
  756. [KEY_F8] = "F8", [KEY_F9] = "F9",
  757. [KEY_F10] = "F10", [KEY_NUMLOCK] = "NumLock",
  758. [KEY_SCROLLLOCK] = "ScrollLock", [KEY_KP7] = "KP7",
  759. [KEY_KP8] = "KP8", [KEY_KP9] = "KP9",
  760. [KEY_KPMINUS] = "KPMinus", [KEY_KP4] = "KP4",
  761. [KEY_KP5] = "KP5", [KEY_KP6] = "KP6",
  762. [KEY_KPPLUS] = "KPPlus", [KEY_KP1] = "KP1",
  763. [KEY_KP2] = "KP2", [KEY_KP3] = "KP3",
  764. [KEY_KP0] = "KP0", [KEY_KPDOT] = "KPDot",
  765. [KEY_ZENKAKUHANKAKU] = "Zenkaku/Hankaku", [KEY_102ND] = "102nd",
  766. [KEY_F11] = "F11", [KEY_F12] = "F12",
  767. [KEY_RO] = "RO", [KEY_KATAKANA] = "Katakana",
  768. [KEY_HIRAGANA] = "HIRAGANA", [KEY_HENKAN] = "Henkan",
  769. [KEY_KATAKANAHIRAGANA] = "Katakana/Hiragana", [KEY_MUHENKAN] = "Muhenkan",
  770. [KEY_KPJPCOMMA] = "KPJpComma", [KEY_KPENTER] = "KPEnter",
  771. [KEY_RIGHTCTRL] = "RightCtrl", [KEY_KPSLASH] = "KPSlash",
  772. [KEY_SYSRQ] = "SysRq", [KEY_RIGHTALT] = "RightAlt",
  773. [KEY_LINEFEED] = "LineFeed", [KEY_HOME] = "Home",
  774. [KEY_UP] = "Up", [KEY_PAGEUP] = "PageUp",
  775. [KEY_LEFT] = "Left", [KEY_RIGHT] = "Right",
  776. [KEY_END] = "End", [KEY_DOWN] = "Down",
  777. [KEY_PAGEDOWN] = "PageDown", [KEY_INSERT] = "Insert",
  778. [KEY_DELETE] = "Delete", [KEY_MACRO] = "Macro",
  779. [KEY_MUTE] = "Mute", [KEY_VOLUMEDOWN] = "VolumeDown",
  780. [KEY_VOLUMEUP] = "VolumeUp", [KEY_POWER] = "Power",
  781. [KEY_KPEQUAL] = "KPEqual", [KEY_KPPLUSMINUS] = "KPPlusMinus",
  782. [KEY_PAUSE] = "Pause", [KEY_KPCOMMA] = "KPComma",
  783. [KEY_HANGUEL] = "Hangeul", [KEY_HANJA] = "Hanja",
  784. [KEY_YEN] = "Yen", [KEY_LEFTMETA] = "LeftMeta",
  785. [KEY_RIGHTMETA] = "RightMeta", [KEY_COMPOSE] = "Compose",
  786. [KEY_STOP] = "Stop", [KEY_AGAIN] = "Again",
  787. [KEY_PROPS] = "Props", [KEY_UNDO] = "Undo",
  788. [KEY_FRONT] = "Front", [KEY_COPY] = "Copy",
  789. [KEY_OPEN] = "Open", [KEY_PASTE] = "Paste",
  790. [KEY_FIND] = "Find", [KEY_CUT] = "Cut",
  791. [KEY_HELP] = "Help", [KEY_MENU] = "Menu",
  792. [KEY_CALC] = "Calc", [KEY_SETUP] = "Setup",
  793. [KEY_SLEEP] = "Sleep", [KEY_WAKEUP] = "WakeUp",
  794. [KEY_FILE] = "File", [KEY_SENDFILE] = "SendFile",
  795. [KEY_DELETEFILE] = "DeleteFile", [KEY_XFER] = "X-fer",
  796. [KEY_PROG1] = "Prog1", [KEY_PROG2] = "Prog2",
  797. [KEY_WWW] = "WWW", [KEY_MSDOS] = "MSDOS",
  798. [KEY_COFFEE] = "Coffee", [KEY_ROTATE_DISPLAY] = "RotateDisplay",
  799. [KEY_CYCLEWINDOWS] = "CycleWindows", [KEY_MAIL] = "Mail",
  800. [KEY_BOOKMARKS] = "Bookmarks", [KEY_COMPUTER] = "Computer",
  801. [KEY_BACK] = "Back", [KEY_FORWARD] = "Forward",
  802. [KEY_CLOSECD] = "CloseCD", [KEY_EJECTCD] = "EjectCD",
  803. [KEY_EJECTCLOSECD] = "EjectCloseCD", [KEY_NEXTSONG] = "NextSong",
  804. [KEY_PLAYPAUSE] = "PlayPause", [KEY_PREVIOUSSONG] = "PreviousSong",
  805. [KEY_STOPCD] = "StopCD", [KEY_RECORD] = "Record",
  806. [KEY_REWIND] = "Rewind", [KEY_PHONE] = "Phone",
  807. [KEY_ISO] = "ISOKey", [KEY_CONFIG] = "Config",
  808. [KEY_HOMEPAGE] = "HomePage", [KEY_REFRESH] = "Refresh",
  809. [KEY_EXIT] = "Exit", [KEY_MOVE] = "Move",
  810. [KEY_EDIT] = "Edit", [KEY_SCROLLUP] = "ScrollUp",
  811. [KEY_SCROLLDOWN] = "ScrollDown", [KEY_KPLEFTPAREN] = "KPLeftParenthesis",
  812. [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_NEW] = "New",
  813. [KEY_REDO] = "Redo", [KEY_F13] = "F13",
  814. [KEY_F14] = "F14", [KEY_F15] = "F15",
  815. [KEY_F16] = "F16", [KEY_F17] = "F17",
  816. [KEY_F18] = "F18", [KEY_F19] = "F19",
  817. [KEY_F20] = "F20", [KEY_F21] = "F21",
  818. [KEY_F22] = "F22", [KEY_F23] = "F23",
  819. [KEY_F24] = "F24", [KEY_PLAYCD] = "PlayCD",
  820. [KEY_PAUSECD] = "PauseCD", [KEY_PROG3] = "Prog3",
  821. [KEY_PROG4] = "Prog4",
  822. [KEY_ALL_APPLICATIONS] = "AllApplications",
  823. [KEY_SUSPEND] = "Suspend",
  824. [KEY_CLOSE] = "Close", [KEY_PLAY] = "Play",
  825. [KEY_FASTFORWARD] = "FastForward", [KEY_BASSBOOST] = "BassBoost",
  826. [KEY_PRINT] = "Print", [KEY_HP] = "HP",
  827. [KEY_CAMERA] = "Camera", [KEY_SOUND] = "Sound",
  828. [KEY_QUESTION] = "Question", [KEY_EMAIL] = "Email",
  829. [KEY_CHAT] = "Chat", [KEY_SEARCH] = "Search",
  830. [KEY_CONNECT] = "Connect", [KEY_FINANCE] = "Finance",
  831. [KEY_SPORT] = "Sport", [KEY_SHOP] = "Shop",
  832. [KEY_ALTERASE] = "AlternateErase", [KEY_CANCEL] = "Cancel",
  833. [KEY_BRIGHTNESSDOWN] = "BrightnessDown", [KEY_BRIGHTNESSUP] = "BrightnessUp",
  834. [KEY_MEDIA] = "Media", [KEY_UNKNOWN] = "Unknown",
  835. [BTN_DPAD_UP] = "BtnDPadUp", [BTN_DPAD_DOWN] = "BtnDPadDown",
  836. [BTN_DPAD_LEFT] = "BtnDPadLeft", [BTN_DPAD_RIGHT] = "BtnDPadRight",
  837. [BTN_0] = "Btn0", [BTN_1] = "Btn1",
  838. [BTN_2] = "Btn2", [BTN_3] = "Btn3",
  839. [BTN_4] = "Btn4", [BTN_5] = "Btn5",
  840. [BTN_6] = "Btn6", [BTN_7] = "Btn7",
  841. [BTN_8] = "Btn8", [BTN_9] = "Btn9",
  842. [BTN_LEFT] = "LeftBtn", [BTN_RIGHT] = "RightBtn",
  843. [BTN_MIDDLE] = "MiddleBtn", [BTN_SIDE] = "SideBtn",
  844. [BTN_EXTRA] = "ExtraBtn", [BTN_FORWARD] = "ForwardBtn",
  845. [BTN_BACK] = "BackBtn", [BTN_TASK] = "TaskBtn",
  846. [BTN_TRIGGER] = "Trigger", [BTN_THUMB] = "ThumbBtn",
  847. [BTN_THUMB2] = "ThumbBtn2", [BTN_TOP] = "TopBtn",
  848. [BTN_TOP2] = "TopBtn2", [BTN_PINKIE] = "PinkieBtn",
  849. [BTN_BASE] = "BaseBtn", [BTN_BASE2] = "BaseBtn2",
  850. [BTN_BASE3] = "BaseBtn3", [BTN_BASE4] = "BaseBtn4",
  851. [BTN_BASE5] = "BaseBtn5", [BTN_BASE6] = "BaseBtn6",
  852. [BTN_DEAD] = "BtnDead", [BTN_A] = "BtnA",
  853. [BTN_B] = "BtnB", [BTN_C] = "BtnC",
  854. [BTN_X] = "BtnX", [BTN_Y] = "BtnY",
  855. [BTN_Z] = "BtnZ", [BTN_TL] = "BtnTL",
  856. [BTN_TR] = "BtnTR", [BTN_TL2] = "BtnTL2",
  857. [BTN_TR2] = "BtnTR2", [BTN_SELECT] = "BtnSelect",
  858. [BTN_START] = "BtnStart", [BTN_MODE] = "BtnMode",
  859. [BTN_THUMBL] = "BtnThumbL", [BTN_THUMBR] = "BtnThumbR",
  860. [BTN_TOOL_PEN] = "ToolPen", [BTN_TOOL_RUBBER] = "ToolRubber",
  861. [BTN_TOOL_BRUSH] = "ToolBrush", [BTN_TOOL_PENCIL] = "ToolPencil",
  862. [BTN_TOOL_AIRBRUSH] = "ToolAirbrush", [BTN_TOOL_FINGER] = "ToolFinger",
  863. [BTN_TOOL_MOUSE] = "ToolMouse", [BTN_TOOL_LENS] = "ToolLens",
  864. [BTN_TOUCH] = "Touch", [BTN_STYLUS] = "Stylus",
  865. [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "ToolDoubleTap",
  866. [BTN_TOOL_TRIPLETAP] = "ToolTripleTap", [BTN_TOOL_QUADTAP] = "ToolQuadrupleTap",
  867. [BTN_GEAR_DOWN] = "WheelBtn",
  868. [BTN_GEAR_UP] = "Gear up", [KEY_OK] = "Ok",
  869. [KEY_SELECT] = "Select", [KEY_GOTO] = "Goto",
  870. [KEY_CLEAR] = "Clear", [KEY_POWER2] = "Power2",
  871. [KEY_OPTION] = "Option", [KEY_INFO] = "Info",
  872. [KEY_TIME] = "Time", [KEY_VENDOR] = "Vendor",
  873. [KEY_ARCHIVE] = "Archive", [KEY_PROGRAM] = "Program",
  874. [KEY_CHANNEL] = "Channel", [KEY_FAVORITES] = "Favorites",
  875. [KEY_EPG] = "EPG", [KEY_PVR] = "PVR",
  876. [KEY_MHP] = "MHP", [KEY_LANGUAGE] = "Language",
  877. [KEY_TITLE] = "Title", [KEY_SUBTITLE] = "Subtitle",
  878. [KEY_ANGLE] = "Angle", [KEY_ZOOM] = "Zoom",
  879. [KEY_MODE] = "Mode", [KEY_KEYBOARD] = "Keyboard",
  880. [KEY_SCREEN] = "Screen", [KEY_PC] = "PC",
  881. [KEY_TV] = "TV", [KEY_TV2] = "TV2",
  882. [KEY_VCR] = "VCR", [KEY_VCR2] = "VCR2",
  883. [KEY_SAT] = "Sat", [KEY_SAT2] = "Sat2",
  884. [KEY_CD] = "CD", [KEY_TAPE] = "Tape",
  885. [KEY_RADIO] = "Radio", [KEY_TUNER] = "Tuner",
  886. [KEY_PLAYER] = "Player", [KEY_TEXT] = "Text",
  887. [KEY_DVD] = "DVD", [KEY_AUX] = "Aux",
  888. [KEY_MP3] = "MP3", [KEY_AUDIO] = "Audio",
  889. [KEY_VIDEO] = "Video", [KEY_DIRECTORY] = "Directory",
  890. [KEY_LIST] = "List", [KEY_MEMO] = "Memo",
  891. [KEY_CALENDAR] = "Calendar", [KEY_RED] = "Red",
  892. [KEY_GREEN] = "Green", [KEY_YELLOW] = "Yellow",
  893. [KEY_BLUE] = "Blue", [KEY_CHANNELUP] = "ChannelUp",
  894. [KEY_CHANNELDOWN] = "ChannelDown", [KEY_FIRST] = "First",
  895. [KEY_LAST] = "Last", [KEY_AB] = "AB",
  896. [KEY_NEXT] = "Next", [KEY_RESTART] = "Restart",
  897. [KEY_SLOW] = "Slow", [KEY_SHUFFLE] = "Shuffle",
  898. [KEY_BREAK] = "Break", [KEY_PREVIOUS] = "Previous",
  899. [KEY_DIGITS] = "Digits", [KEY_TEEN] = "TEEN",
  900. [KEY_TWEN] = "TWEN", [KEY_DEL_EOL] = "DeleteEOL",
  901. [KEY_DEL_EOS] = "DeleteEOS", [KEY_INS_LINE] = "InsertLine",
  902. [KEY_DEL_LINE] = "DeleteLine",
  903. [KEY_SEND] = "Send", [KEY_REPLY] = "Reply",
  904. [KEY_FORWARDMAIL] = "ForwardMail", [KEY_SAVE] = "Save",
  905. [KEY_DOCUMENTS] = "Documents", [KEY_SPELLCHECK] = "SpellCheck",
  906. [KEY_LOGOFF] = "Logoff",
  907. [KEY_FN] = "Fn", [KEY_FN_ESC] = "Fn+ESC",
  908. [KEY_FN_1] = "Fn+1", [KEY_FN_2] = "Fn+2",
  909. [KEY_FN_B] = "Fn+B", [KEY_FN_D] = "Fn+D",
  910. [KEY_FN_E] = "Fn+E", [KEY_FN_F] = "Fn+F",
  911. [KEY_FN_S] = "Fn+S",
  912. [KEY_FN_F1] = "Fn+F1", [KEY_FN_F2] = "Fn+F2",
  913. [KEY_FN_F3] = "Fn+F3", [KEY_FN_F4] = "Fn+F4",
  914. [KEY_FN_F5] = "Fn+F5", [KEY_FN_F6] = "Fn+F6",
  915. [KEY_FN_F7] = "Fn+F7", [KEY_FN_F8] = "Fn+F8",
  916. [KEY_FN_F9] = "Fn+F9", [KEY_FN_F10] = "Fn+F10",
  917. [KEY_FN_F11] = "Fn+F11", [KEY_FN_F12] = "Fn+F12",
  918. [KEY_KBDILLUMTOGGLE] = "KbdIlluminationToggle",
  919. [KEY_KBDILLUMDOWN] = "KbdIlluminationDown",
  920. [KEY_KBDILLUMUP] = "KbdIlluminationUp",
  921. [KEY_SWITCHVIDEOMODE] = "SwitchVideoMode",
  922. [KEY_BUTTONCONFIG] = "ButtonConfig",
  923. [KEY_TASKMANAGER] = "TaskManager",
  924. [KEY_JOURNAL] = "Journal",
  925. [KEY_CONTROLPANEL] = "ControlPanel",
  926. [KEY_APPSELECT] = "AppSelect",
  927. [KEY_SCREENSAVER] = "ScreenSaver",
  928. [KEY_VOICECOMMAND] = "VoiceCommand",
  929. [KEY_ASSISTANT] = "Assistant",
  930. [KEY_KBD_LAYOUT_NEXT] = "KbdLayoutNext",
  931. [KEY_EMOJI_PICKER] = "EmojiPicker",
  932. [KEY_DICTATE] = "Dictate",
  933. [KEY_MICMUTE] = "MicrophoneMute",
  934. [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
  935. [KEY_BRIGHTNESS_MAX] = "BrightnessMax",
  936. [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto",
  937. [KEY_KBDINPUTASSIST_PREV] = "KbdInputAssistPrev",
  938. [KEY_KBDINPUTASSIST_NEXT] = "KbdInputAssistNext",
  939. [KEY_KBDINPUTASSIST_PREVGROUP] = "KbdInputAssistPrevGroup",
  940. [KEY_KBDINPUTASSIST_NEXTGROUP] = "KbdInputAssistNextGroup",
  941. [KEY_KBDINPUTASSIST_ACCEPT] = "KbdInputAssistAccept",
  942. [KEY_KBDINPUTASSIST_CANCEL] = "KbdInputAssistCancel",
  943. [KEY_MACRO1] = "Macro1", [KEY_MACRO2] = "Macro2", [KEY_MACRO3] = "Macro3",
  944. [KEY_MACRO4] = "Macro4", [KEY_MACRO5] = "Macro5", [KEY_MACRO6] = "Macro6",
  945. [KEY_MACRO7] = "Macro7", [KEY_MACRO8] = "Macro8", [KEY_MACRO9] = "Macro9",
  946. [KEY_MACRO10] = "Macro10", [KEY_MACRO11] = "Macro11", [KEY_MACRO12] = "Macro12",
  947. [KEY_MACRO13] = "Macro13", [KEY_MACRO14] = "Macro14", [KEY_MACRO15] = "Macro15",
  948. [KEY_MACRO16] = "Macro16", [KEY_MACRO17] = "Macro17", [KEY_MACRO18] = "Macro18",
  949. [KEY_MACRO19] = "Macro19", [KEY_MACRO20] = "Macro20", [KEY_MACRO21] = "Macro21",
  950. [KEY_MACRO22] = "Macro22", [KEY_MACRO23] = "Macro23", [KEY_MACRO24] = "Macro24",
  951. [KEY_MACRO25] = "Macro25", [KEY_MACRO26] = "Macro26", [KEY_MACRO27] = "Macro27",
  952. [KEY_MACRO28] = "Macro28", [KEY_MACRO29] = "Macro29", [KEY_MACRO30] = "Macro30",
  953. };
  954. static const char *relatives[REL_MAX + 1] = {
  955. [REL_X] = "X", [REL_Y] = "Y",
  956. [REL_Z] = "Z", [REL_RX] = "Rx",
  957. [REL_RY] = "Ry", [REL_RZ] = "Rz",
  958. [REL_HWHEEL] = "HWheel", [REL_DIAL] = "Dial",
  959. [REL_WHEEL] = "Wheel", [REL_MISC] = "Misc",
  960. };
  961. static const char *absolutes[ABS_CNT] = {
  962. [ABS_X] = "X", [ABS_Y] = "Y",
  963. [ABS_Z] = "Z", [ABS_RX] = "Rx",
  964. [ABS_RY] = "Ry", [ABS_RZ] = "Rz",
  965. [ABS_THROTTLE] = "Throttle", [ABS_RUDDER] = "Rudder",
  966. [ABS_WHEEL] = "Wheel", [ABS_GAS] = "Gas",
  967. [ABS_BRAKE] = "Brake", [ABS_HAT0X] = "Hat0X",
  968. [ABS_HAT0Y] = "Hat0Y", [ABS_HAT1X] = "Hat1X",
  969. [ABS_HAT1Y] = "Hat1Y", [ABS_HAT2X] = "Hat2X",
  970. [ABS_HAT2Y] = "Hat2Y", [ABS_HAT3X] = "Hat3X",
  971. [ABS_HAT3Y] = "Hat 3Y", [ABS_PRESSURE] = "Pressure",
  972. [ABS_DISTANCE] = "Distance", [ABS_TILT_X] = "XTilt",
  973. [ABS_TILT_Y] = "YTilt", [ABS_TOOL_WIDTH] = "ToolWidth",
  974. [ABS_VOLUME] = "Volume", [ABS_PROFILE] = "Profile",
  975. [ABS_MISC] = "Misc",
  976. [ABS_MT_TOUCH_MAJOR] = "MTMajor",
  977. [ABS_MT_TOUCH_MINOR] = "MTMinor",
  978. [ABS_MT_WIDTH_MAJOR] = "MTMajorW",
  979. [ABS_MT_WIDTH_MINOR] = "MTMinorW",
  980. [ABS_MT_ORIENTATION] = "MTOrientation",
  981. [ABS_MT_POSITION_X] = "MTPositionX",
  982. [ABS_MT_POSITION_Y] = "MTPositionY",
  983. [ABS_MT_TOOL_TYPE] = "MTToolType",
  984. [ABS_MT_BLOB_ID] = "MTBlobID",
  985. };
  986. static const char *misc[MSC_MAX + 1] = {
  987. [MSC_SERIAL] = "Serial", [MSC_PULSELED] = "Pulseled",
  988. [MSC_GESTURE] = "Gesture", [MSC_RAW] = "RawData"
  989. };
  990. static const char *leds[LED_MAX + 1] = {
  991. [LED_NUML] = "NumLock", [LED_CAPSL] = "CapsLock",
  992. [LED_SCROLLL] = "ScrollLock", [LED_COMPOSE] = "Compose",
  993. [LED_KANA] = "Kana", [LED_SLEEP] = "Sleep",
  994. [LED_SUSPEND] = "Suspend", [LED_MUTE] = "Mute",
  995. [LED_MISC] = "Misc",
  996. };
  997. static const char *repeats[REP_MAX + 1] = {
  998. [REP_DELAY] = "Delay", [REP_PERIOD] = "Period"
  999. };
  1000. static const char *sounds[SND_MAX + 1] = {
  1001. [SND_CLICK] = "Click", [SND_BELL] = "Bell",
  1002. [SND_TONE] = "Tone"
  1003. };
  1004. static const char **names[EV_MAX + 1] = {
  1005. [EV_SYN] = syncs, [EV_KEY] = keys,
  1006. [EV_REL] = relatives, [EV_ABS] = absolutes,
  1007. [EV_MSC] = misc, [EV_LED] = leds,
  1008. [EV_SND] = sounds, [EV_REP] = repeats,
  1009. };
  1010. static void hid_resolv_event(__u8 type, __u16 code, struct seq_file *f)
  1011. {
  1012. seq_printf(f, "%s.%s", events[type] ? events[type] : "?",
  1013. names[type] ? (names[type][code] ? names[type][code] : "?") : "?");
  1014. }
  1015. static void hid_dump_input_mapping(struct hid_device *hid, struct seq_file *f)
  1016. {
  1017. int i, j, k;
  1018. struct hid_report *report;
  1019. struct hid_usage *usage;
  1020. for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) {
  1021. list_for_each_entry(report, &hid->report_enum[k].report_list, list) {
  1022. for (i = 0; i < report->maxfield; i++) {
  1023. for ( j = 0; j < report->field[i]->maxusage; j++) {
  1024. usage = report->field[i]->usage + j;
  1025. hid_resolv_usage(usage->hid, f);
  1026. seq_printf(f, " ---> ");
  1027. hid_resolv_event(usage->type, usage->code, f);
  1028. seq_printf(f, "\n");
  1029. }
  1030. }
  1031. }
  1032. }
  1033. }
  1034. static int hid_debug_rdesc_show(struct seq_file *f, void *p)
  1035. {
  1036. struct hid_device *hdev = f->private;
  1037. const __u8 *rdesc = hdev->rdesc;
  1038. unsigned rsize = hdev->rsize;
  1039. int i;
  1040. if (!rdesc) {
  1041. rdesc = hdev->dev_rdesc;
  1042. rsize = hdev->dev_rsize;
  1043. }
  1044. /* dump HID report descriptor */
  1045. for (i = 0; i < rsize; i++)
  1046. seq_printf(f, "%02x ", rdesc[i]);
  1047. seq_printf(f, "\n\n");
  1048. /* dump parsed data and input mappings */
  1049. if (down_interruptible(&hdev->driver_input_lock))
  1050. return 0;
  1051. hid_dump_device(hdev, f);
  1052. seq_printf(f, "\n");
  1053. hid_dump_input_mapping(hdev, f);
  1054. up(&hdev->driver_input_lock);
  1055. return 0;
  1056. }
  1057. static int hid_debug_events_open(struct inode *inode, struct file *file)
  1058. {
  1059. int err = 0;
  1060. struct hid_debug_list *list;
  1061. unsigned long flags;
  1062. if (!(list = kzalloc(sizeof(struct hid_debug_list), GFP_KERNEL))) {
  1063. err = -ENOMEM;
  1064. goto out;
  1065. }
  1066. err = kfifo_alloc(&list->hid_debug_fifo, HID_DEBUG_FIFOSIZE, GFP_KERNEL);
  1067. if (err) {
  1068. kfree(list);
  1069. goto out;
  1070. }
  1071. list->hdev = (struct hid_device *) inode->i_private;
  1072. file->private_data = list;
  1073. mutex_init(&list->read_mutex);
  1074. spin_lock_irqsave(&list->hdev->debug_list_lock, flags);
  1075. list_add_tail(&list->node, &list->hdev->debug_list);
  1076. spin_unlock_irqrestore(&list->hdev->debug_list_lock, flags);
  1077. out:
  1078. return err;
  1079. }
  1080. static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,
  1081. size_t count, loff_t *ppos)
  1082. {
  1083. struct hid_debug_list *list = file->private_data;
  1084. int ret = 0, copied;
  1085. DECLARE_WAITQUEUE(wait, current);
  1086. mutex_lock(&list->read_mutex);
  1087. if (kfifo_is_empty(&list->hid_debug_fifo)) {
  1088. add_wait_queue(&list->hdev->debug_wait, &wait);
  1089. set_current_state(TASK_INTERRUPTIBLE);
  1090. while (kfifo_is_empty(&list->hid_debug_fifo)) {
  1091. if (signal_pending(current)) {
  1092. ret = -ERESTARTSYS;
  1093. break;
  1094. }
  1095. /* if list->hdev is NULL we cannot remove_wait_queue().
  1096. * if list->hdev->debug is 0 then hid_debug_unregister()
  1097. * was already called and list->hdev is being destroyed.
  1098. * if we add remove_wait_queue() here we can hit a race.
  1099. */
  1100. if (!list->hdev || !list->hdev->debug) {
  1101. ret = -EIO;
  1102. set_current_state(TASK_RUNNING);
  1103. goto out;
  1104. }
  1105. if (file->f_flags & O_NONBLOCK) {
  1106. ret = -EAGAIN;
  1107. break;
  1108. }
  1109. /* allow O_NONBLOCK from other threads */
  1110. mutex_unlock(&list->read_mutex);
  1111. schedule();
  1112. mutex_lock(&list->read_mutex);
  1113. set_current_state(TASK_INTERRUPTIBLE);
  1114. }
  1115. __set_current_state(TASK_RUNNING);
  1116. remove_wait_queue(&list->hdev->debug_wait, &wait);
  1117. if (ret)
  1118. goto out;
  1119. }
  1120. /* pass the fifo content to userspace, locking is not needed with only
  1121. * one concurrent reader and one concurrent writer
  1122. */
  1123. ret = kfifo_to_user(&list->hid_debug_fifo, buffer, count, &copied);
  1124. if (ret)
  1125. goto out;
  1126. ret = copied;
  1127. out:
  1128. mutex_unlock(&list->read_mutex);
  1129. return ret;
  1130. }
  1131. static __poll_t hid_debug_events_poll(struct file *file, poll_table *wait)
  1132. {
  1133. struct hid_debug_list *list = file->private_data;
  1134. poll_wait(file, &list->hdev->debug_wait, wait);
  1135. if (!kfifo_is_empty(&list->hid_debug_fifo))
  1136. return EPOLLIN | EPOLLRDNORM;
  1137. if (!list->hdev->debug)
  1138. return EPOLLERR | EPOLLHUP;
  1139. return 0;
  1140. }
  1141. static int hid_debug_events_release(struct inode *inode, struct file *file)
  1142. {
  1143. struct hid_debug_list *list = file->private_data;
  1144. unsigned long flags;
  1145. spin_lock_irqsave(&list->hdev->debug_list_lock, flags);
  1146. list_del(&list->node);
  1147. spin_unlock_irqrestore(&list->hdev->debug_list_lock, flags);
  1148. kfifo_free(&list->hid_debug_fifo);
  1149. kfree(list);
  1150. return 0;
  1151. }
  1152. DEFINE_SHOW_ATTRIBUTE(hid_debug_rdesc);
  1153. static const struct file_operations hid_debug_events_fops = {
  1154. .owner = THIS_MODULE,
  1155. .open = hid_debug_events_open,
  1156. .read = hid_debug_events_read,
  1157. .poll = hid_debug_events_poll,
  1158. .release = hid_debug_events_release,
  1159. .llseek = noop_llseek,
  1160. };
  1161. void hid_debug_register(struct hid_device *hdev, const char *name)
  1162. {
  1163. hdev->debug_dir = debugfs_create_dir(name, hid_debug_root);
  1164. hdev->debug_rdesc = debugfs_create_file("rdesc", 0400,
  1165. hdev->debug_dir, hdev, &hid_debug_rdesc_fops);
  1166. hdev->debug_events = debugfs_create_file("events", 0400,
  1167. hdev->debug_dir, hdev, &hid_debug_events_fops);
  1168. hdev->debug = 1;
  1169. }
  1170. void hid_debug_unregister(struct hid_device *hdev)
  1171. {
  1172. hdev->debug = 0;
  1173. wake_up_interruptible(&hdev->debug_wait);
  1174. debugfs_remove(hdev->debug_rdesc);
  1175. debugfs_remove(hdev->debug_events);
  1176. debugfs_remove(hdev->debug_dir);
  1177. }
  1178. void hid_debug_init(void)
  1179. {
  1180. hid_debug_root = debugfs_create_dir("hid", NULL);
  1181. }
  1182. void hid_debug_exit(void)
  1183. {
  1184. debugfs_remove_recursive(hid_debug_root);
  1185. }