Improve support for detaching kernel drivers on a per interface basis.

MFC after:	1 week
This commit is contained in:
Hans Petter Selasky 2012-06-01 16:30:54 +00:00
parent 03b0ca8b28
commit d9073c1e6a
2 changed files with 20 additions and 5 deletions

View File

@ -750,10 +750,13 @@ usb_config_parse(struct usb_device *udev, uint8_t iface_index, uint8_t cmd)
if (do_init) {
/* setup the USB interface structure */
iface->idesc = id;
/* default setting */
iface->parent_iface_index = USB_IFACE_INDEX_ANY;
/* set alternate index */
iface->alt_index = alt_index;
/* set default interface parent */
if (iface_index == USB_IFACE_INDEX_ANY) {
iface->parent_iface_index =
USB_IFACE_INDEX_ANY;
}
}
DPRINTFN(5, "found idesc nendpt=%d\n", id->bNumEndpoints);
@ -1229,10 +1232,13 @@ usbd_set_parent_iface(struct usb_device *udev, uint8_t iface_index,
{
struct usb_interface *iface;
iface = usbd_get_iface(udev, iface_index);
if (iface) {
iface->parent_iface_index = parent_index;
if (udev == NULL) {
/* nothing to do */
return;
}
iface = usbd_get_iface(udev, iface_index);
if (iface != NULL)
iface->parent_iface_index = parent_index;
}
static void

View File

@ -2166,7 +2166,16 @@ ugen_ioctl_post(struct usb_fifo *f, u_long cmd, void *addr, int fflags)
break;
}
/*
* Detach the currently attached driver.
*/
usb_detach_device(f->udev, n, 0);
/*
* Set parent to self, this should keep attach away
* until the next set configuration event.
*/
usbd_set_parent_iface(f->udev, n, n);
break;
case USB_SET_POWER_MODE: