VirtualBox

Changeset 42138 in vbox


Ignore:
Timestamp:
Jul 13, 2012 9:49:48 AM (13 years ago)
Author:
vboxsync
Message:

PDMDriver.cpp: A pLun can be used with a normal device or a usb device, check if pDevIns is NULL to find out which it is.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp

    r41965 r42138  
    395395     * Gather the attributes used in the matching process.
    396396     */
    397     const char *pszDevice = pLun->pDevIns->Internal.s.pDevR3->pReg->szName;
     397    const char *pszDevice = pLun->pDevIns
     398                          ? pLun->pDevIns->Internal.s.pDevR3->pReg->szName
     399                          : pLun->pUsbIns->Internal.s.pUsbDev->pReg->szName;
    398400    char        szLun[32];
    399401    RTStrPrintf(szLun, sizeof(szLun), "%u", pLun->iLun);
     
    834836    if (pDrvIns->Internal.s.pUp
    835837        ? !pDrvIns->Internal.s.pUp->pReg->pfnDetach
    836         : !pDrvIns->Internal.s.pLun->pDevIns->pReg->pfnDetach)
     838        :   pDrvIns->Internal.s.pLun->pDevIns
     839          ? !pDrvIns->Internal.s.pLun->pDevIns->Internal.s.pDevR3->pReg->pfnDetach
     840          : !pDrvIns->Internal.s.pLun->pUsbIns->Internal.s.pUsbDev->pReg->pfnDriverDetach
     841       )
    837842    {
    838843        AssertMsgFailed(("Cannot detach driver instance because the driver/device above doesn't support it!\n"));
     
    901906            Assert(pLun->pTop == pCur);
    902907            pLun->pTop = NULL;
    903             if (!(fFlags & PDM_TACH_FLAGS_NO_CALLBACKS) && pLun->pDevIns->pReg->pfnDetach)
     908            if (!(fFlags & PDM_TACH_FLAGS_NO_CALLBACKS))
    904909            {
    905                 PDMCritSectEnter(pLun->pDevIns->pCritSectRoR3, VERR_IGNORED);
    906                 pLun->pDevIns->pReg->pfnDetach(pLun->pDevIns, pLun->iLun, fFlags);
    907                 PDMCritSectLeave(pLun->pDevIns->pCritSectRoR3);
     910                if (pLun->pDevIns)
     911                {
     912                    if (pLun->pDevIns->Internal.s.pDevR3->pReg->pfnDetach)
     913                    {
     914                        PDMCritSectEnter(pLun->pDevIns->pCritSectRoR3, VERR_IGNORED);
     915                        pLun->pDevIns->Internal.s.pDevR3->pReg->pfnDetach(pLun->pDevIns, pLun->iLun, fFlags);
     916                        PDMCritSectLeave(pLun->pDevIns->pCritSectRoR3);
     917                    }
     918                }
     919                else
     920                {
     921                    if (pLun->pUsbIns->Internal.s.pUsbDev->pReg->pfnDriverDetach)
     922                    {
     923                        /** @todo USB device locking? */
     924                        /** @todo add flags to pfnDriverDetach. */
     925                        pLun->pUsbIns->Internal.s.pUsbDev->pReg->pfnDriverDetach(pLun->pUsbIns, pLun->iLun);
     926                    }
     927                }
    908928            }
    909929        }
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