VirtualBox

Changeset 50234 in vbox for trunk


Ignore:
Timestamp:
Jan 24, 2014 10:48:13 PM (11 years ago)
Author:
vboxsync
Message:

USB/Proxy: More code cleanup and finish a few todos, also some new ones so it doesn't get boring

Location:
trunk/src/VBox
Files:
9 edited

Legend:

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

    r50229 r50234  
    5353         * Setup a MSG URB, queue and reap it.
    5454         */
     55        int rc = VINF_SUCCESS;
    5556        VUSBURB Urb;
    5657        AssertCompile(RT_SIZEOFMEMB(VUSBURB, abData) >= _4K);
     
    7980        pSetup->wLength = cbHint;
    8081
    81         if (!pProxyDev->pOps->pfnUrbQueue(&Urb))
     82        rc = pProxyDev->pOps->pfnUrbQueue(pProxyDev, &Urb);
     83        if (RT_FAILURE(rc))
    8284            break;
    8385
     
    8991        if (!pUrbReaped)
    9092        {
    91             pProxyDev->pOps->pfnUrbCancel(&Urb);
     93            rc = pProxyDev->pOps->pfnUrbCancel(pProxyDev, &Urb);
     94            AssertRC(rc);
     95            /** @todo: This breaks the comment above... */
    9296            pUrbReaped = pProxyDev->pOps->pfnUrbReap(pProxyDev, RT_INDEFINITE_WAIT);
    9397        }
     
    629633             pUsbIns->pszName, bInterfaceNumber, bAlternateSetting));
    630634
    631     /** @todo this is fishy, pfnSetInterface returns true/false from what I can see... */
    632     if (pProxyDev->pOps->pfnSetInterface(pProxyDev, bInterfaceNumber, bAlternateSetting) < 0)
    633         return VERR_GENERAL_FAILURE;
    634     return VINF_SUCCESS;
     635    return pProxyDev->pOps->pfnSetInterface(pProxyDev, bInterfaceNumber, bAlternateSetting);
    635636}
    636637
     
    647648             pUsbIns->pszName, uEndpoint));
    648649
    649     if (!pProxyDev->pOps->pfnClearHaltedEndpoint(pProxyDev, uEndpoint))
    650         return VERR_GENERAL_FAILURE;
    651     return VINF_SUCCESS;
     650    return pProxyDev->pOps->pfnClearHaltedEndpoint(pProxyDev, uEndpoint);
    652651}
    653652
     
    660659static DECLCALLBACK(int) usbProxyDevUrbQueue(PPDMUSBINS pUsbIns, PVUSBURB pUrb)
    661660{
     661    int rc = VINF_SUCCESS;
    662662    PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUsbIns, PUSBPROXYDEV);
    663     if (!pProxyDev->pOps->pfnUrbQueue(pUrb))
     663    rc = pProxyDev->pOps->pfnUrbQueue(pProxyDev, pUrb);
     664    if (RT_FAILURE(rc))
    664665        return pProxyDev->fDetached
    665666             ? VERR_VUSB_DEVICE_NOT_ATTACHED
    666667             : VERR_VUSB_FAILED_TO_QUEUE_URB;
    667     return VINF_SUCCESS;
     668    return rc;
    668669}
    669670
     
    677678{
    678679    PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUsbIns, PUSBPROXYDEV);
    679     pProxyDev->pOps->pfnUrbCancel(pUrb);
    680     return VINF_SUCCESS;
     680    return pProxyDev->pOps->pfnUrbCancel(pProxyDev, pUrb);
    681681}
    682682
  • trunk/src/VBox/Devices/USB/USBProxyDevice.h

    r50229 r50234  
    2525
    2626
    27 /**
    28  * Arguments passed to the USB proxy device constructor.
    29  */
    30 typedef struct USBPROXYDEVARGS
    31 {
    32     /** Whether this is a remote (VRDP) or local (Host) device. */
    33     bool        fRemote;
    34     /** Host specific USB device address. */
    35     const char *pszAddress;
    36     /** Pointer to backend specific data. */
    37     void       *pvBackend;
    38 } USBPROXYDEVARGS;
    39 /** Pointer to proxy device creation structure. */
    40 typedef USBPROXYDEVARGS *PUSBPROXYDEVARGS;
    41 
    42 
    4327/** Pointer to a USB proxy device. */
    4428typedef struct USBPROXYDEV *PUSBPROXYDEV;
     
    7357     *
    7458     * @returns VBox status code.
    75      * @param   pProxyDev   The USB Proxy Device instance.
     59     * @param   pProxyDev       The USB Proxy Device instance.
    7660     */
    7761    DECLR3CALLBACKMEMBER(int, pfnInit, (PUSBPROXYDEV pProxyDev));
     
    8064     * Closes handle to the host USB device.
    8165     *
    82      * @param   pDev        The USB Proxy Device instance.
     66     * @param   pProxyDev       The USB Proxy Device instance.
    8367     */
    8468    DECLR3CALLBACKMEMBER(void, pfnClose, (PUSBPROXYDEV pProxyDev));
     
    9074     *
    9175     * @returns VBox status code.
    92      * @param   pDev            The device to reset.
     76     * @param   pProxyDev       The USB Proxy Device instance.
    9377     * @param   fResetOnLinux   It's safe to do reset on linux, we can deal with devices
    9478     *                          being logically reconnected.
     
    9680    DECLR3CALLBACKMEMBER(int, pfnReset, (PUSBPROXYDEV pProxyDev, bool fResetOnLinux));
    9781
    98     /** @todo make it return a VBox status code! */
     82    /**
     83     * Sets the given configuration of the device.
     84     *
     85     * @returns VBox status code.
     86     * @param   pProxyDev       The USB Proxy Device instance.
     87     * @param   iCfg            The configuration to set.
     88     */
    9989    DECLR3CALLBACKMEMBER(int, pfnSetConfig, (PUSBPROXYDEV pProxyDev, int iCfg));
    10090
    101     /** @todo make it return a VBox status code! */
     91    /**
     92     * Claim an interface for use by the prox device.
     93     *
     94     * @returns VBox status code.
     95     * @param   pProxyDev       The USB Proxy Device instance.
     96     * @param   iIf             Interface number to claim.
     97     */
    10298    DECLR3CALLBACKMEMBER(int, pfnClaimInterface, (PUSBPROXYDEV pProxyDev, int iIf));
    10399
    104     /** @todo make it return a VBox status code! */
     100    /**
     101     * Releases an interface which was claimed before.
     102     *
     103     * @returns VBox status code.
     104     * @param   pProxyDev       The USB Proxy Device instance.
     105     * @param   iIf             Interface number to release.
     106     */
    105107    DECLR3CALLBACKMEMBER(int, pfnReleaseInterface, (PUSBPROXYDEV pProxyDev, int iIf));
    106108
    107     /** @todo make it return a VBox status code! */
    108     DECLR3CALLBACKMEMBER(int, pfnSetInterface, (PUSBPROXYDEV pProxyDev, int iIf, int setting));
    109 
    110     /** @todo make it return a VBox status code! */
    111     DECLR3CALLBACKMEMBER(bool, pfnClearHaltedEndpoint, (PUSBPROXYDEV  pDev, unsigned int iEp));
    112 
    113     /** @todo make it return a VBox status code! Add pDev. */
    114     DECLR3CALLBACKMEMBER(int, pfnUrbQueue, (PVUSBURB pUrb));
     109    /**
     110     * Sets the given alternate interface for the device.
     111     *
     112     * @returns VBox status code.
     113     * @param   pProxyDev       The USB Proxy Device instance.
     114     * @param   iIf             Interface to use.
     115     * @param   iSetting        The alternate setting to use.
     116     */
     117    DECLR3CALLBACKMEMBER(int, pfnSetInterface, (PUSBPROXYDEV pProxyDev, int iIf, int iSetting));
     118
     119    /**
     120     * Clears the given halted endpoint.
     121     *
     122     * @returns VBox status code.
     123     * @param   pProxyDev       The USB Proxy Device instance.
     124     * @param   iEp             The endpoint to clear.
     125     */
     126    DECLR3CALLBACKMEMBER(int, pfnClearHaltedEndpoint, (PUSBPROXYDEV  pDev, unsigned int iEp));
     127
     128    /**
     129     * Queue a new URB.
     130     *
     131     * @returns VBox status code.
     132     * @param   pProxyDev       The USB Proxy Device instance.
     133     * @param   pUrb            The URB to queue.
     134     */
     135    DECLR3CALLBACKMEMBER(int, pfnUrbQueue, (PUSBPROXYDEV pProxyDev, PVUSBURB pUrb));
    115136
    116137    /**
    117138     * Cancel an in-flight URB.
    118139     *
    119      * @param   pUrb        The URB to cancel.
    120      * @todo make it return a VBox status code! Add pDev.
    121      */
    122     DECLR3CALLBACKMEMBER(void, pfnUrbCancel, (PVUSBURB pUrb));
     140     * @returns VBox status code.
     141     * @param   pProxyDev       The USB Proxy Device instance.
     142     * @param   pUrb            The URB to cancel.
     143     */
     144    DECLR3CALLBACKMEMBER(int, pfnUrbCancel, (PUSBPROXYDEV pProxyDev, PVUSBURB pUrb));
    123145
    124146    /**
     
    127149     * @returns Pointer to a completed URB.
    128150     * @returns NULL if no URB was completed.
    129      * @param   pDev        The device.
    130      * @param   cMillies    Number of milliseconds to wait. Use 0 to not
    131      *                      wait at all.
     151     * @param   pProxyDev       The USB Proxy Device instance.
     152     * @param   cMillies        Number of milliseconds to wait. Use 0 to not
     153     *                          wait at all.
    132154     */
    133155    DECLR3CALLBACKMEMBER(PVUSBURB, pfnUrbReap, (PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies));
     
    137159     *
    138160     * @returns VBox status code.
    139      * @param   pProxyDev   The device.
     161     * @param   pProxyDev       The USB Proxy Device instance.
    140162     */
    141163    DECLR3CALLBACKMEMBER(int, pfnWakeup, (PUSBPROXYDEV pProxyDev));
  • trunk/src/VBox/Devices/USB/darwin/USBProxyDevice-darwin.cpp

    r50231 r50234  
    14821482    {
    14831483        Log(("usbProxyDarwinSetConfig: Set configuration -> %#x\n", irc));
    1484         return false;
     1484        return RTErrConvertFromDarwin(irc);
    14851485    }
    14861486
    14871487    usbProxyDarwinReleaseAllInterfaces(pDevOsX);
    14881488    usbProxyDarwinSeizeAllInterfaces(pDevOsX, true /* make the best out of it */);
    1489     return true;
     1489    return VINF_SUCCESS;
    14901490}
    14911491
     
    14971497 * open/reset/setconfig time.
    14981498 *
    1499  * @returns success indicator (always true).
     1499 * @returns success indicator (always VINF_SUCCESS).
    15001500 */
    15011501static DECLCALLBACK(int) usbProxyDarwinClaimInterface(PUSBPROXYDEV pProxyDev, int iIf)
    15021502{
    1503     return true;
     1503    return VINF_SUCCESS;
    15041504}
    15051505
     
    15151515static DECLCALLBACK(int) usbProxyDarwinReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf)
    15161516{
    1517     return true;
     1517    return VINF_SUCCESS;
    15181518}
    15191519
     
    15401540            {
    15411541                usbProxyDarwinGetPipeProperties(pDevOsX, pIf);
    1542                 return true;
     1542                return VINF_SUCCESS;
    15431543            }
    15441544        }
     
    15581558            irc = (*pDevOsX->ppDevI)->DeviceRequest(pDevOsX->ppDevI, &Req);
    15591559            Log(("usbProxyDarwinSetInterface: SET_INTERFACE(%d,%d) -> irc=%#x\n", iIf, iAlt, irc));
    1560             return true;
     1560            return VINF_SUCCESS;
    15611561        }
    15621562    }
     
    15641564    LogFlow(("usbProxyDarwinSetInterface: pProxyDev=%s eiIf=%#x iAlt=%#x - failure - pIf=%p irc=%#x\n",
    15651565             pProxyDev->pUsbIns->pszName, iIf, iAlt, pIf, irc));
    1566     return false;
     1566    return RTErrConvertFromDarwin(irc);
    15671567}
    15681568
     
    15711571 * Clears the halted endpoint 'EndPt'.
    15721572 */
    1573 static DECLCALLBACK(bool) usbProxyDarwinClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)
     1573static DECLCALLBACK(int) usbProxyDarwinClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)
    15741574{
    15751575    PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
     
    15811581     */
    15821582    if (EndPt == 0)
    1583         return true;
     1583        return VINF_SUCCESS;
    15841584
    15851585    /*
     
    15951595        irc = (*pIf->ppIfI)->ClearPipeStallBothEnds(pIf->ppIfI, u8PipeRef);
    15961596        if (irc == kIOReturnSuccess)
    1597             return true;
     1597            return VINF_SUCCESS;
    15981598        AssertMsg(irc == kIOReturnNoDevice || irc == kIOReturnNotResponding, ("irc=#x (control pipe?)\n", irc));
    15991599    }
     
    16011601    LogFlow(("usbProxyDarwinClearHaltedEp: pProxyDev=%s EndPt=%#x - failure - pIf=%p irc=%#x\n",
    16021602             pProxyDev->pUsbIns->pszName, EndPt, pIf, irc));
    1603     return false;
     1603    return RTErrConvertFromDarwin(irc);
    16041604}
    16051605
     
    16081608 * @copydoc USBPROXYBACK::pfnUrbQueue
    16091609 */
    1610 static DECLCALLBACK(int) usbProxyDarwinUrbQueue(PVUSBURB pUrb)
    1611 {
    1612     PUSBPROXYDEV    pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);
     1610static DECLCALLBACK(int) usbProxyDarwinUrbQueue(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
     1611{
    16131612    PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
    16141613    LogFlow(("%s: usbProxyDarwinUrbQueue: pProxyDev=%s pUrb=%p EndPt=%d cbData=%d\n",
     
    16291628            LogFlow(("%s: usbProxyDarwinUrbQueue: pProxyDev=%s EndPt=%d cbData=%d - can't find interface / pipe!!!\n",
    16301629                     pUrb->pszDesc, pProxyDev->pUsbIns->pszName, pUrb->EndPt, pUrb->cbData));
    1631             return false;
     1630            return VERR_NOT_FOUND;
    16321631        }
    16331632
     
    16461645    PUSBPROXYURBOSX pUrbOsX = usbProxyDarwinUrbAlloc(pDevOsX);
    16471646    if (!pUrbOsX)
    1648         return false;
     1647        return VERR_NO_MEMORY;
    16491648
    16501649    pUrbOsX->u64SubmitTS = RTTimeMilliTS();
     
    17951794    {
    17961795        Log(("%s: usbProxyDarwinUrbQueue: success\n", pUrb->pszDesc));
    1797         return true;
     1796        return VINF_SUCCESS;
    17981797    }
    17991798    switch (irc)
     
    18041803            Log(("%s: usbProxyDarwinUrbQueue: pProxyDev=%s EndPt=%d cbData=%d - failed irc=%#x! (stall)\n",
    18051804                 pUrb->pszDesc, pProxyDev->pUsbIns->pszName, pUrb->EndPt, pUrb->cbData, irc));
    1806             return true;
     1805            return VINF_SUCCESS;
    18071806        }
    18081807    }
     
    18101809    Log(("%s: usbProxyDarwinUrbQueue: pProxyDev=%s EndPt=%d cbData=%d - failed irc=%#x!\n",
    18111810         pUrb->pszDesc, pProxyDev->pUsbIns->pszName, pUrb->EndPt, pUrb->cbData, irc));
    1812     return false;
     1811    return RTErrConvertFromDarwin(irc);
    18131812}
    18141813
     
    18961895 *          requests, we should probably be fine...
    18971896 */
    1898 static DECLCALLBACK(void) usbProxyDarwinUrbCancel(PVUSBURB pUrb)
    1899 {
    1900     PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);
     1897static DECLCALLBACK(int) usbProxyDarwinUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
     1898{
    19011899    PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX);
    1902     //PUSBPROXYURBOSX pUrbOsX = (PUSBPROXYURBOSX)pUrb->Dev.pvProxyUrb;
    19031900    LogFlow(("%s: usbProxyDarwinUrbCancel: pProxyDev=%s EndPt=%d\n",
    19041901             pUrb->pszDesc, pProxyDev->pUsbIns->pszName, pUrb->EndPt));
     
    19211918                 pProxyDev->pUsbIns->pszName, pUrb, pUrb->EndPt));
    19221919    }
     1920
     1921    int rc = VINF_SUCCESS;
    19231922    if (irc != kIOReturnSuccess)
     1923    {
    19241924        Log(("usbProxyDarwinUrbCancel: pProxyDev=%s pUrb=%p EndPt=%d -> %#x!\n",
    19251925             pProxyDev->pUsbIns->pszName, pUrb, pUrb->EndPt, irc));
     1926        rc = RTErrConvertFromDarwin(irc);
     1927    }
     1928
     1929    return rc;
    19261930}
    19271931
  • trunk/src/VBox/Devices/USB/freebsd/USBProxyDevice-freebsd.cpp

    r50228 r50234  
    537537        LogFlow(("usbProxyFreeBSDSetInterface: Freeing kernel resources "
    538538                 "failed failed rc=%d\n", rc));
    539         return false;
     539        return rc;
    540540    }
    541541
     
    558558            LogFlow(("usbProxyFreeBSDSetConfig: configuration "
    559559                     "%d not found\n", iCfg));
    560             return false;
     560            return VERR_NOT_FOUND;
    561561        }
    562562    }
     
    565565    rc = usbProxyFreeBSDDoIoCtl(pProxyDev, USB_SET_CONFIG, &iCfgIndex, true);
    566566    if (RT_FAILURE(rc))
    567         return false;
     567        return rc;
    568568
    569569    /* Allocate kernel ressources again. */
    570     rc = usbProxyFreeBSDFsInit(pProxyDev);
    571     if (RT_FAILURE(rc))
    572         return false;
    573 
    574     return true;
     570    return usbProxyFreeBSDFsInit(pProxyDev);
    575571}
    576572
     
    590586     * failures
    591587     */
    592     rc = usbProxyFreeBSDDoIoCtl(pProxyDev, USB_IFACE_DRIVER_DETACH, &iIf, true);
     588    usbProxyFreeBSDDoIoCtl(pProxyDev, USB_IFACE_DRIVER_DETACH, &iIf, true);
    593589
    594590    /* Try to claim interface */
    595     rc = usbProxyFreeBSDDoIoCtl(pProxyDev, USB_CLAIM_INTERFACE, &iIf, true);
    596     if (RT_FAILURE(rc))
    597         return false;
    598 
    599     return true;
     591    return usbProxyFreeBSDDoIoCtl(pProxyDev, USB_CLAIM_INTERFACE, &iIf, true);
    600592}
    601593
     
    611603        "ifnum=%x\n", pProxyDev->pUsbIns->pszName, iIf));
    612604
    613     rc = usbProxyFreeBSDDoIoCtl(pProxyDev, USB_RELEASE_INTERFACE, &iIf, true);
    614     if (RT_FAILURE(rc))
    615         return false;
    616 
    617     return true;
     605    return usbProxyFreeBSDDoIoCtl(pProxyDev, USB_RELEASE_INTERFACE, &iIf, true);
    618606}
    619607
     
    623611 * @returns success indicator.
    624612 */
    625 static DECLCALLBACK(int)
    626 usbProxyFreeBSDSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt)
     613static DECLCALLBACK(int) usbProxyFreeBSDSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt)
    627614{
    628615    PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD);
     
    639626        LogFlow(("usbProxyFreeBSDSetInterface: Freeing kernel resources "
    640627                 "failed failed rc=%d\n", rc));
    641         return false;
     628        return rc;
    642629    }
    643630    memset(&UsbIntAlt, 0, sizeof(UsbIntAlt));
     
    650637        LogFlow(("usbProxyFreeBSDSetInterface: Setting interface %d %d "
    651638                 "failed rc=%d\n", iIf, iAlt, rc));
    652         return false;
    653     }
    654 
    655     rc = usbProxyFreeBSDFsInit(pProxyDev);
    656     if (RT_FAILURE(rc))
    657         return false;
    658 
    659     return true;
     639        return rc;
     640    }
     641
     642    return usbProxyFreeBSDFsInit(pProxyDev);
    660643}
    661644
     
    663646 * Clears the halted endpoint 'ep_num'.
    664647 */
    665 static DECLCALLBACK(bool) usbProxyFreeBSDClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep_num)
    666 {
    667     struct usb_ctl_request Req;
    668     int rc;
    669 
     648static DECLCALLBACK(int) usbProxyFreeBSDClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep_num)
     649{
    670650    LogFlow(("usbProxyFreeBSDClearHaltedEp: pProxyDev=%s ep_num=%u\n",
    671651             pProxyDev->pUsbIns->pszName, ep_num));
     
    676656     */
    677657    if ((ep_num & 0xF) == 0)
    678         return true;
    679 
     658        return VINF_SUCCESS;
     659
     660    struct usb_ctl_request Req;
    680661    memset(&Req, 0, sizeof(Req));
    681 
    682662    usbProxyFreeBSDSetupReq(&Req.ucr_request,
    683663                            VUSB_DIR_TO_DEV | VUSB_TO_ENDPOINT,
    684664                            VUSB_REQ_CLEAR_FEATURE, 0, ep_num, 0);
    685665
    686     rc = usbProxyFreeBSDDoIoCtl(pProxyDev, USB_DO_REQUEST, &Req, true);
     666    int rc = usbProxyFreeBSDDoIoCtl(pProxyDev, USB_DO_REQUEST, &Req, true);
    687667
    688668    LogFlow(("usbProxyFreeBSDClearHaltedEp: rc=%Rrc\n", rc));
    689 
    690     if (RT_FAILURE(rc))
    691         return false;
    692 
    693     return true;
     669    return rc;
    694670}
    695671
     
    727703
    728704    if (index < 0)
    729         return false;
     705        return VERR_INVALID_PARAMETER;
    730706
    731707    pEndpointFBSD = &pDevFBSD->aSwEndpoint[index];
     
    997973 * The URB requires reaping, so we don't change its state.
    998974 */
    999 static DECLCALLBACK(void) usbProxyFreeBSDUrbCancel(PVUSBURB pUrb)
    1000 {
    1001     PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);
     975static DECLCALLBACK(int) usbProxyFreeBSDUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
     976{
    1002977    int index;
    1003978
     
    1005980
    1006981    if (index < 0 || index >= USBFBSD_MAXENDPOINTS)
    1007         return;
     982        return VINF_SUCCESS; /* invalid index, pretend success. */
    1008983
    1009984    LogFlow(("usbProxyFreeBSDUrbCancel: epindex=%u\n", (unsigned)index));
    1010 
    1011     usbProxyFreeBSDEndpointClose(pProxyDev, index);
     985    return usbProxyFreeBSDEndpointClose(pProxyDev, index);
    1012986}
    1013987
  • trunk/src/VBox/Devices/USB/linux/USBProxyDevice-linux.cpp

    r50228 r50234  
    11261126    {
    11271127        Log(("usb-linux: Set configuration. errno=%d\n", errno));
    1128         return false;
    1129     }
    1130     return true;
     1128        return RTErrConvertFromErrno(errno);
     1129    }
     1130    return VINF_SUCCESS;
    11311131}
    11321132
     
    11441144    {
    11451145        Log(("usb-linux: Claim interface. errno=%d pProxyDev=%s\n", errno, usbProxyGetName(pProxyDev)));
    1146         return false;
    1147     }
    1148     return true;
     1146        return RTErrConvertFromErrno(errno);
     1147    }
     1148    return VINF_SUCCESS;
    11491149}
    11501150
     
    11611161    {
    11621162        Log(("usb-linux: Release interface, errno=%d. pProxyDev=%s\n", errno, usbProxyGetName(pProxyDev)));
    1163         return false;
    1164     }
    1165     return true;
     1163        return RTErrConvertFromErrno(errno);
     1164    }
     1165    return VINF_SUCCESS;
    11661166}
    11671167
     
    11821182    {
    11831183        Log(("usb-linux: Set interface, errno=%d. pProxyDev=%s\n", errno, usbProxyGetName(pProxyDev)));
    1184         return false;
    1185     }
    1186     return true;
     1184        return RTErrConvertFromErrno(errno);
     1185    }
     1186    return VINF_SUCCESS;
    11871187}
    11881188
     
    11911191 * Clears the halted endpoint 'EndPt'.
    11921192 */
    1193 static bool usbProxyLinuxClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)
     1193static int usbProxyLinuxClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)
    11941194{
    11951195    LogFlow(("usbProxyLinuxClearHaltedEp: pProxyDev=%s EndPt=%u\n", usbProxyGetName(pProxyDev), EndPt));
     
    12061206            Log(("usb-linux: clear_halted_ep failed errno=%d. pProxyDev=%s ep=%d - IGNORED\n",
    12071207                 errno, usbProxyGetName(pProxyDev), EndPt));
    1208             return true;
     1208            return VINF_SUCCESS;
    12091209        }
    12101210        Log(("usb-linux: clear_halted_ep failed errno=%d. pProxyDev=%s ep=%d\n",
    12111211             errno, usbProxyGetName(pProxyDev), EndPt));
    1212         return false;
    1213     }
    1214     return true;
     1212        return RTErrConvertFromErrno(errno);
     1213    }
     1214    return VINF_SUCCESS;
    12151215}
    12161216
     
    12771277 * retries
    12781278 *
    1279  * @returns true / false.
    1280  */
    1281 static bool usbProxyLinuxSubmitURB(PUSBPROXYDEV pProxyDev, PUSBPROXYURBLNX pCur, PVUSBURB pUrb, bool *pfUnplugged)
    1282 {
     1279 * @returns VBox status code.
     1280 */
     1281static int usbProxyLinuxSubmitURB(PUSBPROXYDEV pProxyDev, PUSBPROXYURBLNX pCur, PVUSBURB pUrb, bool *pfUnplugged)
     1282{
     1283    int rc = VINF_SUCCESS;
    12831284    PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX);
    12841285    unsigned        cTries = 0;
     
    12921293            Log(("usbProxyLinuxSubmitURB: ENODEV -> unplugged. pProxyDev=%s\n", usbProxyGetName(pProxyDev)));
    12931294            *pfUnplugged = true;
    1294             return false;
     1295            return RTErrConvertFromErrno(errno);
    12951296        }
    12961297
     
    13021303            continue;
    13031304        }
    1304         return false;
    1305     }
    1306     return true;
     1305        return RTErrConvertFromErrno(errno);
     1306    }
     1307    return VINF_SUCCESS;
    13071308}
    13081309
     
    13531354 * URB at a time -> worse performance but correct behaviour.
    13541355 *
    1355  * @returns true / false.
     1356 * @returns VBox status code.
    13561357 * @param   pProxyDev   The proxy device.
    13571358 * @param   pUrbLnx     The linux URB which was rejected because of being too big.
     
    13791380            AssertMsgFailed(("We can't split isochronous URBs!\n"));
    13801381            usbProxyLinuxUrbFree(pProxyDev, pUrbLnx);
    1381             return false;
     1382            return VERR_INVALID_PARAMETER; /** @todo: Better status code. */
    13821383    }
    13831384    pUrbLnx->KUrb.endpoint          = pUrb->EndPt;
     
    14021403    pUrbLnx->cbSplitRemaining = cbLeft;
    14031404
    1404     bool fSucceeded = false;
     1405    int rc = VINF_SUCCESS;
    14051406    bool fUnplugged = false;
    14061407    if (pUrb->enmDir == VUSBDIRECTION_IN && !pUrb->fShortNotOk)
     
    14091410         * and only if necessary.
    14101411         */
    1411         fSucceeded = true;
    14121412        Log(("usb-linux: Large ShortOK read, only queuing first fragment.\n"));
    14131413        Assert(pUrbLnx->cbSplitRemaining > 0 && pUrbLnx->cbSplitRemaining < 256 * _1K);
    1414         fSucceeded = usbProxyLinuxSubmitURB(pProxyDev, pUrbLnx, pUrb, &fUnplugged);
     1414        rc = usbProxyLinuxSubmitURB(pProxyDev, pUrbLnx, pUrb, &fUnplugged);
    14151415    }
    14161416    else
     
    14221422            pCur = usbProxyLinuxSplitURBFragment(pProxyDev, pUrbLnx, pCur);
    14231423            if (!pCur)
    1424             {
    1425                 return false;
    1426             }
     1424                return VERR_NO_MEMORY;
    14271425        }
    14281426        Assert(pCur->cbSplitRemaining == 0);
     
    14321430        for (i = 0; i < cKUrbs; i++, pCur = pCur->pSplitNext)
    14331431        {
    1434             fSucceeded = usbProxyLinuxSubmitURB(pProxyDev, pCur, pUrb, &fUnplugged);
    1435             if (!fSucceeded)
     1432            rc = usbProxyLinuxSubmitURB(pProxyDev, pCur, pUrb, &fUnplugged);
     1433            if (RT_FAILURE(rc))
    14361434                break;
    14371435        }
    14381436    }
    14391437
    1440     if (fSucceeded)
     1438    if (RT_SUCCESS(rc))
    14411439    {
    14421440        pUrb->Dev.pvPrivate = pUrbLnx;
    14431441        LogFlow(("usbProxyLinuxUrbQueueSplit: ok\n"));
    1444         return true;
     1442        return VINF_SUCCESS;
    14451443    }
    14461444
    14471445    usbProxyLinuxCleanupFailedSubmit(pProxyDev, pUrbLnx, pCur, pUrb, &fUnplugged);
    1448     return false;
     1446    return rc;
    14491447}
    14501448
     
    14531451 * @copydoc USBPROXYBACK::pfnUrbQueue
    14541452 */
    1455 static DECLCALLBACK(int) usbProxyLinuxUrbQueue(PVUSBURB pUrb)
    1456 {
     1453static DECLCALLBACK(int) usbProxyLinuxUrbQueue(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
     1454{
     1455    int             rc = VINF_SUCCESS;
    14571456    unsigned        cTries;
    1458 #ifndef RDESKTOP
    1459     PUSBPROXYDEV    pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);
    1460 #else
    1461     PUSBPROXYDEV    pProxyDev = usbProxyFromVusbDev(pUrb->pDev);
    1462 #endif
    14631457    PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX);
    14641458    LogFlow(("usbProxyLinuxUrbQueue: pProxyDev=%s pUrb=%p EndPt=%d cbData=%d\n",
     
    14701464    PUSBPROXYURBLNX pUrbLnx = usbProxyLinuxUrbAlloc(pProxyDev, NULL);
    14711465    if (!pUrbLnx)
    1472         return false;
     1466        return VERR_NO_MEMORY;
    14731467
    14741468    pUrbLnx->KUrb.endpoint          = pUrb->EndPt | (pUrb->enmDir == VUSBDIRECTION_IN ? 0x80 : 0);
     
    14911485            {
    14921486                usbProxyLinuxUrbFree(pProxyDev, pUrbLnx);
    1493                 return false;
     1487                return VERR_BUFFER_UNDERFLOW;
    14941488            }
    14951489            usbProxyLinuxUrbSwapSetup((PVUSBSETUP)pUrb->abData);
     
    15151509            break;
    15161510        default:
    1517             goto l_err;
     1511            rc = VERR_INVALID_PARAMETER; /** @todo: better status code. */
    15181512    }
    15191513
     
    15341528
    15351529            usbProxLinuxUrbUnplugged(pProxyDev);
    1536             return false;
     1530            return RTErrConvertFromErrno(errno);
    15371531        }
    15381532
     
    15531547        if (errno != EBUSY && ++cTries < 3) /* this doesn't work for the floppy :/ */
    15541548            continue;
     1549
     1550        rc = RTErrConvertFromErrno(errno);
     1551
    15551552l_err:
    15561553        if (pUrb->enmType == VUSBXFERTYPE_MSG)
    15571554            usbProxyLinuxUrbSwapSetup((PVUSBSETUP)pUrb->abData);
    15581555        usbProxyLinuxUrbFree(pProxyDev, pUrbLnx);
    1559         return false;
     1556        return rc;
    15601557    }
    15611558    pUrbLnx->u64SubmitTS = RTTimeMilliTS();
     
    15631560    LogFlow(("usbProxyLinuxUrbQueue: ok\n"));
    15641561    pUrb->Dev.pvPrivate = pUrbLnx;
    1565     return true;
     1562    return rc;
    15661563}
    15671564
     
    19511948 * The URB requires reaping, so we don't change its state.
    19521949 */
    1953 static DECLCALLBACK(void) usbProxyLinuxUrbCancel(PVUSBURB pUrb)
    1954 {
    1955 #ifndef RDESKTOP
    1956     PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);
    1957 #else
    1958     PUSBPROXYDEV pProxyDev = usbProxyFromVusbDev(pUrb->pDev);
    1959 #endif
     1950static DECLCALLBACK(int) usbProxyLinuxUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
     1951{
     1952    int rc = VINF_SUCCESS;
    19601953    PUSBPROXYURBLNX pUrbLnx = (PUSBPROXYURBLNX)pUrb->Dev.pvPrivate;
    19611954    if (pUrbLnx->pSplitHead)
     
    19731966            if (errno == ENODEV)
    19741967                break;
     1968            /** @todo: Think about how to handle errors wrt. to the status code. */
    19751969            Log(("usb-linux: Discard URB %p failed, errno=%d. pProxyDev=%s!!! (split)\n",
    19761970                 pUrb, errno, usbProxyGetName(pProxyDev)));
     
    19831977            &&  errno != ENODEV /* deal with elsewhere. */
    19841978            &&  errno != ENOENT)
     1979        {
    19851980            Log(("usb-linux: Discard URB %p failed, errno=%d. pProxyDev=%s!!!\n",
    19861981                 pUrb, errno, usbProxyGetName(pProxyDev)));
    1987     }
     1982            rc = RTErrConvertFromErrno(errno);
     1983        }
     1984    }
     1985
     1986    return rc;
    19881987}
    19891988
  • trunk/src/VBox/Devices/USB/solaris/USBProxyDevice-solaris.cpp

    r50232 r50234  
    494494    SetConfigReq.bConfigValue = iCfg;
    495495    int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_SET_CONFIG, &SetConfigReq, sizeof(SetConfigReq));
    496     if (RT_SUCCESS(rc))
    497         return true;
    498 
    499     if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
     496    if (   RT_FAILURE(rc)
     497        && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    500498        LogRel((USBPROXY ":usbProxySolarisSetConfig failed to switch configuration. rc=%Rrc\n", rc));
    501499
    502     return false;
     500    return rc;
    503501}
    504502
     
    514512static DECLCALLBACK(int) usbProxySolarisClaimInterface(PUSBPROXYDEV pProxyDev, int iIf)
    515513{
    516     return true;
     514    return VINF_SUCCESS;
    517515}
    518516
     
    528526static DECLCALLBACK(int) usbProxySolarisReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf)
    529527{
    530     return true;
     528    return VINF_SUCCESS;
    531529}
    532530
     
    548546    SetInterfaceReq.bAlternate = iAlt;
    549547    int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_SET_INTERFACE, &SetInterfaceReq, sizeof(SetInterfaceReq));
    550     if (RT_SUCCESS(rc))
    551         return true;
    552 
    553     if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
     548    if (   RT_FAILURE(rc)
     549        && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    554550        LogRel((USBPROXY ":usbProxySolarisSetInterface failed to set interface. rc=%Rrc\n", rc));
    555551
    556     return false;
     552    return rc;
    557553}
    558554
     
    561557 * Clears the halted endpoint 'EndPt'.
    562558 */
    563 static DECLCALLBACK(bool) usbProxySolarisClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)
     559static DECLCALLBACK(int) usbProxySolarisClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)
    564560{
    565561    LogFlowFunc((USBPROXY ":usbProxySolarisClearHaltedEp pProxyDev=%p EndPt=%#x\n", pProxyDev, EndPt));
     
    571567    ClearEpReq.bEndpoint = EndPt;
    572568    int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_CLEAR_EP, &ClearEpReq, sizeof(ClearEpReq));
    573     if (RT_SUCCESS(rc))
    574         return true;
    575 
    576     if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
     569    if (   RT_FAILURE(rc)
     570        && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    577571        LogRel((USBPROXY ":usbProxySolarisClearHaltedEp failed! rc=%Rrc\n", rc));
    578572
    579     return false;
     573    return rc;
    580574}
    581575
     
    596590    {
    597591        LogRel((USBPROXY ":usbProxySolarisUrbQueue: Failed to allocate URB.\n"));
    598         return false;
     592        return VERR_NO_MEMORY;
    599593    }
    600594
     
    632626            LogFlow((USBPROXY ":usbProxySolarisUrbQueue success cbData=%d.\n", pUrb->cbData));
    633627        pUrb->Dev.pvPrivate = pUrbSol;
    634         return true;
     628        return VINF_SUCCESS;
    635629    }
    636630
     
    639633             pProxyDev->pUsbIns->pszName, pUrb, pUrb->EndPt, UrbReq.bEndpoint, pUrb->enmType, pUrb->enmDir, pUrb->cbData, rc));
    640634
    641     return false;
     635    return rc;
    642636}
    643637
     
    650644 *          on Solaris. So we just abort pending URBs on the pipe.
    651645 */
    652 static DECLCALLBACK(void) usbProxySolarisUrbCancel(PVUSBURB pUrb)
     646static DECLCALLBACK(int) usbProxySolarisUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
    653647{
    654648    PUSBPROXYURBSOL pUrbSol = (PUSBPROXYURBSOL)pUrb->Dev.pvPrivate;
    655 
    656     PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);
    657649    PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
    658650    AssertPtrReturnVoid(pDevSol);
     
    662654    /* Aborting the control pipe isn't supported, pretend success. */
    663655    if (!pUrb->EndPt)
    664         return;
     656        return VINF_SUCCESS;
    665657
    666658    VBOXUSBREQ_ABORT_PIPE AbortPipeReq;
    667659    AbortPipeReq.bEndpoint = pUrb->EndPt | (pUrb->enmDir == VUSBDIRECTION_IN ? VUSB_DIR_TO_HOST : VUSB_DIR_TO_DEVICE);
    668660    int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_ABORT_PIPE, &AbortPipeReq, sizeof(AbortPipeReq));
    669     if (RT_FAILURE(rc))
    670     {
    671         if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
    672             LogRel((USBPROXY ":usbProxySolarisUrbCancel failed to abort pipe. rc=%Rrc\n", rc));
    673         return;
    674     }
    675 
    676     LogFlow((USBPROXY ":usbProxySolarisUrbCancel success.\n", rc));
     661    if (   RT_FAILURE(rc)
     662        && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
     663        LogRel((USBPROXY ":usbProxySolarisUrbCancel failed to abort pipe. rc=%Rrc\n", rc));
     664
     665    LogFlow((USBPROXY ":usbProxySolarisUrbCancel: rc=%Rrc.\n", rc));
     666    return rc;
    677667}
    678668
  • trunk/src/VBox/Devices/USB/vrdp/USBProxyDevice-vrdp.cpp

    r50228 r50234  
    118118    }
    119119
    120     return RT_SUCCESS(rc);
     120    return rc;
    121121}
    122122
     
    135135    }
    136136
    137     return RT_SUCCESS(rc);
     137    return rc;
    138138}
    139139
     
    152152    }
    153153
    154     return RT_SUCCESS(rc);
     154    return rc;
    155155}
    156156
     
    169169    }
    170170
    171     return RT_SUCCESS(rc);
    172 }
    173 
    174 static DECLCALLBACK(bool) usbProxyVrdpClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep)
     171    return rc;
     172}
     173
     174static DECLCALLBACK(int) usbProxyVrdpClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep)
    175175{
    176176    LogFlow(("usbProxyVrdpClearHaltedEp: pProxyDev=%s ep=%u\n", pProxyDev->pUsbIns->pszName, ep));
     
    186186    }
    187187
    188     return RT_SUCCESS(rc);
    189 }
    190 
    191 static DECLCALLBACK(int) usbProxyVrdpUrbQueue(PVUSBURB pUrb)
     188    return rc;
     189}
     190
     191static DECLCALLBACK(int) usbProxyVrdpUrbQueue(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
    192192{
    193193    LogFlow(("usbProxyVrdpUrbQueue: pUrb=%p\n", pUrb));
     
    197197    {
    198198        Log(("usbproxy: isochronous transfers aren't implemented yet.\n"));
    199         return false;
    200     }
    201 
    202     PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);
    203     PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP);
    204 
     199        return VERR_NOT_IMPLEMENTED;
     200    }
     201
     202    PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP);
    205203    int rc = pDevVrdp->pCallback->pfnQueueURB (pDevVrdp->pDevice, pUrb->enmType, pUrb->EndPt, pUrb->enmDir, pUrb->cbData,
    206204                                               pUrb->abData, pUrb, (PREMOTEUSBQURB *)&pUrb->Dev.pvPrivate);
     
    212210    }
    213211
    214     return RT_SUCCESS(rc);
     212    return rc;
    215213}
    216214
     
    245243}
    246244
    247 static DECLCALLBACK(void) usbProxyVrdpUrbCancel(PVUSBURB pUrb)
     245static DECLCALLBACK(int) usbProxyVrdpUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
    248246{
    249247    LogFlow(("usbProxyVrdpUrbCancel: pUrb=%p\n", pUrb));
    250248
    251     PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);
    252     PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP);
    253 
     249    PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP);
    254250    pDevVrdp->pCallback->pfnCancelURB (pDevVrdp->pDevice, (PREMOTEUSBQURB)pUrb->Dev.pvPrivate);
     251    return VINF_SUCCESS; /** @todo: Enhance remote interface to pass a status code. */
    255252}
    256253
     
    260257
    261258    PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP);
    262 
    263259    return pDevVrdp->pCallback->pfnWakeup (pDevVrdp->pDevice);
    264260}
  • trunk/src/VBox/Devices/USB/win/USBProxyDevice-win.cpp

    r50233 r50234  
    8383*******************************************************************************/
    8484static int usbProxyWinSetInterface(PUSBPROXYDEV p, int ifnum, int setting);
    85 static DECLCALLBACK(int) usbProxyWinAsyncIoThread(RTTHREAD ThreadSelf, void *lpParameter);
     85
     86/**
     87 * Converts the given Windows error code to VBox handling unplugged devices.
     88 *
     89 * @returns VBox status code.
     90 * @param   pProxDev    The USB proxy device instance.
     91 * @param   dwErr       Windows error code.
     92 */
     93static int usbProxyWinHandleUnpluggedDevice(PUSBPROXYDEV pProxyDev, DWORD dwErr)
     94{
     95    PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32);
     96
     97    if (   dwErr == ERROR_INVALID_HANDLE_STATE
     98        || dwErr == ERROR_BAD_COMMAND)
     99    {
     100        Log(("usbproxy: device %x unplugged!!\n", pPriv->hDev));
     101        pProxyDev->fDetached = true;
     102    }
     103    else
     104        AssertMsgFailed(("lasterr=%d\n", dwErr));
     105    return RTErrConvertFromWin32(dwErr);
     106}
    86107
    87108/**
     
    279300    cbReturned = 0;
    280301    if (DeviceIoControl(pPriv->hDev, SUPUSB_IOCTL_USB_SET_CONFIG, &in, sizeof(in), NULL, 0, &cbReturned, NULL))
    281         return 1;
    282 
    283     if (   GetLastError() == ERROR_INVALID_HANDLE_STATE
    284         || GetLastError() == ERROR_BAD_COMMAND)
    285     {
    286         Log(("usbproxy: device %p unplugged!!\n", pPriv->hDev));
    287         pProxyDev->fDetached = true;
    288     }
    289     else
    290         AssertMsgFailed(("lasterr=%u\n", GetLastError()));
    291 
    292     return 0;
     302        return VINF_SUCCESS;
     303
     304    return usbProxyWinHandleUnpluggedDevice(pProxyDev, GetLastError());
    293305}
    294306
     
    305317
    306318    Assert(pPriv);
    307     return true;
     319    return VINF_SUCCESS;
    308320}
    309321
     
    314326
    315327    Assert(pPriv);
    316     return true;
     328    return VINF_SUCCESS;
    317329}
    318330
     
    336348    cbReturned = 0;
    337349    if (DeviceIoControl(pPriv->hDev, SUPUSB_IOCTL_USB_SELECT_INTERFACE, &in, sizeof(in), NULL, 0, &cbReturned, NULL))
    338         return true;
    339 
    340     if (    GetLastError() == ERROR_INVALID_HANDLE_STATE
    341         ||  GetLastError() == ERROR_BAD_COMMAND)
    342     {
    343         Log(("usbproxy: device %x unplugged!!\n", pPriv->hDev));
    344         pProxyDev->fDetached = true;
    345     }
    346     else
    347         AssertMsgFailed(("lasterr=%d\n", GetLastError()));
    348     return 0;
     350        return VINF_SUCCESS;
     351
     352    return usbProxyWinHandleUnpluggedDevice(pProxyDev, GetLastError());
    349353}
    350354
     
    352356 * Clears the halted endpoint 'ep'.
    353357 */
    354 static DECLCALLBACK(bool) usbProxyWinClearHaltedEndPt(PUSBPROXYDEV pProxyDev, unsigned int ep)
     358static DECLCALLBACK(int) usbProxyWinClearHaltedEndPt(PUSBPROXYDEV pProxyDev, unsigned int ep)
    355359{
    356360    PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32);
     
    365369    cbReturned = 0;
    366370    if (DeviceIoControl(pPriv->hDev, SUPUSB_IOCTL_USB_CLEAR_ENDPOINT, &in, sizeof(in), NULL, 0, &cbReturned, NULL))
    367         return true;
    368 
    369     if (    GetLastError() == ERROR_INVALID_HANDLE_STATE
    370         ||  GetLastError() == ERROR_BAD_COMMAND)
    371     {
    372         Log(("usbproxy: device %x unplugged!!\n", pPriv->hDev));
    373         pProxyDev->fDetached = true;
    374     }
    375     else
    376         AssertMsgFailed(("lasterr=%d\n", GetLastError()));
    377     return 0;
     371        return VINF_SUCCESS;
     372
     373    return usbProxyWinHandleUnpluggedDevice(pProxyDev, GetLastError());
    378374}
    379375
     
    397393        return VINF_SUCCESS;
    398394
    399     rc = GetLastError();
    400     if (    rc == ERROR_INVALID_HANDLE_STATE
    401         ||  rc == ERROR_BAD_COMMAND)
    402     {
    403         Log(("usbproxy: device %x unplugged!!\n", pPriv->hDev));
    404         pProxyDev->fDetached = true;
    405     }
    406     else
    407         AssertMsgFailed(("lasterr=%d\n", rc));
    408     return RTErrConvertFromWin32(rc);
     395    return usbProxyWinHandleUnpluggedDevice(pProxyDev, GetLastError());
    409396}
    410397
     
    412399 * @copydoc USBPROXYBACK::pfnUrbQueue
    413400 */
    414 static DECLCALLBACK(int) usbProxyWinUrbQueue(PVUSBURB pUrb)
    415 {
    416     PUSBPROXYDEV    pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);
     401static DECLCALLBACK(int) usbProxyWinUrbQueue(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
     402{
    417403    PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32);
    418404    Assert(pPriv);
     
    424410    PQUEUED_URB pQUrbWin = (PQUEUED_URB)RTMemAllocZ(sizeof(QUEUED_URB));
    425411    if (!pQUrbWin)
    426         return false;
     412        return VERR_NO_MEMORY;
    427413
    428414    switch (pUrb->enmType)
     
    443429        default:
    444430            AssertMsgFailed(("Invalid type %d\n", pUrb->enmType));
    445             return false;
     431            return VERR_INVALID_PARAMETER;
    446432    }
    447433
     
    460446        default:
    461447            AssertMsgFailed(("Invalid direction %d\n", pUrb->enmDir));
    462             return false;
     448            return VERR_INVALID_PARAMETER;
    463449    }
    464450
     
    474460        pQUrbWin->urbwin.flags = USBSUP_FLAG_SHORT_OK;
    475461
     462    int rc = VINF_SUCCESS;
    476463    pQUrbWin->overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    477464    if (pQUrbWin->overlapped.hEvent != INVALID_HANDLE_VALUE)
     
    492479            RTCritSectLeave(&pPriv->CritSect);
    493480            SetEvent(pPriv->hEventWakeup);
    494             return true;
     481            return VINF_SUCCESS;
    495482        }
    496483        else
     
    500487                || dwErr == ERROR_BAD_COMMAND)
    501488            {
    502                 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pQUrbWin->urb->pUsbIns, PUSBPROXYDEV);
    503489                Log(("usbproxy: device %p unplugged!!\n", pPriv->hDev));
    504490                pProxyDev->fDetached = true;
     
    506492            else
    507493                AssertMsgFailed(("dwErr=%X urbwin.error=%d (submit urb)\n", dwErr, pQUrbWin->urbwin.error));
     494            rc = RTErrConvertFromWin32(dwErr);
    508495            CloseHandle(pQUrbWin->overlapped.hEvent);
    509496            pQUrbWin->overlapped.hEvent = INVALID_HANDLE_VALUE;
     
    514501    {
    515502        AssertMsgFailed(("FAILED!!, hEvent(0x%p)\n", pQUrbWin->overlapped.hEvent));
     503        rc = VERR_NO_MEMORY;
    516504    }
    517505#endif
     
    519507    Assert(pQUrbWin->overlapped.hEvent == INVALID_HANDLE_VALUE);
    520508    RTMemFree(pQUrbWin);
    521     return false;
     509    return rc;
    522510}
    523511
     
    587575        RTCritSectEnter(&pPriv->CritSect);
    588576
    589         /* Ensure we've got sufficient space in the arrays.
    590          * Do it inside the lock to ensure we do not concur
    591          * with the usbProxyWinAsyncIoThread */
     577        /* Ensure we've got sufficient space in the arrays. */
    592578        if (pPriv->cQueuedUrbs + pPriv->cPendingUrbs + 1 > pPriv->cAllocatedUrbs)
    593579        {
     
    719705 *          exactly what the guest wants to do.
    720706 */
    721 static DECLCALLBACK(void) usbProxyWinUrbCancel(PVUSBURB pUrb)
    722 {
    723     PUSBPROXYDEV      pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);
     707static DECLCALLBACK(int) usbProxyWinUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
     708{
    724709    PPRIV_USBW32      pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32);
    725710    PQUEUED_URB       pQUrbWin  = (PQUEUED_URB)pUrb->Dev.pvPrivate;
    726     int                     rc;
    727711    USBSUP_CLEAR_ENDPOINT   in;
    728712    DWORD                   cbReturned;
    729     Assert(pQUrbWin);
     713
     714    AssertPtrReturn(pQUrbWin, VERR_INVALID_PARAMETER);
    730715
    731716    in.bEndpoint = pUrb->EndPt | (pUrb->enmDir == VUSBDIRECTION_IN ? 0x80 : 0);
     
    734719    cbReturned = 0;
    735720    if (DeviceIoControl(pPriv->hDev, SUPUSB_IOCTL_USB_ABORT_ENDPOINT, &in, sizeof(in), NULL, 0, &cbReturned, NULL))
    736         return;
    737 
    738     rc = GetLastError();
    739     if (    rc == ERROR_INVALID_HANDLE_STATE
    740         ||  rc == ERROR_BAD_COMMAND)
     721        return VINF_SUCCESS;
     722
     723    DWORD dwErr = GetLastError();
     724    if (    dwErr == ERROR_INVALID_HANDLE_STATE
     725        ||  dwErr == ERROR_BAD_COMMAND)
    741726    {
    742727        Log(("usbproxy: device %x unplugged!!\n", pPriv->hDev));
    743728        pProxyDev->fDetached = true;
     729        return VINF_SUCCESS; /* Fake success and deal with the unplugged device elsewhere. */
    744730    }
    745731    else
  • trunk/src/VBox/RDP/client/vrdp/rdpusb.c

    r50228 r50234  
    133133}
    134134
    135 static inline int op_usbproxy_back_queue_urb(PVUSBURB pUrb)
    136 {
    137     return g_USBProxyDeviceHost.pfnUrbQueue(pUrb);
     135static inline int op_usbproxy_back_queue_urb(PUSBPROXYDEV pDev, PVUSBURB pUrb)
     136{
     137    return g_USBProxyDeviceHost.pfnUrbQueue(pDev, pUrb);
    138138}
    139139
     
    148148}
    149149
    150 static inline void op_usbproxy_back_cancel_urb(PVUSBURB pUrb)
    151 {
    152     return g_USBProxyDeviceHost.pfnUrbCancel (pUrb);
     150static inline int op_usbproxy_back_cancel_urb(PUSBPROXYDEV pDev, PVUSBURB pUrb)
     151{
     152    return g_USBProxyDeviceHost.pfnUrbCancel (pDev, pUrb);
    153153}
    154154
     
    699699                        }
    700700
    701                         rc = op_usbproxy_back_queue_urb(pUrb);
     701                        rc = op_usbproxy_back_queue_urb(proxy, pUrb);
    702702
    703703                        /* No reply required. */
     
    772772                        if (pUrb)
    773773                        {
    774                                 op_usbproxy_back_cancel_urb(pUrb);
     774                                op_usbproxy_back_cancel_urb(proxy, pUrb);
    775775
    776776                                /* No reply required. */
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