summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb_device.c
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2011-09-10 15:55:36 +0000
committerhselasky <hselasky@FreeBSD.org>2011-09-10 15:55:36 +0000
commit51e6bf127c1adb88842f4c0c83102e00d45f2731 (patch)
tree7724f0fc7a7c9bc3852ede5b8fd465396407b487 /sys/dev/usb/usb_device.c
parent0f94bf5e3e3273f05320c01e355014a79b8d8c1f (diff)
downloadFreeBSD-src-51e6bf127c1adb88842f4c0c83102e00d45f2731.zip
FreeBSD-src-51e6bf127c1adb88842f4c0c83102e00d45f2731.tar.gz
Refactor auto-quirk solution so that we break as few external
drivers as possible. PR: usb/160299 Approved by: re (kib) Suggested by: rwatson MFC after: 0 days
Diffstat (limited to 'sys/dev/usb/usb_device.c')
-rw-r--r--sys/dev/usb/usb_device.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c
index 3be9ba9..7e0de33 100644
--- a/sys/dev/usb/usb_device.c
+++ b/sys/dev/usb/usb_device.c
@@ -1239,8 +1239,6 @@ static void
usb_init_attach_arg(struct usb_device *udev,
struct usb_attach_arg *uaa)
{
- uint8_t x;
-
memset(uaa, 0, sizeof(*uaa));
uaa->device = udev;
@@ -1256,9 +1254,6 @@ usb_init_attach_arg(struct usb_device *udev,
uaa->info.bDeviceProtocol = udev->ddesc.bDeviceProtocol;
uaa->info.bConfigIndex = udev->curr_config_index;
uaa->info.bConfigNum = udev->curr_config_no;
-
- for (x = 0; x != USB_MAX_AUTO_QUIRK; x++)
- uaa->info.autoQuirk[x] = udev->autoQuirk[x];
}
/*------------------------------------------------------------------------*
@@ -2389,8 +2384,22 @@ uint8_t
usb_test_quirk(const struct usb_attach_arg *uaa, uint16_t quirk)
{
uint8_t found;
+ uint8_t x;
+
+ if (quirk == UQ_NONE)
+ return (0);
+
+ /* search the automatic per device quirks first */
+
+ for (x = 0; x != USB_MAX_AUTO_QUIRK; x++) {
+ if (uaa->device->autoQuirk[x] == quirk)
+ return (1);
+ }
+
+ /* search global quirk table, if any */
found = (usb_test_quirk_p) (&uaa->info, quirk);
+
return (found);
}
@@ -2723,7 +2732,8 @@ usbd_add_dynamic_quirk(struct usb_device *udev, uint16_t quirk)
uint8_t x;
for (x = 0; x != USB_MAX_AUTO_QUIRK; x++) {
- if (udev->autoQuirk[x] == 0) {
+ if (udev->autoQuirk[x] == 0 ||
+ udev->autoQuirk[x] == quirk) {
udev->autoQuirk[x] = quirk;
return (0); /* success */
}
OpenPOWER on IntegriCloud