Linux Audio

Check our new training course

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