| 1 | // SPDX-License-Identifier: GPL-2.0 | 
|---|
| 2 | /* | 
|---|
| 3 | * USB device quirk handling logic and table | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright (c) 2007 Oliver Neukum | 
|---|
| 6 | * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de> | 
|---|
| 7 | */ | 
|---|
| 8 |  | 
|---|
| 9 | #include <linux/moduleparam.h> | 
|---|
| 10 | #include <linux/usb.h> | 
|---|
| 11 | #include <linux/usb/quirks.h> | 
|---|
| 12 | #include <linux/usb/hcd.h> | 
|---|
| 13 | #include "usb.h" | 
|---|
| 14 |  | 
|---|
| 15 | struct quirk_entry { | 
|---|
| 16 | u16 vid; | 
|---|
| 17 | u16 pid; | 
|---|
| 18 | u32 flags; | 
|---|
| 19 | }; | 
|---|
| 20 |  | 
|---|
| 21 | static DEFINE_MUTEX(quirk_mutex); | 
|---|
| 22 |  | 
|---|
| 23 | static struct quirk_entry *quirk_list; | 
|---|
| 24 | static unsigned int quirk_count; | 
|---|
| 25 |  | 
|---|
| 26 | static char quirks_param[128]; | 
|---|
| 27 |  | 
|---|
| 28 | static int quirks_param_set(const char *value, const struct kernel_param *kp) | 
|---|
| 29 | { | 
|---|
| 30 | char *val, *p, *field; | 
|---|
| 31 | u16 vid, pid; | 
|---|
| 32 | u32 flags; | 
|---|
| 33 | size_t i; | 
|---|
| 34 | int err; | 
|---|
| 35 |  | 
|---|
| 36 | val = kstrdup(s: value, GFP_KERNEL); | 
|---|
| 37 | if (!val) | 
|---|
| 38 | return -ENOMEM; | 
|---|
| 39 |  | 
|---|
| 40 | err = param_set_copystring(val, kp); | 
|---|
| 41 | if (err) { | 
|---|
| 42 | kfree(objp: val); | 
|---|
| 43 | return err; | 
|---|
| 44 | } | 
|---|
| 45 |  | 
|---|
| 46 | mutex_lock(lock: &quirk_mutex); | 
|---|
| 47 |  | 
|---|
| 48 | if (!*val) { | 
|---|
| 49 | quirk_count = 0; | 
|---|
| 50 | kfree(objp: quirk_list); | 
|---|
| 51 | quirk_list = NULL; | 
|---|
| 52 | goto unlock; | 
|---|
| 53 | } | 
|---|
| 54 |  | 
|---|
| 55 | for (quirk_count = 1, i = 0; val[i]; i++) | 
|---|
| 56 | if (val[i] == ',') | 
|---|
| 57 | quirk_count++; | 
|---|
| 58 |  | 
|---|
| 59 | if (quirk_list) { | 
|---|
| 60 | kfree(objp: quirk_list); | 
|---|
| 61 | quirk_list = NULL; | 
|---|
| 62 | } | 
|---|
| 63 |  | 
|---|
| 64 | quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry), | 
|---|
| 65 | GFP_KERNEL); | 
|---|
| 66 | if (!quirk_list) { | 
|---|
| 67 | quirk_count = 0; | 
|---|
| 68 | mutex_unlock(lock: &quirk_mutex); | 
|---|
| 69 | kfree(objp: val); | 
|---|
| 70 | return -ENOMEM; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | for (i = 0, p = val; p && *p;) { | 
|---|
| 74 | /* Each entry consists of VID:PID:flags */ | 
|---|
| 75 | field = strsep(&p, ":"); | 
|---|
| 76 | if (!field) | 
|---|
| 77 | break; | 
|---|
| 78 |  | 
|---|
| 79 | if (kstrtou16(s: field, base: 16, res: &vid)) | 
|---|
| 80 | break; | 
|---|
| 81 |  | 
|---|
| 82 | field = strsep(&p, ":"); | 
|---|
| 83 | if (!field) | 
|---|
| 84 | break; | 
|---|
| 85 |  | 
|---|
| 86 | if (kstrtou16(s: field, base: 16, res: &pid)) | 
|---|
| 87 | break; | 
|---|
| 88 |  | 
|---|
| 89 | field = strsep(&p, ","); | 
|---|
| 90 | if (!field || !*field) | 
|---|
| 91 | break; | 
|---|
| 92 |  | 
|---|
| 93 | /* Collect the flags */ | 
|---|
| 94 | for (flags = 0; *field; field++) { | 
|---|
| 95 | switch (*field) { | 
|---|
| 96 | case 'a': | 
|---|
| 97 | flags |= USB_QUIRK_STRING_FETCH_255; | 
|---|
| 98 | break; | 
|---|
| 99 | case 'b': | 
|---|
| 100 | flags |= USB_QUIRK_RESET_RESUME; | 
|---|
| 101 | break; | 
|---|
| 102 | case 'c': | 
|---|
| 103 | flags |= USB_QUIRK_NO_SET_INTF; | 
|---|
| 104 | break; | 
|---|
| 105 | case 'd': | 
|---|
| 106 | flags |= USB_QUIRK_CONFIG_INTF_STRINGS; | 
|---|
| 107 | break; | 
|---|
| 108 | case 'e': | 
|---|
| 109 | flags |= USB_QUIRK_RESET; | 
|---|
| 110 | break; | 
|---|
| 111 | case 'f': | 
|---|
| 112 | flags |= USB_QUIRK_HONOR_BNUMINTERFACES; | 
|---|
| 113 | break; | 
|---|
| 114 | case 'g': | 
|---|
| 115 | flags |= USB_QUIRK_DELAY_INIT; | 
|---|
| 116 | break; | 
|---|
| 117 | case 'h': | 
|---|
| 118 | flags |= USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL; | 
|---|
| 119 | break; | 
|---|
| 120 | case 'i': | 
|---|
| 121 | flags |= USB_QUIRK_DEVICE_QUALIFIER; | 
|---|
| 122 | break; | 
|---|
| 123 | case 'j': | 
|---|
| 124 | flags |= USB_QUIRK_IGNORE_REMOTE_WAKEUP; | 
|---|
| 125 | break; | 
|---|
| 126 | case 'k': | 
|---|
| 127 | flags |= USB_QUIRK_NO_LPM; | 
|---|
| 128 | break; | 
|---|
| 129 | case 'l': | 
|---|
| 130 | flags |= USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL; | 
|---|
| 131 | break; | 
|---|
| 132 | case 'm': | 
|---|
| 133 | flags |= USB_QUIRK_DISCONNECT_SUSPEND; | 
|---|
| 134 | break; | 
|---|
| 135 | case 'n': | 
|---|
| 136 | flags |= USB_QUIRK_DELAY_CTRL_MSG; | 
|---|
| 137 | break; | 
|---|
| 138 | case 'o': | 
|---|
| 139 | flags |= USB_QUIRK_HUB_SLOW_RESET; | 
|---|
| 140 | break; | 
|---|
| 141 | case 'p': | 
|---|
| 142 | flags |= USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT; | 
|---|
| 143 | break; | 
|---|
| 144 | /* Ignore unrecognized flag characters */ | 
|---|
| 145 | } | 
|---|
| 146 | } | 
|---|
| 147 |  | 
|---|
| 148 | quirk_list[i++] = (struct quirk_entry) | 
|---|
| 149 | { .vid = vid, .pid = pid, .flags = flags }; | 
|---|
| 150 | } | 
|---|
| 151 |  | 
|---|
| 152 | if (i < quirk_count) | 
|---|
| 153 | quirk_count = i; | 
|---|
| 154 |  | 
|---|
| 155 | unlock: | 
|---|
| 156 | mutex_unlock(lock: &quirk_mutex); | 
|---|
| 157 | kfree(objp: val); | 
|---|
| 158 |  | 
|---|
| 159 | return 0; | 
|---|
| 160 | } | 
|---|
| 161 |  | 
|---|
| 162 | static const struct kernel_param_ops quirks_param_ops = { | 
|---|
| 163 | .set = quirks_param_set, | 
|---|
| 164 | .get = param_get_string, | 
|---|
| 165 | }; | 
|---|
| 166 |  | 
|---|
| 167 | static struct kparam_string quirks_param_string = { | 
|---|
| 168 | .maxlen = sizeof(quirks_param), | 
|---|
| 169 | .string = quirks_param, | 
|---|
| 170 | }; | 
|---|
| 171 |  | 
|---|
| 172 | device_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644); | 
|---|
| 173 | MODULE_PARM_DESC(quirks, "Add/modify USB quirks by specifying quirks=vendorID:productID:quirks"); | 
|---|
| 174 |  | 
|---|
| 175 | /* Lists of quirky USB devices, split in device quirks and interface quirks. | 
|---|
| 176 | * Device quirks are applied at the very beginning of the enumeration process, | 
|---|
| 177 | * right after reading the device descriptor. They can thus only match on device | 
|---|
| 178 | * information. | 
|---|
| 179 | * | 
|---|
| 180 | * Interface quirks are applied after reading all the configuration descriptors. | 
|---|
| 181 | * They can match on both device and interface information. | 
|---|
| 182 | * | 
|---|
| 183 | * Note that the DELAY_INIT and HONOR_BNUMINTERFACES quirks do not make sense as | 
|---|
| 184 | * interface quirks, as they only influence the enumeration process which is run | 
|---|
| 185 | * before processing the interface quirks. | 
|---|
| 186 | * | 
|---|
| 187 | * Please keep the lists ordered by: | 
|---|
| 188 | * 	1) Vendor ID | 
|---|
| 189 | * 	2) Product ID | 
|---|
| 190 | * 	3) Class ID | 
|---|
| 191 | */ | 
|---|
| 192 | static const struct usb_device_id usb_quirk_list[] = { | 
|---|
| 193 | /* CBM - Flash disk */ | 
|---|
| 194 | { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 195 |  | 
|---|
| 196 | /* WORLDE Controller KS49 or Prodipe MIDI 49C USB controller */ | 
|---|
| 197 | { USB_DEVICE(0x0218, 0x0201), .driver_info = | 
|---|
| 198 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 
|---|
| 199 |  | 
|---|
| 200 | /* WORLDE easy key (easykey.25) MIDI controller  */ | 
|---|
| 201 | { USB_DEVICE(0x0218, 0x0401), .driver_info = | 
|---|
| 202 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 
|---|
| 203 |  | 
|---|
| 204 | /* HP 5300/5370C scanner */ | 
|---|
| 205 | { USB_DEVICE(0x03f0, 0x0701), .driver_info = | 
|---|
| 206 | USB_QUIRK_STRING_FETCH_255 }, | 
|---|
| 207 |  | 
|---|
| 208 | /* HP v222w 16GB Mini USB Drive */ | 
|---|
| 209 | { USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 210 |  | 
|---|
| 211 | /* Creative SB Audigy 2 NX */ | 
|---|
| 212 | { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 213 |  | 
|---|
| 214 | /* USB3503 */ | 
|---|
| 215 | { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 216 |  | 
|---|
| 217 | /* Microsoft Wireless Laser Mouse 6000 Receiver */ | 
|---|
| 218 | { USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 219 |  | 
|---|
| 220 | /* Microsoft LifeCam-VX700 v2.0 */ | 
|---|
| 221 | { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 222 |  | 
|---|
| 223 | /* Microsoft Surface Dock Ethernet (RTL8153 GigE) */ | 
|---|
| 224 | { USB_DEVICE(0x045e, 0x07c6), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 225 |  | 
|---|
| 226 | /* Cherry Stream G230 2.0 (G85-231) and 3.0 (G85-232) */ | 
|---|
| 227 | { USB_DEVICE(0x046a, 0x0023), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 228 |  | 
|---|
| 229 | /* Logitech HD Webcam C270 */ | 
|---|
| 230 | { USB_DEVICE(0x046d, 0x0825), .driver_info = USB_QUIRK_RESET_RESUME | | 
|---|
| 231 | USB_QUIRK_NO_LPM}, | 
|---|
| 232 |  | 
|---|
| 233 | /* Logitech HD Pro Webcams C920, C920-C, C922, C925e and C930e */ | 
|---|
| 234 | { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 235 | { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 236 | { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 237 | { USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 238 | { USB_DEVICE(0x046d, 0x085c), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 239 |  | 
|---|
| 240 | /* Logitech ConferenceCam CC3000e */ | 
|---|
| 241 | { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 242 | { USB_DEVICE(0x046d, 0x0848), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 243 |  | 
|---|
| 244 | /* Logitech PTZ Pro Camera */ | 
|---|
| 245 | { USB_DEVICE(0x046d, 0x0853), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 246 |  | 
|---|
| 247 | /* Logitech Screen Share */ | 
|---|
| 248 | { USB_DEVICE(0x046d, 0x086c), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 249 |  | 
|---|
| 250 | /* Logitech Quickcam Fusion */ | 
|---|
| 251 | { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 252 |  | 
|---|
| 253 | /* Logitech Quickcam Orbit MP */ | 
|---|
| 254 | { USB_DEVICE(0x046d, 0x08c2), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 255 |  | 
|---|
| 256 | /* Logitech Quickcam Pro for Notebook */ | 
|---|
| 257 | { USB_DEVICE(0x046d, 0x08c3), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 258 |  | 
|---|
| 259 | /* Logitech Quickcam Pro 5000 */ | 
|---|
| 260 | { USB_DEVICE(0x046d, 0x08c5), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 261 |  | 
|---|
| 262 | /* Logitech Quickcam OEM Dell Notebook */ | 
|---|
| 263 | { USB_DEVICE(0x046d, 0x08c6), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 264 |  | 
|---|
| 265 | /* Logitech Quickcam OEM Cisco VT Camera II */ | 
|---|
| 266 | { USB_DEVICE(0x046d, 0x08c7), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 267 |  | 
|---|
| 268 | /* Logitech Harmony 700-series */ | 
|---|
| 269 | { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 270 |  | 
|---|
| 271 | /* Philips PSC805 audio device */ | 
|---|
| 272 | { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 273 |  | 
|---|
| 274 | /* Plantronic Audio 655 DSP */ | 
|---|
| 275 | { USB_DEVICE(0x047f, 0xc008), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 276 |  | 
|---|
| 277 | /* Plantronic Audio 648 USB */ | 
|---|
| 278 | { USB_DEVICE(0x047f, 0xc013), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 279 |  | 
|---|
| 280 | /* Artisman Watchdog Dongle */ | 
|---|
| 281 | { USB_DEVICE(0x04b4, 0x0526), .driver_info = | 
|---|
| 282 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 
|---|
| 283 |  | 
|---|
| 284 | /* Microchip Joss Optical infrared touchboard device */ | 
|---|
| 285 | { USB_DEVICE(0x04d8, 0x000c), .driver_info = | 
|---|
| 286 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 
|---|
| 287 |  | 
|---|
| 288 | /* CarrolTouch 4000U */ | 
|---|
| 289 | { USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 290 |  | 
|---|
| 291 | /* CarrolTouch 4500U */ | 
|---|
| 292 | { USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 293 |  | 
|---|
| 294 | /* Samsung Android phone modem - ID conflict with SPH-I500 */ | 
|---|
| 295 | { USB_DEVICE(0x04e8, 0x6601), .driver_info = | 
|---|
| 296 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 
|---|
| 297 |  | 
|---|
| 298 | /* Elan Touchscreen */ | 
|---|
| 299 | { USB_DEVICE(0x04f3, 0x0089), .driver_info = | 
|---|
| 300 | USB_QUIRK_DEVICE_QUALIFIER }, | 
|---|
| 301 |  | 
|---|
| 302 | { USB_DEVICE(0x04f3, 0x009b), .driver_info = | 
|---|
| 303 | USB_QUIRK_DEVICE_QUALIFIER }, | 
|---|
| 304 |  | 
|---|
| 305 | { USB_DEVICE(0x04f3, 0x010c), .driver_info = | 
|---|
| 306 | USB_QUIRK_DEVICE_QUALIFIER }, | 
|---|
| 307 |  | 
|---|
| 308 | { USB_DEVICE(0x04f3, 0x0125), .driver_info = | 
|---|
| 309 | USB_QUIRK_DEVICE_QUALIFIER }, | 
|---|
| 310 |  | 
|---|
| 311 | { USB_DEVICE(0x04f3, 0x016f), .driver_info = | 
|---|
| 312 | USB_QUIRK_DEVICE_QUALIFIER }, | 
|---|
| 313 |  | 
|---|
| 314 | { USB_DEVICE(0x04f3, 0x0381), .driver_info = | 
|---|
| 315 | USB_QUIRK_NO_LPM }, | 
|---|
| 316 |  | 
|---|
| 317 | { USB_DEVICE(0x04f3, 0x21b8), .driver_info = | 
|---|
| 318 | USB_QUIRK_DEVICE_QUALIFIER }, | 
|---|
| 319 |  | 
|---|
| 320 | /* Roland SC-8820 */ | 
|---|
| 321 | { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 322 |  | 
|---|
| 323 | /* Edirol SD-20 */ | 
|---|
| 324 | { USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 325 |  | 
|---|
| 326 | /* Alcor Micro Corp. Hub */ | 
|---|
| 327 | { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 328 |  | 
|---|
| 329 | /* appletouch */ | 
|---|
| 330 | { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 331 |  | 
|---|
| 332 | /* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */ | 
|---|
| 333 | { USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 334 |  | 
|---|
| 335 | /* ELSA MicroLink 56K */ | 
|---|
| 336 | { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 337 |  | 
|---|
| 338 | /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */ | 
|---|
| 339 | { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 340 |  | 
|---|
| 341 | /* Avision AV600U */ | 
|---|
| 342 | { USB_DEVICE(0x0638, 0x0a13), .driver_info = | 
|---|
| 343 | USB_QUIRK_STRING_FETCH_255 }, | 
|---|
| 344 |  | 
|---|
| 345 | /* Prolific Single-LUN Mass Storage Card Reader */ | 
|---|
| 346 | { USB_DEVICE(0x067b, 0x2731), .driver_info = USB_QUIRK_DELAY_INIT | | 
|---|
| 347 | USB_QUIRK_NO_LPM }, | 
|---|
| 348 |  | 
|---|
| 349 | /* Saitek Cyborg Gold Joystick */ | 
|---|
| 350 | { USB_DEVICE(0x06a3, 0x0006), .driver_info = | 
|---|
| 351 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 
|---|
| 352 |  | 
|---|
| 353 | /* Agfa SNAPSCAN 1212U */ | 
|---|
| 354 | { USB_DEVICE(0x06bd, 0x0001), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 355 |  | 
|---|
| 356 | /* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */ | 
|---|
| 357 | { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 358 |  | 
|---|
| 359 | /* Guillemot Webcam Hercules Dualpix Exchange*/ | 
|---|
| 360 | { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 361 |  | 
|---|
| 362 | /* Guillemot Hercules DJ Console audio card (BZ 208357) */ | 
|---|
| 363 | { USB_DEVICE(0x06f8, 0xb000), .driver_info = | 
|---|
| 364 | USB_QUIRK_ENDPOINT_IGNORE }, | 
|---|
| 365 |  | 
|---|
| 366 | /* Midiman M-Audio Keystation 88es */ | 
|---|
| 367 | { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 368 |  | 
|---|
| 369 | /* SanDisk Ultra Fit and Ultra Flair */ | 
|---|
| 370 | { USB_DEVICE(0x0781, 0x5583), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 371 | { USB_DEVICE(0x0781, 0x5591), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 372 |  | 
|---|
| 373 | /* SanDisk Corp. SanDisk 3.2Gen1 */ | 
|---|
| 374 | { USB_DEVICE(0x0781, 0x5596), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 375 | { USB_DEVICE(0x0781, 0x55a3), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 376 |  | 
|---|
| 377 | /* SanDisk Extreme 55AE */ | 
|---|
| 378 | { USB_DEVICE(0x0781, 0x55ae), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 379 |  | 
|---|
| 380 | /* Realforce 87U Keyboard */ | 
|---|
| 381 | { USB_DEVICE(0x0853, 0x011b), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 382 |  | 
|---|
| 383 | /* M-Systems Flash Disk Pioneers */ | 
|---|
| 384 | { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 385 |  | 
|---|
| 386 | /* Baum Vario Ultra */ | 
|---|
| 387 | { USB_DEVICE(0x0904, 0x6101), .driver_info = | 
|---|
| 388 | USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, | 
|---|
| 389 | { USB_DEVICE(0x0904, 0x6102), .driver_info = | 
|---|
| 390 | USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, | 
|---|
| 391 | { USB_DEVICE(0x0904, 0x6103), .driver_info = | 
|---|
| 392 | USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, | 
|---|
| 393 |  | 
|---|
| 394 | /* Silicon Motion Flash Drive */ | 
|---|
| 395 | { USB_DEVICE(0x090c, 0x1000), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 396 |  | 
|---|
| 397 | /* Sound Devices USBPre2 */ | 
|---|
| 398 | { USB_DEVICE(0x0926, 0x0202), .driver_info = | 
|---|
| 399 | USB_QUIRK_ENDPOINT_IGNORE }, | 
|---|
| 400 |  | 
|---|
| 401 | /* Sound Devices MixPre-D */ | 
|---|
| 402 | { USB_DEVICE(0x0926, 0x0208), .driver_info = | 
|---|
| 403 | USB_QUIRK_ENDPOINT_IGNORE }, | 
|---|
| 404 |  | 
|---|
| 405 | /* Keytouch QWERTY Panel keyboard */ | 
|---|
| 406 | { USB_DEVICE(0x0926, 0x3333), .driver_info = | 
|---|
| 407 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 
|---|
| 408 |  | 
|---|
| 409 | /* Kingston DataTraveler 3.0 */ | 
|---|
| 410 | { USB_DEVICE(0x0951, 0x1666), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 411 |  | 
|---|
| 412 | /* TOSHIBA TransMemory-Mx */ | 
|---|
| 413 | { USB_DEVICE(0x0930, 0x1408), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 414 |  | 
|---|
| 415 | /* NVIDIA Jetson devices in Force Recovery mode */ | 
|---|
| 416 | { USB_DEVICE(0x0955, 0x7018), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 417 | { USB_DEVICE(0x0955, 0x7019), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 418 | { USB_DEVICE(0x0955, 0x7418), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 419 | { USB_DEVICE(0x0955, 0x7721), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 420 | { USB_DEVICE(0x0955, 0x7c18), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 421 | { USB_DEVICE(0x0955, 0x7e19), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 422 | { USB_DEVICE(0x0955, 0x7f21), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 423 |  | 
|---|
| 424 | /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */ | 
|---|
| 425 | { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF }, | 
|---|
| 426 |  | 
|---|
| 427 | /* ELMO L-12F document camera */ | 
|---|
| 428 | { USB_DEVICE(0x09a1, 0x0028), .driver_info = USB_QUIRK_DELAY_CTRL_MSG }, | 
|---|
| 429 |  | 
|---|
| 430 | /* Broadcom BCM92035DGROM BT dongle */ | 
|---|
| 431 | { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 432 |  | 
|---|
| 433 | /* MAYA44USB sound device */ | 
|---|
| 434 | { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 435 |  | 
|---|
| 436 | /* ASUS Base Station(T100) */ | 
|---|
| 437 | { USB_DEVICE(0x0b05, 0x17e0), .driver_info = | 
|---|
| 438 | USB_QUIRK_IGNORE_REMOTE_WAKEUP }, | 
|---|
| 439 |  | 
|---|
| 440 | /* Realtek Semiconductor Corp. Mass Storage Device (Multicard Reader)*/ | 
|---|
| 441 | { USB_DEVICE(0x0bda, 0x0151), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS }, | 
|---|
| 442 |  | 
|---|
| 443 | /* Realtek hub in Dell WD19 (Type-C) */ | 
|---|
| 444 | { USB_DEVICE(0x0bda, 0x0487), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 445 |  | 
|---|
| 446 | /* Generic RTL8153 based ethernet adapters */ | 
|---|
| 447 | { USB_DEVICE(0x0bda, 0x8153), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 448 |  | 
|---|
| 449 | /* SONiX USB DEVICE Touchpad */ | 
|---|
| 450 | { USB_DEVICE(0x0c45, 0x7056), .driver_info = | 
|---|
| 451 | USB_QUIRK_IGNORE_REMOTE_WAKEUP }, | 
|---|
| 452 |  | 
|---|
| 453 | /* Sony Xperia XZ1 Compact (lilac) smartphone in fastboot mode */ | 
|---|
| 454 | { USB_DEVICE(0x0fce, 0x0dde), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 455 |  | 
|---|
| 456 | /* Action Semiconductor flash disk */ | 
|---|
| 457 | { USB_DEVICE(0x10d6, 0x2200), .driver_info = | 
|---|
| 458 | USB_QUIRK_STRING_FETCH_255 }, | 
|---|
| 459 |  | 
|---|
| 460 | /* novation SoundControl XL */ | 
|---|
| 461 | { USB_DEVICE(0x1235, 0x0061), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 462 |  | 
|---|
| 463 | /* Focusrite Scarlett Solo USB */ | 
|---|
| 464 | { USB_DEVICE(0x1235, 0x8211), .driver_info = | 
|---|
| 465 | USB_QUIRK_DISCONNECT_SUSPEND }, | 
|---|
| 466 |  | 
|---|
| 467 | /* Huawei 4G LTE module */ | 
|---|
| 468 | { USB_DEVICE(0x12d1, 0x15bb), .driver_info = | 
|---|
| 469 | USB_QUIRK_DISCONNECT_SUSPEND }, | 
|---|
| 470 | { USB_DEVICE(0x12d1, 0x15c3), .driver_info = | 
|---|
| 471 | USB_QUIRK_DISCONNECT_SUSPEND }, | 
|---|
| 472 |  | 
|---|
| 473 | /* SKYMEDI USB_DRIVE */ | 
|---|
| 474 | { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 475 |  | 
|---|
| 476 | /* Razer - Razer Blade Keyboard */ | 
|---|
| 477 | { USB_DEVICE(0x1532, 0x0116), .driver_info = | 
|---|
| 478 | USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, | 
|---|
| 479 |  | 
|---|
| 480 | /* Lenovo ThinkPad OneLink+ Dock twin hub controllers (VIA Labs VL812) */ | 
|---|
| 481 | { USB_DEVICE(0x17ef, 0x1018), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 482 | { USB_DEVICE(0x17ef, 0x1019), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 483 |  | 
|---|
| 484 | /* Lenovo USB-C to Ethernet Adapter RTL8153-04 */ | 
|---|
| 485 | { USB_DEVICE(0x17ef, 0x720c), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 486 |  | 
|---|
| 487 | /* Lenovo Powered USB-C Travel Hub (4X90S92381, RTL8153 GigE) */ | 
|---|
| 488 | { USB_DEVICE(0x17ef, 0x721e), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 489 |  | 
|---|
| 490 | /* Lenovo ThinkCenter A630Z TI024Gen3 usb-audio */ | 
|---|
| 491 | { USB_DEVICE(0x17ef, 0xa012), .driver_info = | 
|---|
| 492 | USB_QUIRK_DISCONNECT_SUSPEND }, | 
|---|
| 493 |  | 
|---|
| 494 | /* Lenovo ThinkPad USB-C Dock Gen2 Ethernet (RTL8153 GigE) */ | 
|---|
| 495 | { USB_DEVICE(0x17ef, 0xa387), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 496 |  | 
|---|
| 497 | /* BUILDWIN Photo Frame */ | 
|---|
| 498 | { USB_DEVICE(0x1908, 0x1315), .driver_info = | 
|---|
| 499 | USB_QUIRK_HONOR_BNUMINTERFACES }, | 
|---|
| 500 |  | 
|---|
| 501 | /* Protocol and OTG Electrical Test Device */ | 
|---|
| 502 | { USB_DEVICE(0x1a0a, 0x0200), .driver_info = | 
|---|
| 503 | USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, | 
|---|
| 504 |  | 
|---|
| 505 | /* Terminus Technology Inc. Hub */ | 
|---|
| 506 | { USB_DEVICE(0x1a40, 0x0101), .driver_info = USB_QUIRK_HUB_SLOW_RESET }, | 
|---|
| 507 |  | 
|---|
| 508 | /* Corsair K70 RGB */ | 
|---|
| 509 | { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT | | 
|---|
| 510 | USB_QUIRK_DELAY_CTRL_MSG }, | 
|---|
| 511 |  | 
|---|
| 512 | /* Corsair Strafe */ | 
|---|
| 513 | { USB_DEVICE(0x1b1c, 0x1b15), .driver_info = USB_QUIRK_DELAY_INIT | | 
|---|
| 514 | USB_QUIRK_DELAY_CTRL_MSG }, | 
|---|
| 515 |  | 
|---|
| 516 | /* Corsair Strafe RGB */ | 
|---|
| 517 | { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT | | 
|---|
| 518 | USB_QUIRK_DELAY_CTRL_MSG }, | 
|---|
| 519 |  | 
|---|
| 520 | /* Corsair K70 LUX RGB */ | 
|---|
| 521 | { USB_DEVICE(0x1b1c, 0x1b33), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 522 |  | 
|---|
| 523 | /* Corsair K70 LUX */ | 
|---|
| 524 | { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT }, | 
|---|
| 525 |  | 
|---|
| 526 | /* Corsair K70 RGB RAPDIFIRE */ | 
|---|
| 527 | { USB_DEVICE(0x1b1c, 0x1b38), .driver_info = USB_QUIRK_DELAY_INIT | | 
|---|
| 528 | USB_QUIRK_DELAY_CTRL_MSG }, | 
|---|
| 529 |  | 
|---|
| 530 | /* START BP-850k Printer */ | 
|---|
| 531 | { USB_DEVICE(0x1bc3, 0x0003), .driver_info = USB_QUIRK_NO_SET_INTF }, | 
|---|
| 532 |  | 
|---|
| 533 | /* MIDI keyboard WORLDE MINI */ | 
|---|
| 534 | { USB_DEVICE(0x1c75, 0x0204), .driver_info = | 
|---|
| 535 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 
|---|
| 536 |  | 
|---|
| 537 | /* Acer C120 LED Projector */ | 
|---|
| 538 | { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 539 |  | 
|---|
| 540 | /* Blackmagic Design Intensity Shuttle */ | 
|---|
| 541 | { USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 542 |  | 
|---|
| 543 | /* Blackmagic Design UltraStudio SDI */ | 
|---|
| 544 | { USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 545 |  | 
|---|
| 546 | /* Teclast disk */ | 
|---|
| 547 | { USB_DEVICE(0x1f75, 0x0917), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 548 |  | 
|---|
| 549 | /* Hauppauge HVR-950q */ | 
|---|
| 550 | { USB_DEVICE(0x2040, 0x7200), .driver_info = | 
|---|
| 551 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 
|---|
| 552 |  | 
|---|
| 553 | /* VLI disk */ | 
|---|
| 554 | { USB_DEVICE(0x2109, 0x0711), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 555 |  | 
|---|
| 556 | /* Raydium Touchscreen */ | 
|---|
| 557 | { USB_DEVICE(0x2386, 0x3114), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 558 |  | 
|---|
| 559 | { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 560 |  | 
|---|
| 561 | { USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 562 |  | 
|---|
| 563 | /* APTIV AUTOMOTIVE HUB */ | 
|---|
| 564 | { USB_DEVICE(0x2c48, 0x0132), .driver_info = | 
|---|
| 565 | USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT }, | 
|---|
| 566 |  | 
|---|
| 567 | /* DJI CineSSD */ | 
|---|
| 568 | { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 569 |  | 
|---|
| 570 | /* Alcor Link AK9563 SC Reader used in 2022 Lenovo ThinkPads */ | 
|---|
| 571 | { USB_DEVICE(0x2ce3, 0x9563), .driver_info = USB_QUIRK_NO_LPM }, | 
|---|
| 572 |  | 
|---|
| 573 | /* DELL USB GEN2 */ | 
|---|
| 574 | { USB_DEVICE(0x413c, 0xb062), .driver_info = USB_QUIRK_NO_LPM | USB_QUIRK_RESET_RESUME }, | 
|---|
| 575 |  | 
|---|
| 576 | /* VCOM device */ | 
|---|
| 577 | { USB_DEVICE(0x4296, 0x7570), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS }, | 
|---|
| 578 |  | 
|---|
| 579 | /* INTEL VALUE SSD */ | 
|---|
| 580 | { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 581 |  | 
|---|
| 582 | { }  /* terminating entry must be last */ | 
|---|
| 583 | }; | 
|---|
| 584 |  | 
|---|
| 585 | static const struct usb_device_id usb_interface_quirk_list[] = { | 
|---|
| 586 | /* Logitech UVC Cameras */ | 
|---|
| 587 | { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0), | 
|---|
| 588 | .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 589 |  | 
|---|
| 590 | { }  /* terminating entry must be last */ | 
|---|
| 591 | }; | 
|---|
| 592 |  | 
|---|
| 593 | static const struct usb_device_id usb_amd_resume_quirk_list[] = { | 
|---|
| 594 | /* Lenovo Mouse with Pixart controller */ | 
|---|
| 595 | { USB_DEVICE(0x17ef, 0x602e), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 596 |  | 
|---|
| 597 | /* Pixart Mouse */ | 
|---|
| 598 | { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 599 | { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 600 | { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 601 | { USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 602 |  | 
|---|
| 603 | /* Logitech Optical Mouse M90/M100 */ | 
|---|
| 604 | { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME }, | 
|---|
| 605 |  | 
|---|
| 606 | { }  /* terminating entry must be last */ | 
|---|
| 607 | }; | 
|---|
| 608 |  | 
|---|
| 609 | /* | 
|---|
| 610 | * Entries for endpoints that should be ignored when parsing configuration | 
|---|
| 611 | * descriptors. | 
|---|
| 612 | * | 
|---|
| 613 | * Matched for devices with USB_QUIRK_ENDPOINT_IGNORE. | 
|---|
| 614 | */ | 
|---|
| 615 | static const struct usb_device_id usb_endpoint_ignore[] = { | 
|---|
| 616 | { USB_DEVICE_INTERFACE_NUMBER(0x06f8, 0xb000, 5), .driver_info = 0x01 }, | 
|---|
| 617 | { USB_DEVICE_INTERFACE_NUMBER(0x06f8, 0xb000, 5), .driver_info = 0x81 }, | 
|---|
| 618 | { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0202, 1), .driver_info = 0x85 }, | 
|---|
| 619 | { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0208, 1), .driver_info = 0x85 }, | 
|---|
| 620 | { } | 
|---|
| 621 | }; | 
|---|
| 622 |  | 
|---|
| 623 | bool usb_endpoint_is_ignored(struct usb_device *udev, | 
|---|
| 624 | struct usb_host_interface *intf, | 
|---|
| 625 | struct usb_endpoint_descriptor *epd) | 
|---|
| 626 | { | 
|---|
| 627 | const struct usb_device_id *id; | 
|---|
| 628 | unsigned int address; | 
|---|
| 629 |  | 
|---|
| 630 | for (id = usb_endpoint_ignore; id->match_flags; ++id) { | 
|---|
| 631 | if (!usb_match_device(dev: udev, id)) | 
|---|
| 632 | continue; | 
|---|
| 633 |  | 
|---|
| 634 | if (!usb_match_one_id_intf(dev: udev, intf, id)) | 
|---|
| 635 | continue; | 
|---|
| 636 |  | 
|---|
| 637 | address = id->driver_info; | 
|---|
| 638 | if (address == epd->bEndpointAddress) | 
|---|
| 639 | return true; | 
|---|
| 640 | } | 
|---|
| 641 |  | 
|---|
| 642 | return false; | 
|---|
| 643 | } | 
|---|
| 644 |  | 
|---|
| 645 | static bool usb_match_any_interface(struct usb_device *udev, | 
|---|
| 646 | const struct usb_device_id *id) | 
|---|
| 647 | { | 
|---|
| 648 | unsigned int i; | 
|---|
| 649 |  | 
|---|
| 650 | for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) { | 
|---|
| 651 | struct usb_host_config *cfg = &udev->config[i]; | 
|---|
| 652 | unsigned int j; | 
|---|
| 653 |  | 
|---|
| 654 | for (j = 0; j < cfg->desc.bNumInterfaces; ++j) { | 
|---|
| 655 | struct usb_interface_cache *cache; | 
|---|
| 656 | struct usb_host_interface *intf; | 
|---|
| 657 |  | 
|---|
| 658 | cache = cfg->intf_cache[j]; | 
|---|
| 659 | if (cache->num_altsetting == 0) | 
|---|
| 660 | continue; | 
|---|
| 661 |  | 
|---|
| 662 | intf = &cache->altsetting[0]; | 
|---|
| 663 | if (usb_match_one_id_intf(dev: udev, intf, id)) | 
|---|
| 664 | return true; | 
|---|
| 665 | } | 
|---|
| 666 | } | 
|---|
| 667 |  | 
|---|
| 668 | return false; | 
|---|
| 669 | } | 
|---|
| 670 |  | 
|---|
| 671 | static int usb_amd_resume_quirk(struct usb_device *udev) | 
|---|
| 672 | { | 
|---|
| 673 | struct usb_hcd *hcd; | 
|---|
| 674 |  | 
|---|
| 675 | hcd = bus_to_hcd(bus: udev->bus); | 
|---|
| 676 | /* The device should be attached directly to root hub */ | 
|---|
| 677 | if (udev->level == 1 && hcd->amd_resume_bug == 1) | 
|---|
| 678 | return 1; | 
|---|
| 679 |  | 
|---|
| 680 | return 0; | 
|---|
| 681 | } | 
|---|
| 682 |  | 
|---|
| 683 | static u32 usb_detect_static_quirks(struct usb_device *udev, | 
|---|
| 684 | const struct usb_device_id *id) | 
|---|
| 685 | { | 
|---|
| 686 | u32 quirks = 0; | 
|---|
| 687 |  | 
|---|
| 688 | for (; id->match_flags; id++) { | 
|---|
| 689 | if (!usb_match_device(dev: udev, id)) | 
|---|
| 690 | continue; | 
|---|
| 691 |  | 
|---|
| 692 | if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) && | 
|---|
| 693 | !usb_match_any_interface(udev, id)) | 
|---|
| 694 | continue; | 
|---|
| 695 |  | 
|---|
| 696 | quirks |= (u32)(id->driver_info); | 
|---|
| 697 | } | 
|---|
| 698 |  | 
|---|
| 699 | return quirks; | 
|---|
| 700 | } | 
|---|
| 701 |  | 
|---|
| 702 | static u32 usb_detect_dynamic_quirks(struct usb_device *udev) | 
|---|
| 703 | { | 
|---|
| 704 | u16 vid = le16_to_cpu(udev->descriptor.idVendor); | 
|---|
| 705 | u16 pid = le16_to_cpu(udev->descriptor.idProduct); | 
|---|
| 706 | int i, flags = 0; | 
|---|
| 707 |  | 
|---|
| 708 | mutex_lock(lock: &quirk_mutex); | 
|---|
| 709 |  | 
|---|
| 710 | for (i = 0; i < quirk_count; i++) { | 
|---|
| 711 | if (vid == quirk_list[i].vid && pid == quirk_list[i].pid) { | 
|---|
| 712 | flags = quirk_list[i].flags; | 
|---|
| 713 | break; | 
|---|
| 714 | } | 
|---|
| 715 | } | 
|---|
| 716 |  | 
|---|
| 717 | mutex_unlock(lock: &quirk_mutex); | 
|---|
| 718 |  | 
|---|
| 719 | return flags; | 
|---|
| 720 | } | 
|---|
| 721 |  | 
|---|
| 722 | /* | 
|---|
| 723 | * Detect any quirks the device has, and do any housekeeping for it if needed. | 
|---|
| 724 | */ | 
|---|
| 725 | void usb_detect_quirks(struct usb_device *udev) | 
|---|
| 726 | { | 
|---|
| 727 | udev->quirks = usb_detect_static_quirks(udev, id: usb_quirk_list); | 
|---|
| 728 |  | 
|---|
| 729 | /* | 
|---|
| 730 | * Pixart-based mice would trigger remote wakeup issue on AMD | 
|---|
| 731 | * Yangtze chipset, so set them as RESET_RESUME flag. | 
|---|
| 732 | */ | 
|---|
| 733 | if (usb_amd_resume_quirk(udev)) | 
|---|
| 734 | udev->quirks |= usb_detect_static_quirks(udev, | 
|---|
| 735 | id: usb_amd_resume_quirk_list); | 
|---|
| 736 |  | 
|---|
| 737 | udev->quirks ^= usb_detect_dynamic_quirks(udev); | 
|---|
| 738 |  | 
|---|
| 739 | if (udev->quirks) | 
|---|
| 740 | dev_dbg(&udev->dev, "USB quirks for this device: 0x%x\n", | 
|---|
| 741 | udev->quirks); | 
|---|
| 742 |  | 
|---|
| 743 | #ifdef CONFIG_USB_DEFAULT_PERSIST | 
|---|
| 744 | if (!(udev->quirks & USB_QUIRK_RESET)) | 
|---|
| 745 | udev->persist_enabled = 1; | 
|---|
| 746 | #else | 
|---|
| 747 | /* Hubs are automatically enabled for USB-PERSIST */ | 
|---|
| 748 | if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) | 
|---|
| 749 | udev->persist_enabled = 1; | 
|---|
| 750 | #endif	/* CONFIG_USB_DEFAULT_PERSIST */ | 
|---|
| 751 | } | 
|---|
| 752 |  | 
|---|
| 753 | void usb_detect_interface_quirks(struct usb_device *udev) | 
|---|
| 754 | { | 
|---|
| 755 | u32 quirks; | 
|---|
| 756 |  | 
|---|
| 757 | quirks = usb_detect_static_quirks(udev, id: usb_interface_quirk_list); | 
|---|
| 758 | if (quirks == 0) | 
|---|
| 759 | return; | 
|---|
| 760 |  | 
|---|
| 761 | dev_dbg(&udev->dev, "USB interface quirks for this device: %x\n", | 
|---|
| 762 | quirks); | 
|---|
| 763 | udev->quirks |= quirks; | 
|---|
| 764 | } | 
|---|
| 765 |  | 
|---|
| 766 | void usb_release_quirk_list(void) | 
|---|
| 767 | { | 
|---|
| 768 | mutex_lock(lock: &quirk_mutex); | 
|---|
| 769 | kfree(objp: quirk_list); | 
|---|
| 770 | quirk_list = NULL; | 
|---|
| 771 | mutex_unlock(lock: &quirk_mutex); | 
|---|
| 772 | } | 
|---|
| 773 |  | 
|---|