VirtualBox

Ignore:
Timestamp:
Feb 28, 2022 1:16:30 PM (3 years ago)
Author:
vboxsync
Message:

Devices/USB: Get rid of the VUSBHUB structure which was mostly meaningless as roothubs were supported only since forever, bugref:10196

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp

    r93974 r93979  
    343343static int vusbHubAttach(PVUSBROOTHUB pThis, PVUSBDEV pDev)
    344344{
    345     LogFlow(("vusbHubAttach: pThis=%p[%s] pDev=%p[%s]\n", pThis, pThis->Hub.pszName, pDev, pDev->pUsbIns->pszName));
    346 
    347     PVUSBHUB pHub = &pThis->Hub;
     345    LogFlow(("vusbHubAttach: pThis=%p[%s] pDev=%p[%s]\n", pThis, pThis->pszName, pDev, pDev->pUsbIns->pszName));
    348346
    349347    /*
     
    357355    }
    358356    ASMBitClear(&pThis->Bitmap, iPort);
    359     pHub->cDevices++;
     357    pThis->cDevices++;
    360358    pDev->i16Port = iPort;
    361359
    362360    /* Call the device attach helper, so it can initialize its state. */
    363     int rc = vusbDevAttach(pDev, pHub);
     361    int rc = vusbDevAttach(pDev, pThis);
    364362    if (RT_SUCCESS(rc))
    365363    {
     
    378376        {
    379377            LogRel(("VUSB: Attached '%s' to port %d on %s (%sSpeed)\n", pDev->pUsbIns->pszName,
    380                     iPort, pHub->pszName, vusbGetSpeedString(pDev->pUsbIns->enmSpeed)));
     378                    iPort, pThis->pszName, vusbGetSpeedString(pDev->pUsbIns->enmSpeed)));
    381379            return VINF_SUCCESS;
    382380        }
     
    392390
    393391    ASMBitSet(&pThis->Bitmap, iPort);
    394     pHub->cDevices--;
     392    pThis->cDevices--;
    395393    pDev->i16Port = -1;
    396394    LogRel(("VUSB: Failed to attach '%s' to port %d, rc=%Rrc\n", pDev->pUsbIns->pszName, iPort, rc));
     
    409407static int vusbHubDetach(PVUSBROOTHUB pThis, PVUSBDEV pDev)
    410408{
    411     PVUSBHUB pHub = &pThis->Hub;
    412 
    413409    Assert(pDev->i16Port != -1);
    414410
     
    423419    pThis->pIRhPort->pfnDetach(pThis->pIRhPort, uPort);
    424420    ASMBitSet(&pThis->Bitmap, uPort);
    425     pHub->cDevices--;
     421    pThis->cDevices--;
    426422
    427423    /* Check that it's attached and remove it. */
     
    480476    RT_NOREF(iPort);
    481477    PVUSBROOTHUB pThis = PDMINS_2_DATA(pDrvIns, PVUSBROOTHUB);
    482     PVUSBHUB pHub = &pThis->Hub;
    483478    PVUSBDEV pDev = (PVUSBDEV)pUsbIns->pvVUsbDev2;
    484479    Assert(pDev);
    485480
    486     LogRel(("VUSB: Detached '%s' from port %u on %s\n", pDev->pUsbIns->pszName, pDev->i16Port, pHub->pszName));
     481    LogRel(("VUSB: Detached '%s' from port %u on %s\n", pDev->pUsbIns->pszName, pDev->i16Port, pThis->pszName));
    487482
    488483    /*
     
    544539    }
    545540    else
    546         vusbUrbPoolFree(&pRh->Hub.Dev.UrbPool, pUrb);
     541        vusbUrbPoolFree(&pRh->Dev.UrbPool, pUrb);
    547542}
    548543
     
    555550{
    556551    RT_NOREF(pszTag);
    557     PVUSBURBPOOL pUrbPool = &pRh->Hub.Dev.UrbPool;
     552    PVUSBURBPOOL pUrbPool = &pRh->Dev.UrbPool;
    558553
    559554    if (RT_UNLIKELY(cbData > (32 * _1M)))
     
    822817    LogFlow(("vusR3bRhPowerOn: pRh=%p\n", pRh));
    823818
    824     Assert(     pRh->Hub.Dev.enmState != VUSB_DEVICE_STATE_DETACHED
    825            &&   pRh->Hub.Dev.enmState != VUSB_DEVICE_STATE_RESET);
    826 
    827     if (pRh->Hub.Dev.enmState == VUSB_DEVICE_STATE_ATTACHED)
    828         pRh->Hub.Dev.enmState = VUSB_DEVICE_STATE_POWERED;
     819    Assert(     pRh->Dev.enmState != VUSB_DEVICE_STATE_DETACHED
     820           &&   pRh->Dev.enmState != VUSB_DEVICE_STATE_RESET);
     821
     822    if (pRh->Dev.enmState == VUSB_DEVICE_STATE_ATTACHED)
     823        pRh->Dev.enmState = VUSB_DEVICE_STATE_POWERED;
    829824
    830825    return VINF_SUCCESS;
     
    838833    LogFlow(("vusbR3RhDevPowerOff: pThis=%p\n", pThis));
    839834
    840     Assert(     pThis->Hub.Dev.enmState != VUSB_DEVICE_STATE_DETACHED
    841            &&   pThis->Hub.Dev.enmState != VUSB_DEVICE_STATE_RESET);
     835    Assert(     pThis->Dev.enmState != VUSB_DEVICE_STATE_DETACHED
     836           &&   pThis->Dev.enmState != VUSB_DEVICE_STATE_RESET);
    842837
    843838    /*
     
    848843        VUSBIRhReapAsyncUrbs(&pThis->IRhConnector, uPort, 0);
    849844
    850     pThis->Hub.Dev.enmState = VUSB_DEVICE_STATE_ATTACHED;
     845    pThis->Dev.enmState = VUSB_DEVICE_STATE_ATTACHED;
    851846    return VINF_SUCCESS;
    852847}
     
    949944    else
    950945    {
    951         vusbDevRetain(&pRh->Hub.Dev);
    952         pUrb->pVUsb->pDev = &pRh->Hub.Dev;
     946        vusbDevRetain(&pRh->Dev);
     947        pUrb->pVUsb->pDev = &pRh->Dev;
    953948        Log(("vusb: pRh=%p: SUBMIT: Address %i not found!!!\n", pRh, pUrb->DstAddress));
    954949
     
    11011096    PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort);
    11021097
    1103     if (&pRh->Hub != pDev->pHub)
     1098    if (pDev->pHub != pRh)
    11041099        AssertFailedReturn(VERR_INVALID_PARAMETER);
    11051100
     
    14941489    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
    14951490    PDMIBASE_RETURN_INTERFACE(pszIID, VUSBIROOTHUBCONNECTOR, &pRh->IRhConnector);
    1496     PDMIBASE_RETURN_INTERFACE(pszIID, VUSBIDEVICE, &pRh->Hub.Dev.IDevice);
    14971491    return NULL;
    14981492}
     
    15151509    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    15161510
    1517     vusbUrbPoolDestroy(&pRh->Hub.Dev.UrbPool);
    1518     if (pRh->Hub.pszName)
    1519     {
    1520         RTStrFree(pRh->Hub.pszName);
    1521         pRh->Hub.pszName = NULL;
     1511    vusbUrbPoolDestroy(&pRh->Dev.UrbPool);
     1512    if (pRh->pszName)
     1513    {
     1514        RTStrFree(pRh->pszName);
     1515        pRh->pszName = NULL;
    15221516    }
    15231517    if (pRh->hSniffer != VUSBSNIFFER_NIL)
     
    15791573    pDrvIns->IBase.pfnQueryInterface    = vusbRhQueryInterface;
    15801574    /* the usb device */
    1581     pThis->Hub.Dev.enmState             = VUSB_DEVICE_STATE_ATTACHED;
    1582     pThis->Hub.Dev.cRefs                = 1;
    1583     /* the hub */
    1584     pThis->Hub.pRootHub                 = pThis;
     1575    pThis->Dev.enmState                 = VUSB_DEVICE_STATE_ATTACHED;
     1576    pThis->Dev.cRefs                    = 1;
    15851577    //pThis->hub.cPorts                - later
    1586     pThis->Hub.cDevices                 = 0;
    1587     pThis->Hub.Dev.pHub                 = &pThis->Hub;
    1588     RTStrAPrintf(&pThis->Hub.pszName, "RootHub#%d", pDrvIns->iInstance);
     1578    pThis->cDevices                     = 0;
     1579    pThis->Dev.pHub                     = pThis;
     1580    RTStrAPrintf(&pThis->pszName, "RootHub#%d", pDrvIns->iInstance);
    15891581    /* misc */
    15901582    pThis->pDrvIns                      = pDrvIns;
     
    16271619     * ASSUME that the number of ports reported now at creation time is the max number.
    16281620     */
    1629     pThis->Hub.cPorts = pThis->pIRhPort->pfnGetAvailablePorts(pThis->pIRhPort, &pThis->Bitmap);
    1630     Log(("vusbRhConstruct: cPorts=%d\n", pThis->Hub.cPorts));
     1621    pThis->cPorts = pThis->pIRhPort->pfnGetAvailablePorts(pThis->pIRhPort, &pThis->Bitmap);
     1622    Log(("vusbRhConstruct: cPorts=%d\n", pThis->cPorts));
    16311623
    16321624    /*
     
    16371629    Log(("vusbRhConstruct: fHcVersions=%u\n", pThis->fHcVersions));
    16381630
    1639     rc = vusbUrbPoolInit(&pThis->Hub.Dev.UrbPool);
     1631    rc = vusbUrbPoolInit(&pThis->Dev.UrbPool);
    16401632    if (RT_FAILURE(rc))
    16411633        return rc;
     
    16571649     */
    16581650    PCPDMUSBHUBHLP pHlpUsb; /* not used currently */
    1659     rc = PDMDrvHlpUSBRegisterHub(pDrvIns, pThis->fHcVersions, pThis->Hub.cPorts, &g_vusbHubReg, &pHlpUsb);
     1651    rc = PDMDrvHlpUSBRegisterHub(pDrvIns, pThis->fHcVersions, pThis->cPorts, &g_vusbHubReg, &pHlpUsb);
    16601652    if (RT_FAILURE(rc))
    16611653        return rc;
     
    18001792                           "/VUSB/%d/FramesProcessedClbk",     pDrvIns->iInstance);
    18011793#endif
    1802     PDMDrvHlpSTAMRegisterF(pDrvIns, (void *)&pThis->Hub.Dev.UrbPool.cUrbsInPool, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "The number of URBs in the pool.",
     1794    PDMDrvHlpSTAMRegisterF(pDrvIns, (void *)&pThis->Dev.UrbPool.cUrbsInPool, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "The number of URBs in the pool.",
    18031795                           "/VUSB/%d/cUrbsInPool",             pDrvIns->iInstance);
    18041796
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette