From owner-svn-src-all@FreeBSD.ORG Sun Sep 11 21:47:04 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 11415106566C; Sun, 11 Sep 2011 21:47:04 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id DD8118FC13; Sun, 11 Sep 2011 21:47:03 +0000 (UTC) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id 73CEB46B06; Sun, 11 Sep 2011 17:47:03 -0400 (EDT) Date: Sun, 11 Sep 2011 22:47:03 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Hans Petter Selasky In-Reply-To: <201109101555.p8AFtavQ098290@svn.freebsd.org> Message-ID: References: <201109101555.p8AFtavQ098290@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r225469 - in head/sys: dev/usb dev/usb/quirk sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Sep 2011 21:47:04 -0000 On Sat, 10 Sep 2011, Hans Petter Selasky wrote: > Refactor auto-quirk solution so that we break as few external > drivers as possible. > > PR: usb/160299 > Approved by: re (kib) > Suggested by: rwatson Thanks, much appreciated! Robert > MFC after: 0 days > > Modified: > head/sys/dev/usb/quirk/usb_quirk.c > head/sys/dev/usb/usb_device.c > head/sys/dev/usb/usb_dynamic.c > head/sys/dev/usb/usb_dynamic.h > head/sys/dev/usb/usbdi.h > head/sys/sys/param.h > > Modified: head/sys/dev/usb/quirk/usb_quirk.c > ============================================================================== > --- head/sys/dev/usb/quirk/usb_quirk.c Sat Sep 10 12:36:11 2011 (r225468) > +++ head/sys/dev/usb/quirk/usb_quirk.c Sat Sep 10 15:55:36 2011 (r225469) > @@ -588,7 +588,7 @@ usb_test_quirk_by_info(const struct usbd > } > mtx_unlock(&usb_quirk_mtx); > done: > - return (usb_test_quirk_w(info, quirk)); > + return (0); /* no quirk match */ > } > > static struct usb_quirk_entry * > > Modified: head/sys/dev/usb/usb_device.c > ============================================================================== > --- head/sys/dev/usb/usb_device.c Sat Sep 10 12:36:11 2011 (r225468) > +++ head/sys/dev/usb/usb_device.c Sat Sep 10 15:55:36 2011 (r225469) > @@ -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 *u > 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 > 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 */ > } > > Modified: head/sys/dev/usb/usb_dynamic.c > ============================================================================== > --- head/sys/dev/usb/usb_dynamic.c Sat Sep 10 12:36:11 2011 (r225468) > +++ head/sys/dev/usb/usb_dynamic.c Sat Sep 10 15:55:36 2011 (r225469) > @@ -50,12 +50,12 @@ > #include > #include > #include > -#include > > /* function prototypes */ > static usb_handle_req_t usb_temp_get_desc_w; > static usb_temp_setup_by_index_t usb_temp_setup_by_index_w; > static usb_temp_unsetup_t usb_temp_unsetup_w; > +static usb_test_quirk_t usb_test_quirk_w; > static usb_quirk_ioctl_t usb_quirk_ioctl_w; > > /* global variables */ > @@ -72,19 +72,9 @@ usb_temp_setup_by_index_w(struct usb_dev > return (USB_ERR_INVAL); > } > > -uint8_t > +static uint8_t > usb_test_quirk_w(const struct usbd_lookup_info *info, uint16_t quirk) > { > - uint8_t x; > - > - if (quirk == UQ_NONE) > - return (0); /* no match */ > - > - for (x = 0; x != USB_MAX_AUTO_QUIRK; x++) { > - if (info->autoQuirk[x] == quirk) > - return (1); /* match */ > - } > - > return (0); /* no match */ > } > > > Modified: head/sys/dev/usb/usb_dynamic.h > ============================================================================== > --- head/sys/dev/usb/usb_dynamic.h Sat Sep 10 12:36:11 2011 (r225468) > +++ head/sys/dev/usb/usb_dynamic.h Sat Sep 10 15:55:36 2011 (r225469) > @@ -57,6 +57,5 @@ extern devclass_t usb_devclass_ptr; > void usb_temp_unload(void *); > void usb_quirk_unload(void *); > void usb_bus_unload(void *); > -usb_test_quirk_t usb_test_quirk_w; > > #endif /* _USB_DYNAMIC_H_ */ > > Modified: head/sys/dev/usb/usbdi.h > ============================================================================== > --- head/sys/dev/usb/usbdi.h Sat Sep 10 12:36:11 2011 (r225468) > +++ head/sys/dev/usb/usbdi.h Sat Sep 10 15:55:36 2011 (r225469) > @@ -353,7 +353,6 @@ struct usbd_lookup_info { > uint16_t idVendor; > uint16_t idProduct; > uint16_t bcdDevice; > - uint16_t autoQuirk[USB_MAX_AUTO_QUIRK]; > uint8_t bDeviceClass; > uint8_t bDeviceSubClass; > uint8_t bDeviceProtocol; > > Modified: head/sys/sys/param.h > ============================================================================== > --- head/sys/sys/param.h Sat Sep 10 12:36:11 2011 (r225468) > +++ head/sys/sys/param.h Sat Sep 10 15:55:36 2011 (r225469) > @@ -58,7 +58,7 @@ > * in the range 5 to 9. > */ > #undef __FreeBSD_version > -#define __FreeBSD_version 900043 /* Master, propagated to newvers */ > +#define __FreeBSD_version 900044 /* Master, propagated to newvers */ > > #ifdef _KERNEL > #define P_OSREL_SIGSEGV 700004 >