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 
quirks_param_set(const char * val,const struct kernel_param * kp)28 static int quirks_param_set(const char *val, const struct kernel_param *kp)
29 {
30 	char *p, *field;
31 	u16 vid, pid;
32 	u32 flags;
33 	size_t i;
34 	int err;
35 
36 	err = param_set_copystring(val, kp);
37 	if (err)
38 		return err;
39 
40 	mutex_lock(&quirk_mutex);
41 
42 	if (!*val) {
43 		quirk_count = 0;
44 		kfree(quirk_list);
45 		quirk_list = NULL;
46 		goto unlock;
47 	}
48 
49 	for (quirk_count = 1, i = 0; val[i]; i++)
50 		if (val[i] == ',')
51 			quirk_count++;
52 
53 	if (quirk_list) {
54 		kfree(quirk_list);
55 		quirk_list = NULL;
56 	}
57 
58 	quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
59 			     GFP_KERNEL);
60 	if (!quirk_list) {
61 		quirk_count = 0;
62 		mutex_unlock(&quirk_mutex);
63 		return -ENOMEM;
64 	}
65 
66 	for (i = 0, p = (char *)val; p && *p;) {
67 		/* Each entry consists of VID:PID:flags */
68 		field = strsep(&p, ":");
69 		if (!field)
70 			break;
71 
72 		if (kstrtou16(field, 16, &vid))
73 			break;
74 
75 		field = strsep(&p, ":");
76 		if (!field)
77 			break;
78 
79 		if (kstrtou16(field, 16, &pid))
80 			break;
81 
82 		field = strsep(&p, ",");
83 		if (!field || !*field)
84 			break;
85 
86 		/* Collect the flags */
87 		for (flags = 0; *field; field++) {
88 			switch (*field) {
89 			case 'a':
90 				flags |= USB_QUIRK_STRING_FETCH_255;
91 				break;
92 			case 'b':
93 				flags |= USB_QUIRK_RESET_RESUME;
94 				break;
95 			case 'c':
96 				flags |= USB_QUIRK_NO_SET_INTF;
97 				break;
98 			case 'd':
99 				flags |= USB_QUIRK_CONFIG_INTF_STRINGS;
100 				break;
101 			case 'e':
102 				flags |= USB_QUIRK_RESET;
103 				break;
104 			case 'f':
105 				flags |= USB_QUIRK_HONOR_BNUMINTERFACES;
106 				break;
107 			case 'g':
108 				flags |= USB_QUIRK_DELAY_INIT;
109 				break;
110 			case 'h':
111 				flags |= USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL;
112 				break;
113 			case 'i':
114 				flags |= USB_QUIRK_DEVICE_QUALIFIER;
115 				break;
116 			case 'j':
117 				flags |= USB_QUIRK_IGNORE_REMOTE_WAKEUP;
118 				break;
119 			case 'k':
120 				flags |= USB_QUIRK_NO_LPM;
121 				break;
122 			case 'l':
123 				flags |= USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL;
124 				break;
125 			case 'm':
126 				flags |= USB_QUIRK_DISCONNECT_SUSPEND;
127 				break;
128 			case 'n':
129 				flags |= USB_QUIRK_DELAY_CTRL_MSG;
130 				break;
131 			/* Ignore unrecognized flag characters */
132 			}
133 		}
134 
135 		quirk_list[i++] = (struct quirk_entry)
136 			{ .vid = vid, .pid = pid, .flags = flags };
137 	}
138 
139 	if (i < quirk_count)
140 		quirk_count = i;
141 
142 unlock:
143 	mutex_unlock(&quirk_mutex);
144 
145 	return 0;
146 }
147 
148 static const struct kernel_param_ops quirks_param_ops = {
149 	.set = quirks_param_set,
150 	.get = param_get_string,
151 };
152 
153 static struct kparam_string quirks_param_string = {
154 	.maxlen = sizeof(quirks_param),
155 	.string = quirks_param,
156 };
157 
158 device_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644);
159 MODULE_PARM_DESC(quirks, "Add/modify USB quirks by specifying quirks=vendorID:productID:quirks");
160 
161 /* Lists of quirky USB devices, split in device quirks and interface quirks.
162  * Device quirks are applied at the very beginning of the enumeration process,
163  * right after reading the device descriptor. They can thus only match on device
164  * information.
165  *
166  * Interface quirks are applied after reading all the configuration descriptors.
167  * They can match on both device and interface information.
168  *
169  * Note that the DELAY_INIT and HONOR_BNUMINTERFACES quirks do not make sense as
170  * interface quirks, as they only influence the enumeration process which is run
171  * before processing the interface quirks.
172  *
173  * Please keep the lists ordered by:
174  * 	1) Vendor ID
175  * 	2) Product ID
176  * 	3) Class ID
177  */
178 static const struct usb_device_id usb_quirk_list[] = {
179 	/* CBM - Flash disk */
180 	{ USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },
181 
182 	/* WORLDE Controller KS49 or Prodipe MIDI 49C USB controller */
183 	{ USB_DEVICE(0x0218, 0x0201), .driver_info =
184 			USB_QUIRK_CONFIG_INTF_STRINGS },
185 
186 	/* WORLDE easy key (easykey.25) MIDI controller  */
187 	{ USB_DEVICE(0x0218, 0x0401), .driver_info =
188 			USB_QUIRK_CONFIG_INTF_STRINGS },
189 
190 	/* HP 5300/5370C scanner */
191 	{ USB_DEVICE(0x03f0, 0x0701), .driver_info =
192 			USB_QUIRK_STRING_FETCH_255 },
193 
194 	/* HP v222w 16GB Mini USB Drive */
195 	{ USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT },
196 
197 	/* Creative SB Audigy 2 NX */
198 	{ USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
199 
200 	/* USB3503 */
201 	{ USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME },
202 
203 	/* Microsoft Wireless Laser Mouse 6000 Receiver */
204 	{ USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME },
205 
206 	/* Microsoft LifeCam-VX700 v2.0 */
207 	{ USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
208 
209 	/* Logitech HD Pro Webcams C920, C920-C, C925e and C930e */
210 	{ USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT },
211 	{ USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT },
212 	{ USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT },
213 	{ USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT },
214 
215 	/* Logitech ConferenceCam CC3000e */
216 	{ USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT },
217 	{ USB_DEVICE(0x046d, 0x0848), .driver_info = USB_QUIRK_DELAY_INIT },
218 
219 	/* Logitech PTZ Pro Camera */
220 	{ USB_DEVICE(0x046d, 0x0853), .driver_info = USB_QUIRK_DELAY_INIT },
221 
222 	/* Logitech Quickcam Fusion */
223 	{ USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME },
224 
225 	/* Logitech Quickcam Orbit MP */
226 	{ USB_DEVICE(0x046d, 0x08c2), .driver_info = USB_QUIRK_RESET_RESUME },
227 
228 	/* Logitech Quickcam Pro for Notebook */
229 	{ USB_DEVICE(0x046d, 0x08c3), .driver_info = USB_QUIRK_RESET_RESUME },
230 
231 	/* Logitech Quickcam Pro 5000 */
232 	{ USB_DEVICE(0x046d, 0x08c5), .driver_info = USB_QUIRK_RESET_RESUME },
233 
234 	/* Logitech Quickcam OEM Dell Notebook */
235 	{ USB_DEVICE(0x046d, 0x08c6), .driver_info = USB_QUIRK_RESET_RESUME },
236 
237 	/* Logitech Quickcam OEM Cisco VT Camera II */
238 	{ USB_DEVICE(0x046d, 0x08c7), .driver_info = USB_QUIRK_RESET_RESUME },
239 
240 	/* Logitech Harmony 700-series */
241 	{ USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT },
242 
243 	/* Philips PSC805 audio device */
244 	{ USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
245 
246 	/* Plantronic Audio 655 DSP */
247 	{ USB_DEVICE(0x047f, 0xc008), .driver_info = USB_QUIRK_RESET_RESUME },
248 
249 	/* Plantronic Audio 648 USB */
250 	{ USB_DEVICE(0x047f, 0xc013), .driver_info = USB_QUIRK_RESET_RESUME },
251 
252 	/* Artisman Watchdog Dongle */
253 	{ USB_DEVICE(0x04b4, 0x0526), .driver_info =
254 			USB_QUIRK_CONFIG_INTF_STRINGS },
255 
256 	/* Microchip Joss Optical infrared touchboard device */
257 	{ USB_DEVICE(0x04d8, 0x000c), .driver_info =
258 			USB_QUIRK_CONFIG_INTF_STRINGS },
259 
260 	/* CarrolTouch 4000U */
261 	{ USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME },
262 
263 	/* CarrolTouch 4500U */
264 	{ USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME },
265 
266 	/* Samsung Android phone modem - ID conflict with SPH-I500 */
267 	{ USB_DEVICE(0x04e8, 0x6601), .driver_info =
268 			USB_QUIRK_CONFIG_INTF_STRINGS },
269 
270 	/* Elan Touchscreen */
271 	{ USB_DEVICE(0x04f3, 0x0089), .driver_info =
272 			USB_QUIRK_DEVICE_QUALIFIER },
273 
274 	{ USB_DEVICE(0x04f3, 0x009b), .driver_info =
275 			USB_QUIRK_DEVICE_QUALIFIER },
276 
277 	{ USB_DEVICE(0x04f3, 0x010c), .driver_info =
278 			USB_QUIRK_DEVICE_QUALIFIER },
279 
280 	{ USB_DEVICE(0x04f3, 0x0125), .driver_info =
281 			USB_QUIRK_DEVICE_QUALIFIER },
282 
283 	{ USB_DEVICE(0x04f3, 0x016f), .driver_info =
284 			USB_QUIRK_DEVICE_QUALIFIER },
285 
286 	{ USB_DEVICE(0x04f3, 0x0381), .driver_info =
287 			USB_QUIRK_NO_LPM },
288 
289 	{ USB_DEVICE(0x04f3, 0x21b8), .driver_info =
290 			USB_QUIRK_DEVICE_QUALIFIER },
291 
292 	/* Roland SC-8820 */
293 	{ USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
294 
295 	/* Edirol SD-20 */
296 	{ USB_DEVICE(0x0582, 0x0027), .driver_info = USB_QUIRK_RESET_RESUME },
297 
298 	/* Alcor Micro Corp. Hub */
299 	{ USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME },
300 
301 	/* appletouch */
302 	{ USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
303 
304 	/* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */
305 	{ USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM },
306 
307 	/* ELSA MicroLink 56K */
308 	{ USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_RESET_RESUME },
309 
310 	/* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
311 	{ USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
312 
313 	/* Avision AV600U */
314 	{ USB_DEVICE(0x0638, 0x0a13), .driver_info =
315 	  USB_QUIRK_STRING_FETCH_255 },
316 
317 	/* Saitek Cyborg Gold Joystick */
318 	{ USB_DEVICE(0x06a3, 0x0006), .driver_info =
319 			USB_QUIRK_CONFIG_INTF_STRINGS },
320 
321 	/* Guillemot Webcam Hercules Dualpix Exchange (2nd ID) */
322 	{ USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME },
323 
324 	/* Guillemot Webcam Hercules Dualpix Exchange*/
325 	{ USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME },
326 
327 	/* Midiman M-Audio Keystation 88es */
328 	{ USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
329 
330 	/* M-Systems Flash Disk Pioneers */
331 	{ USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
332 
333 	/* Baum Vario Ultra */
334 	{ USB_DEVICE(0x0904, 0x6101), .driver_info =
335 			USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
336 	{ USB_DEVICE(0x0904, 0x6102), .driver_info =
337 			USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
338 	{ USB_DEVICE(0x0904, 0x6103), .driver_info =
339 			USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL },
340 
341 	/* Keytouch QWERTY Panel keyboard */
342 	{ USB_DEVICE(0x0926, 0x3333), .driver_info =
343 			USB_QUIRK_CONFIG_INTF_STRINGS },
344 
345 	/* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
346 	{ USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
347 
348 	/* Broadcom BCM92035DGROM BT dongle */
349 	{ USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME },
350 
351 	/* MAYA44USB sound device */
352 	{ USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME },
353 
354 	/* ASUS Base Station(T100) */
355 	{ USB_DEVICE(0x0b05, 0x17e0), .driver_info =
356 			USB_QUIRK_IGNORE_REMOTE_WAKEUP },
357 
358 	/* Action Semiconductor flash disk */
359 	{ USB_DEVICE(0x10d6, 0x2200), .driver_info =
360 			USB_QUIRK_STRING_FETCH_255 },
361 
362 	/* Huawei 4G LTE module */
363 	{ USB_DEVICE(0x12d1, 0x15bb), .driver_info =
364 			USB_QUIRK_DISCONNECT_SUSPEND },
365 	{ USB_DEVICE(0x12d1, 0x15c3), .driver_info =
366 			USB_QUIRK_DISCONNECT_SUSPEND },
367 
368 	/* SKYMEDI USB_DRIVE */
369 	{ USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
370 
371 	/* Razer - Razer Blade Keyboard */
372 	{ USB_DEVICE(0x1532, 0x0116), .driver_info =
373 			USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
374 
375 	/* BUILDWIN Photo Frame */
376 	{ USB_DEVICE(0x1908, 0x1315), .driver_info =
377 			USB_QUIRK_HONOR_BNUMINTERFACES },
378 
379 	/* Protocol and OTG Electrical Test Device */
380 	{ USB_DEVICE(0x1a0a, 0x0200), .driver_info =
381 			USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
382 
383 	/* Corsair K70 RGB */
384 	{ USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT },
385 
386 	/* Corsair Strafe */
387 	{ USB_DEVICE(0x1b1c, 0x1b15), .driver_info = USB_QUIRK_DELAY_INIT |
388 	  USB_QUIRK_DELAY_CTRL_MSG },
389 
390 	/* Corsair Strafe RGB */
391 	{ USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT |
392 	  USB_QUIRK_DELAY_CTRL_MSG },
393 
394 	/* Corsair K70 LUX */
395 	{ USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
396 
397 	/* MIDI keyboard WORLDE MINI */
398 	{ USB_DEVICE(0x1c75, 0x0204), .driver_info =
399 			USB_QUIRK_CONFIG_INTF_STRINGS },
400 
401 	/* Acer C120 LED Projector */
402 	{ USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM },
403 
404 	/* Blackmagic Design Intensity Shuttle */
405 	{ USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM },
406 
407 	/* Blackmagic Design UltraStudio SDI */
408 	{ USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM },
409 
410 	/* Hauppauge HVR-950q */
411 	{ USB_DEVICE(0x2040, 0x7200), .driver_info =
412 			USB_QUIRK_CONFIG_INTF_STRINGS },
413 
414 	/* DJI CineSSD */
415 	{ USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
416 
417 	/* INTEL VALUE SSD */
418 	{ USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
419 
420 	{ }  /* terminating entry must be last */
421 };
422 
423 static const struct usb_device_id usb_interface_quirk_list[] = {
424 	/* Logitech UVC Cameras */
425 	{ USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0),
426 	  .driver_info = USB_QUIRK_RESET_RESUME },
427 
428 	{ }  /* terminating entry must be last */
429 };
430 
431 static const struct usb_device_id usb_amd_resume_quirk_list[] = {
432 	/* Lenovo Mouse with Pixart controller */
433 	{ USB_DEVICE(0x17ef, 0x602e), .driver_info = USB_QUIRK_RESET_RESUME },
434 
435 	/* Pixart Mouse */
436 	{ USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME },
437 	{ USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME },
438 	{ USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME },
439 	{ USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME },
440 
441 	/* Logitech Optical Mouse M90/M100 */
442 	{ USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME },
443 
444 	{ }  /* terminating entry must be last */
445 };
446 
usb_match_any_interface(struct usb_device * udev,const struct usb_device_id * id)447 static bool usb_match_any_interface(struct usb_device *udev,
448 				    const struct usb_device_id *id)
449 {
450 	unsigned int i;
451 
452 	for (i = 0; i < udev->descriptor.bNumConfigurations; ++i) {
453 		struct usb_host_config *cfg = &udev->config[i];
454 		unsigned int j;
455 
456 		for (j = 0; j < cfg->desc.bNumInterfaces; ++j) {
457 			struct usb_interface_cache *cache;
458 			struct usb_host_interface *intf;
459 
460 			cache = cfg->intf_cache[j];
461 			if (cache->num_altsetting == 0)
462 				continue;
463 
464 			intf = &cache->altsetting[0];
465 			if (usb_match_one_id_intf(udev, intf, id))
466 				return true;
467 		}
468 	}
469 
470 	return false;
471 }
472 
usb_amd_resume_quirk(struct usb_device * udev)473 static int usb_amd_resume_quirk(struct usb_device *udev)
474 {
475 	struct usb_hcd *hcd;
476 
477 	hcd = bus_to_hcd(udev->bus);
478 	/* The device should be attached directly to root hub */
479 	if (udev->level == 1 && hcd->amd_resume_bug == 1)
480 		return 1;
481 
482 	return 0;
483 }
484 
usb_detect_static_quirks(struct usb_device * udev,const struct usb_device_id * id)485 static u32 usb_detect_static_quirks(struct usb_device *udev,
486 				    const struct usb_device_id *id)
487 {
488 	u32 quirks = 0;
489 
490 	for (; id->match_flags; id++) {
491 		if (!usb_match_device(udev, id))
492 			continue;
493 
494 		if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_INFO) &&
495 		    !usb_match_any_interface(udev, id))
496 			continue;
497 
498 		quirks |= (u32)(id->driver_info);
499 	}
500 
501 	return quirks;
502 }
503 
usb_detect_dynamic_quirks(struct usb_device * udev)504 static u32 usb_detect_dynamic_quirks(struct usb_device *udev)
505 {
506 	u16 vid = le16_to_cpu(udev->descriptor.idVendor);
507 	u16 pid = le16_to_cpu(udev->descriptor.idProduct);
508 	int i, flags = 0;
509 
510 	mutex_lock(&quirk_mutex);
511 
512 	for (i = 0; i < quirk_count; i++) {
513 		if (vid == quirk_list[i].vid && pid == quirk_list[i].pid) {
514 			flags = quirk_list[i].flags;
515 			break;
516 		}
517 	}
518 
519 	mutex_unlock(&quirk_mutex);
520 
521 	return flags;
522 }
523 
524 /*
525  * Detect any quirks the device has, and do any housekeeping for it if needed.
526  */
usb_detect_quirks(struct usb_device * udev)527 void usb_detect_quirks(struct usb_device *udev)
528 {
529 	udev->quirks = usb_detect_static_quirks(udev, usb_quirk_list);
530 
531 	/*
532 	 * Pixart-based mice would trigger remote wakeup issue on AMD
533 	 * Yangtze chipset, so set them as RESET_RESUME flag.
534 	 */
535 	if (usb_amd_resume_quirk(udev))
536 		udev->quirks |= usb_detect_static_quirks(udev,
537 				usb_amd_resume_quirk_list);
538 
539 	udev->quirks ^= usb_detect_dynamic_quirks(udev);
540 
541 	if (udev->quirks)
542 		dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
543 			udev->quirks);
544 
545 #ifdef CONFIG_USB_DEFAULT_PERSIST
546 	if (!(udev->quirks & USB_QUIRK_RESET))
547 		udev->persist_enabled = 1;
548 #else
549 	/* Hubs are automatically enabled for USB-PERSIST */
550 	if (udev->descriptor.bDeviceClass == USB_CLASS_HUB)
551 		udev->persist_enabled = 1;
552 #endif	/* CONFIG_USB_DEFAULT_PERSIST */
553 }
554 
usb_detect_interface_quirks(struct usb_device * udev)555 void usb_detect_interface_quirks(struct usb_device *udev)
556 {
557 	u32 quirks;
558 
559 	quirks = usb_detect_static_quirks(udev, usb_interface_quirk_list);
560 	if (quirks == 0)
561 		return;
562 
563 	dev_dbg(&udev->dev, "USB interface quirks for this device: %x\n",
564 		quirks);
565 	udev->quirks |= quirks;
566 }
567 
usb_release_quirk_list(void)568 void usb_release_quirk_list(void)
569 {
570 	mutex_lock(&quirk_mutex);
571 	kfree(quirk_list);
572 	quirk_list = NULL;
573 	mutex_unlock(&quirk_mutex);
574 }
575