Fix for deadlock in USB device side mode.

MFC after:	3 days
This commit is contained in:
Hans Petter Selasky 2014-08-05 06:38:21 +00:00
parent c65494287f
commit c3ccd2bf8c

View File

@ -448,6 +448,17 @@ usb_endpoint_foreach(struct usb_device *udev, struct usb_endpoint *ep)
return (NULL);
}
#if USB_HAVE_UGEN
static uint16_t
usb_get_refcount(struct usb_device *udev)
{
if (usb_proc_is_called_from(USB_BUS_EXPLORE_PROC(udev->bus)) ||
usb_proc_is_called_from(USB_BUS_CONTROL_XFER_PROC(udev->bus)))
return (1);
return (2);
}
#endif
/*------------------------------------------------------------------------*
* usb_wait_pending_ref_locked
*
@ -460,9 +471,7 @@ static void
usb_wait_pending_ref_locked(struct usb_device *udev)
{
#if USB_HAVE_UGEN
const uint16_t refcount =
usb_proc_is_called_from(
USB_BUS_EXPLORE_PROC(udev->bus)) ? 1 : 2;
const uint16_t refcount = usb_get_refcount(udev);
DPRINTF("Refcount = %d\n", (int)refcount);
@ -493,9 +502,7 @@ static void
usb_ref_restore_locked(struct usb_device *udev)
{
#if USB_HAVE_UGEN
const uint16_t refcount =
usb_proc_is_called_from(
USB_BUS_EXPLORE_PROC(udev->bus)) ? 1 : 2;
const uint16_t refcount = usb_get_refcount(udev);
DPRINTF("Refcount = %d\n", (int)refcount);