Greg Kroah-Hartman
95713fb8aa
Revert "usb: core: Add "quirks" parameter for usbcore"
...
This reverts commit b27560e4d9e5240b5544c9c5650c7442e482646e as it
breaks the build for some arches :(
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 1d1d53f85ddd..70a7398c20e2 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4368,6 +4368,61 @@
usbcore.nousb [USB] Disable the USB subsystem
+ usbcore.quirks=
+ [USB] A list of quirks entries to supplement or
+ override the built-in usb core quirk list. List
+ entries are separated by commas. Each entry has
+ the form VID:PID:Flags where VID and PID are Vendor
+ and Product ID values (4-digit hex numbers) and
+ Flags is a set of characters, each corresponding
+ to a common usb core quirk flag as follows:
+ a = USB_QUIRK_STRING_FETCH_255 (string
+ descriptors must not be fetched using
+ a 255-byte read);
+ b = USB_QUIRK_RESET_RESUME (device can't resume
+ correctly so reset it instead);
+ c = USB_QUIRK_NO_SET_INTF (device can't handle
+ Set-Interface requests);
+ d = USB_QUIRK_CONFIG_INTF_STRINGS (device can't
+ handle its Configuration or Interface
+ strings);
+ e = USB_QUIRK_RESET (device can't be reset
+ (e.g morph devices), don't use reset);
+ f = USB_QUIRK_HONOR_BNUMINTERFACES (device has
+ more interface descriptions than the
+ bNumInterfaces count, and can't handle
+ talking to these interfaces);
+ g = USB_QUIRK_DELAY_INIT (device needs a pause
+ during initialization, after we read
+ the device descriptor);
+ h = USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL (For
+ high speed and super speed interrupt
+ endpoints, the USB 2.0 and USB 3.0 spec
+ require the interval in microframes (1
+ microframe = 125 microseconds) to be
+ calculated as interval = 2 ^
+ (bInterval-1).
+ Devices with this quirk report their
+ bInterval as the result of this
+ calculation instead of the exponent
+ variable used in the calculation);
+ i = USB_QUIRK_DEVICE_QUALIFIER (device can't
+ handle device_qualifier descriptor
+ requests);
+ j = USB_QUIRK_IGNORE_REMOTE_WAKEUP (device
+ generates spurious wakeup, ignore
+ remote wakeup capability);
+ k = USB_QUIRK_NO_LPM (device can't handle Link
+ Power Management);
+ l = USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL
+ (Device reports its bInterval as linear
+ frames instead of the USB 2.0
+ calculation);
+ m = USB_QUIRK_DISCONNECT_SUSPEND (Device needs
+ to be disconnected before suspend to
+ prevent spurious wakeup)
+ Example: quirks=0781:5580:bk,0a5c:5834:gij
+
usbhid.mousepoll=
[USBHID] The interval which mice are to be polled at.
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index f4a548471f0f..42faaeead81b 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -11,6 +11,143 @@
#include <linux/usb/hcd.h>
#include "usb.h"
+struct quirk_entry {
+ u16 vid;
+ u16 pid;
+ u32 flags;
+};
+
+static DEFINE_MUTEX(quirk_mutex);
+
+static struct quirk_entry *quirk_list;
+static unsigned int quirk_count;
+
+static char quirks_param[128];
+
+static int quirks_param_set(const char *val, const struct kernel_param *kp)
+{
+ char *p, *field;
+ u16 vid, pid;
+ u32 flags;
+ size_t i;
+
+ mutex_lock(&quirk_mutex);
+
+ if (!val || !*val) {
+ quirk_count = 0;
+ kfree(quirk_list);
+ quirk_list = NULL;
+ goto unlock;
+ }
+
+ for (quirk_count = 1, i = 0; val[i]; i++)
+ if (val[i] == ',')
+ quirk_count++;
+
+ if (quirk_list) {
+ kfree(quirk_list);
+ quirk_list = NULL;
+ }
+
+ quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
+ GFP_KERNEL);
+ if (!quirk_list) {
+ mutex_unlock(&quirk_mutex);
+ return -ENOMEM;
+ }
+
+ for (i = 0, p = (char *)val; p && *p;) {
+ /* Each entry consists of VID:PID:flags */
+ field = strsep(&p, ":");
+ if (!field)
+ break;
+
+ if (kstrtou16(field, 16, &vid))
+ break;
+
+ field = strsep(&p, ":");
+ if (!field)
+ break;
+
+ if (kstrtou16(field, 16, &pid))
+ break;
+
+ field = strsep(&p, ",");
+ if (!field || !*field)
+ break;
+
+ /* Collect the flags */
+ for (flags = 0; *field; field++) {
+ switch (*field) {
+ case 'a':
+ flags |= USB_QUIRK_STRING_FETCH_255;
+ break;
+ case 'b':
+ flags |= USB_QUIRK_RESET_RESUME;
+ break;
+ case 'c':
+ flags |= USB_QUIRK_NO_SET_INTF;
+ break;
+ case 'd':
+ flags |= USB_QUIRK_CONFIG_INTF_STRINGS;
+ break;
+ case 'e':
+ flags |= USB_QUIRK_RESET;
+ break;
+ case 'f':
+ flags |= USB_QUIRK_HONOR_BNUMINTERFACES;
+ break;
+ case 'g':
+ flags |= USB_QUIRK_DELAY_INIT;
+ break;
+ case 'h':
+ flags |= USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL;
+ break;
+ case 'i':
+ flags |= USB_QUIRK_DEVICE_QUALIFIER;
+ break;
+ case 'j':
+ flags |= USB_QUIRK_IGNORE_REMOTE_WAKEUP;
+ break;
+ case 'k':
+ flags |= USB_QUIRK_NO_LPM;
+ break;
+ case 'l':
+ flags |= USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL;
+ break;
+ case 'm':
+ flags |= USB_QUIRK_DISCONNECT_SUSPEND;
+ break;
+ /* Ignore unrecognized flag characters */
+ }
+ }
+
+ quirk_list[i++] = (struct quirk_entry)
+ { .vid = vid, .pid = pid, .flags = flags };
+ }
+
+ if (i < quirk_count)
+ quirk_count = i;
+
+unlock:
+ mutex_unlock(&quirk_mutex);
+
+ return param_set_copystring(val, kp);
+}
+
+static const struct kernel_param_ops quirks_param_ops = {
+ .set = quirks_param_set,
+ .get = param_get_string,
+};
+
+static struct kparam_string quirks_param_string = {
+ .maxlen = sizeof(quirks_param),
+ .string = quirks_param,
+};
+
+module_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644);
+MODULE_PARM_DESC(quirks, "Add/modify USB quirks by specifying quirks=vendorID:productID:quirks");
+
/* Lists of quirky USB devices, split in device quirks and interface quirks.
* Device quirks are applied at the very beginning of the enumeration process,
* right after reading the device descriptor. They can thus only match on device
@@ -320,8 +457,8 @@ static int usb_amd_resume_quirk(struct usb_device *udev)
return 0;
}
-static u32 __usb_detect_quirks(struct usb_device *udev,
- const struct usb_device_id *id)
+static u32 usb_detect_static_quirks(struct usb_device *udev,
+ const struct usb_device_id *id)
{
u32 quirks = 0;
@@ -339,21 +476,43 @@ static u32 __usb_detect_quirks(struct usb_device *udev,
return quirks;
}
+static u32 usb_detect_dynamic_quirks(struct usb_device *udev)
+{
+ u16 vid = le16_to_cpu(udev->descriptor.idVendor);
+ u16 pid = le16_to_cpu(udev->descriptor.idProduct);
+ int i, flags = 0;
+
+ mutex_lock(&quirk_mutex);
+
+ for (i = 0; i < quirk_count; i++) {
+ if (vid == quirk_list[i].vid && pid == quirk_list[i].pid) {
+ flags = quirk_list[i].flags;
+ break;
+ }
+ }
+
+ mutex_unlock(&quirk_mutex);
+
+ return flags;
+}
+
/*
* Detect any quirks the device has, and do any housekeeping for it if needed.
*/
void usb_detect_quirks(struct usb_device *udev)
{
- udev->quirks = __usb_detect_quirks(udev, usb_quirk_list);
+ udev->quirks = usb_detect_static_quirks(udev, usb_quirk_list);
/*
* Pixart-based mice would trigger remote wakeup issue on AMD
* Yangtze chipset, so set them as RESET_RESUME flag.
*/
if (usb_amd_resume_quirk(udev))
- udev->quirks |= __usb_detect_quirks(udev,
+ udev->quirks |= usb_detect_static_quirks(udev,
usb_amd_resume_quirk_list);
+ udev->quirks ^= usb_detect_dynamic_quirks(udev);
+
if (udev->quirks)
dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
udev->quirks);
@@ -372,7 +531,7 @@ void usb_detect_interface_quirks(struct usb_device *udev)
{
u32 quirks;
- quirks = __usb_detect_quirks(udev, usb_interface_quirk_list);
+ quirks = usb_detect_static_quirks(udev, usb_interface_quirk_list);
if (quirks == 0)
return;
@@ -380,3 +539,11 @@ void usb_detect_interface_quirks(struct usb_device *udev)
quirks);
udev->quirks |= quirks;
}
+
+void usb_release_quirk_list(void)
+{
+ mutex_lock(&quirk_mutex);
+ kfree(quirk_list);
+ quirk_list = NULL;
+ mutex_unlock(&quirk_mutex);
+}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 2f5fbc56a9dd..0adb6345ff2e 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -1259,6 +1259,7 @@ static void __exit usb_exit(void)
if (usb_disabled())
return;
+ usb_release_quirk_list();
usb_deregister_device_driver(&usb_generic_driver);
usb_major_cleanup();
usb_deregister(&usbfs_driver);
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 149cc7480971..546a2219454b 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -36,6 +36,7 @@ extern void usb_deauthorize_interface(struct usb_interface *);
extern void usb_authorize_interface(struct usb_interface *);
extern void usb_detect_quirks(struct usb_device *udev);
extern void usb_detect_interface_quirks(struct usb_device *udev);
+extern void usb_release_quirk_list(void);
extern int usb_remove_device(struct usb_device *udev);
extern int usb_get_device_descriptor(struct usb_device *dev,
2018-03-12 16:30:40 +01:00
..
2018-02-15 14:50:32 -08:00
2018-01-27 20:02:24 +11:00
2017-10-11 15:38:10 +02:00
2018-03-12 16:30:40 +01:00
2017-09-22 21:57:09 +02:00
2018-01-30 13:57:43 -08:00
2017-11-14 20:13:33 -07:00
2017-09-07 21:11:05 -07:00
2018-02-02 11:14:19 +01:00
2017-10-12 11:25:31 -06:00
2018-01-30 09:52:11 -08:00
2018-02-06 16:41:29 -05:00
2018-02-08 10:21:39 +01:00
2017-11-03 22:11:23 +08:00
2017-11-17 17:51:33 -08:00
2018-01-30 16:55:47 -05:00
2018-03-09 09:43:52 -08:00
2017-12-21 13:41:46 -07:00
2018-02-02 10:47:15 +01:00
2018-01-08 10:08:34 +00:00
2018-01-31 19:25:25 -08:00
2017-11-08 03:39:52 -07:00
2018-02-10 12:45:10 +01:00
2018-02-06 14:43:37 +00:00
2017-11-28 16:30:37 +01:00
2018-02-01 10:49:58 -08:00
2018-02-22 08:39:26 +10:00
2017-10-12 11:14:06 -06:00
2018-01-02 15:05:34 -08:00
2018-02-21 09:17:20 +01:00
2017-11-18 11:32:27 +09:00
2017-07-25 19:56:23 +01:00
2018-02-04 11:56:49 -05:00
2018-02-01 10:49:58 -08:00
2018-01-27 20:02:24 +11:00
2018-01-31 19:25:25 -08:00
2017-07-12 16:26:00 -07:00
2018-01-17 16:45:01 -07:00
2017-10-12 11:13:28 -06:00
2017-10-23 20:17:03 +02:00
2018-01-11 10:58:03 +01:00
2018-02-11 12:28:58 +01:00
2017-12-11 14:46:10 -07:00
2018-01-15 14:29:42 -08:00
2018-01-23 07:25:26 -05:00
2018-02-01 12:45:35 -07:00
2017-12-13 00:36:00 +01:00
2018-02-14 14:52:39 -05:00
2017-08-24 13:31:58 -06:00
2017-10-30 21:37:53 +09:00
2017-05-16 08:44:19 -03:00
2018-01-02 16:43:12 +00:00
2018-01-29 11:32:44 -08:00
2017-07-07 13:55:45 -07:00
2017-09-08 18:26:51 -07:00
2018-02-07 09:42:59 -08:00
2017-12-11 09:21:58 -08:00
2017-11-16 09:00:35 +01:00
2017-12-02 08:43:43 -07:00
2018-01-08 14:20:31 -07:00
2017-06-03 18:48:52 +09:00
2017-05-16 08:44:18 -03:00
2017-11-14 18:01:46 -08:00
2018-01-22 08:17:16 -08:00
2018-01-17 16:49:05 -07:00
2017-07-17 13:48:45 -06:00
2017-05-26 13:11:00 +01:00
2018-02-06 18:32:48 -08:00
2018-01-03 13:11:48 +01:00
2017-09-26 14:58:23 -06:00
2017-12-21 13:39:31 -07:00
2018-02-01 13:36:15 -08:00
2018-01-31 19:25:25 -08:00
2017-08-14 13:46:50 -07:00
2018-02-01 16:13:07 +01:00
2018-01-31 19:25:25 -08:00
2018-01-31 19:25:25 -08:00
2018-02-03 11:09:54 +01:00
2018-02-23 08:40:12 +01:00
2017-12-16 22:37:12 -08:00
2017-12-21 13:41:46 -07:00
2018-02-13 14:55:53 +01:00
2017-08-25 11:06:33 +02:00
2017-07-14 13:51:27 -06:00
2017-07-14 13:51:27 -06:00
2017-07-14 13:51:27 -06:00
2017-07-14 13:51:28 -06:00
2017-07-14 13:51:28 -06:00
2018-01-16 08:07:09 -08:00
2017-12-05 11:57:53 -08:00
2017-11-17 16:10:00 -08:00
2017-07-14 13:51:29 -06:00
2017-12-11 15:20:04 -07:00
2017-07-14 13:51:30 -06:00
2017-07-14 13:51:30 -06:00
2017-07-14 13:51:30 -06:00
2017-07-14 13:51:31 -06:00
2017-07-14 13:51:34 -06:00
2017-07-14 13:58:12 -06:00
2017-07-14 13:51:31 -06:00
2017-07-14 13:51:32 -06:00
2017-09-01 11:59:17 +02:00
2017-07-14 13:51:33 -06:00
2017-07-14 13:51:33 -06:00
2017-08-19 11:02:53 -07:00
2017-07-14 13:51:34 -06:00
2017-07-14 13:51:34 -06:00
2017-07-14 13:51:35 -06:00
2017-07-14 13:51:35 -06:00
2017-07-14 13:51:36 -06:00
2017-07-14 13:51:36 -06:00
2017-07-14 13:51:37 -06:00
2017-07-14 13:51:37 -06:00
2018-01-06 10:58:02 -07:00
2017-07-14 13:51:38 -06:00
2017-07-14 13:51:38 -06:00
2017-07-14 13:51:39 -06:00
2017-07-14 13:51:38 -06:00
2017-07-14 13:51:40 -06:00
2017-09-27 16:03:45 -05:00
2017-07-14 13:51:41 -06:00
2018-01-24 12:32:58 +01:00
2017-07-14 13:51:42 -06:00
2017-07-14 13:51:42 -06:00
2017-07-14 13:51:43 -06:00
2017-07-14 13:51:43 -06:00
2017-07-14 13:51:43 -06:00
2017-07-14 13:51:44 -06:00
2017-10-20 11:02:55 +02:00
2017-07-14 13:51:45 -06:00
2017-07-14 13:51:45 -06:00
2017-07-14 13:51:46 -06:00
2017-05-16 08:44:19 -03:00
2017-07-14 13:51:46 -06:00
2017-07-14 13:51:47 -06:00
2017-10-12 11:07:42 -06:00
2017-12-05 11:57:53 -08:00
2017-07-14 13:57:53 -06:00
2017-07-14 13:57:54 -06:00
2017-07-14 13:57:55 -06:00
2017-07-15 12:58:58 -07:00
2017-07-14 13:57:56 -06:00
2017-07-14 13:57:56 -06:00
2017-07-14 13:57:57 -06:00
2017-07-14 13:57:58 -06:00
2017-07-14 13:57:58 -06:00
2017-10-19 12:56:44 -06:00
2017-07-14 13:57:59 -06:00
2017-07-14 13:58:00 -06:00
2017-07-06 08:23:30 +02:00
2017-09-08 18:26:48 -07:00
2017-07-14 13:58:02 -06:00
2017-07-14 13:58:02 -06:00
2017-07-14 13:58:03 -06:00
2017-07-14 13:58:03 -06:00
2017-07-14 13:58:04 -06:00
2018-01-12 00:20:41 +01:00
2017-07-14 13:58:04 -06:00
2017-07-14 13:58:05 -06:00
2017-07-14 13:58:06 -06:00
2017-07-14 13:58:06 -06:00
2017-07-14 13:58:07 -06:00
2018-01-30 21:54:28 +01:00
2017-08-10 12:28:59 +02:00
2017-11-20 10:45:50 -07:00
2017-11-18 20:37:13 -05:00
2017-05-24 13:01:27 -03:00
2017-07-14 13:58:14 -06:00
2017-07-14 13:58:08 -06:00
2017-07-14 13:58:09 -06:00
2017-07-14 13:58:10 -06:00
2017-07-14 13:58:10 -06:00
2017-07-14 13:58:11 -06:00
2017-07-14 13:58:11 -06:00
2017-07-14 13:58:12 -06:00