third_party/virtualbox/src/VBox/Devices/USB/VUSBUrb.cpp
/**
 * Queues an URB for asynchronous transfer.
 * A list of asynchronous URBs is kept by the roothub.
 *
 * @returns VBox status code (from pfnUrbQueue).
 * @param   pUrb    The URB.
 */
Queues an URB for asynchronous transfer.
A list of asynchronous URBs is kept by the roothub.


Queues an URB for asynchronous transfer . A list of asynchronous URBs is kept by the roothub .
int vusbUrbQueueAsyncRh(PVUSBURB pUrb)
{
#ifdef LOG_ENABLED
    vusbUrbTrace(pUrb, "vusbUrbQueueAsyncRh", false);
#endif
    PVUSBDEV pDev = pUrb->pVUsb->pDev;
    PVUSBROOTHUB pRh = vusbDevGetRh(pDev);
    if (!pRh)
    {
        Log(("vusbUrbQueueAsyncRh returning VERR_OBJECT_DESTROYED\n"));
        return VERR_OBJECT_DESTROYED;
    }
    RTCritSectEnter(&pDev->CritSectAsyncUrbs);
    int rc = pDev->pUsbIns->pReg->pfnUrbQueue(pDev->pUsbIns, pUrb);
    if (RT_FAILURE(rc))
    {
        LogFlow(("%s: vusbUrbQueueAsyncRh: returns %Rrc (queue_urb)\n", pUrb->pszDesc, rc));
        RTCritSectLeave(&pDev->CritSectAsyncUrbs);
        return rc;
    }
    ASMAtomicIncU32(&pDev->aPipes[pUrb->EndPt].async);
    RTListAppend(&pDev->LstAsyncUrbs, &pUrb->pVUsb->NdLst);
    RTCritSectLeave(&pDev->CritSectAsyncUrbs);
    return VINF_SUCCESS;
}
int vusbUrbQueueAsyncRh ( PVUSBURB pUrb ) { #ifdef LOG_ENABLED vusbUrbTrace ( pUrb , " " , false ) ; #endif PVUSBDEV pDev = pUrb -> pVUsb -> pDev ; PVUSBROOTHUB pRh = vusbDevGetRh ( pDev ) ; if ( ! pRh ) { Log ( ( " \n " ) ) ; return VERR_OBJECT_DESTROYED ; } RTCritSectEnter ( & pDev -> CritSectAsyncUrbs ) ; int rc = pDev -> pUsbIns -> pReg -> pfnUrbQueue ( pDev -> pUsbIns , pUrb ) ; if ( RT_FAILURE ( rc ) ) { LogFlow ( ( " \n " , pUrb -> pszDesc , rc ) ) ; RTCritSectLeave ( & pDev -> CritSectAsyncUrbs ) ; return rc ; } ASMAtomicIncU32 ( & pDev -> aPipes [ pUrb -> EndPt ] . async ) ; RTListAppend ( & pDev -> LstAsyncUrbs , & pUrb -> pVUsb -> NdLst ) ; RTCritSectLeave ( & pDev -> CritSectAsyncUrbs ) ; return VINF_SUCCESS ; }
Queues an URB for asynchronous transfer.
Queues an URB for asynchronous transfer .
/* Immediately return in case of error.
     * XXX There is still a race: The Rh might vanish after this point! */ /* Queue the Urb on the roothub */