- Timestamp:
- Jan 24, 2014 10:48:13 PM (11 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/USBProxyDevice.cpp
r50229 r50234 53 53 * Setup a MSG URB, queue and reap it. 54 54 */ 55 int rc = VINF_SUCCESS; 55 56 VUSBURB Urb; 56 57 AssertCompile(RT_SIZEOFMEMB(VUSBURB, abData) >= _4K); … … 79 80 pSetup->wLength = cbHint; 80 81 81 if (!pProxyDev->pOps->pfnUrbQueue(&Urb)) 82 rc = pProxyDev->pOps->pfnUrbQueue(pProxyDev, &Urb); 83 if (RT_FAILURE(rc)) 82 84 break; 83 85 … … 89 91 if (!pUrbReaped) 90 92 { 91 pProxyDev->pOps->pfnUrbCancel(&Urb); 93 rc = pProxyDev->pOps->pfnUrbCancel(pProxyDev, &Urb); 94 AssertRC(rc); 95 /** @todo: This breaks the comment above... */ 92 96 pUrbReaped = pProxyDev->pOps->pfnUrbReap(pProxyDev, RT_INDEFINITE_WAIT); 93 97 } … … 629 633 pUsbIns->pszName, bInterfaceNumber, bAlternateSetting)); 630 634 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); 635 636 } 636 637 … … 647 648 pUsbIns->pszName, uEndpoint)); 648 649 649 if (!pProxyDev->pOps->pfnClearHaltedEndpoint(pProxyDev, uEndpoint)) 650 return VERR_GENERAL_FAILURE; 651 return VINF_SUCCESS; 650 return pProxyDev->pOps->pfnClearHaltedEndpoint(pProxyDev, uEndpoint); 652 651 } 653 652 … … 660 659 static DECLCALLBACK(int) usbProxyDevUrbQueue(PPDMUSBINS pUsbIns, PVUSBURB pUrb) 661 660 { 661 int rc = VINF_SUCCESS; 662 662 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)) 664 665 return pProxyDev->fDetached 665 666 ? VERR_VUSB_DEVICE_NOT_ATTACHED 666 667 : VERR_VUSB_FAILED_TO_QUEUE_URB; 667 return VINF_SUCCESS;668 return rc; 668 669 } 669 670 … … 677 678 { 678 679 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUsbIns, PUSBPROXYDEV); 679 pProxyDev->pOps->pfnUrbCancel(pUrb); 680 return VINF_SUCCESS; 680 return pProxyDev->pOps->pfnUrbCancel(pProxyDev, pUrb); 681 681 } 682 682 -
trunk/src/VBox/Devices/USB/USBProxyDevice.h
r50229 r50234 25 25 26 26 27 /**28 * Arguments passed to the USB proxy device constructor.29 */30 typedef struct USBPROXYDEVARGS31 {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 43 27 /** Pointer to a USB proxy device. */ 44 28 typedef struct USBPROXYDEV *PUSBPROXYDEV; … … 73 57 * 74 58 * @returns VBox status code. 75 * @param pProxyDev The USB Proxy Device instance.59 * @param pProxyDev The USB Proxy Device instance. 76 60 */ 77 61 DECLR3CALLBACKMEMBER(int, pfnInit, (PUSBPROXYDEV pProxyDev)); … … 80 64 * Closes handle to the host USB device. 81 65 * 82 * @param p DevThe USB Proxy Device instance.66 * @param pProxyDev The USB Proxy Device instance. 83 67 */ 84 68 DECLR3CALLBACKMEMBER(void, pfnClose, (PUSBPROXYDEV pProxyDev)); … … 90 74 * 91 75 * @returns VBox status code. 92 * @param p Dev The device to reset.76 * @param pProxyDev The USB Proxy Device instance. 93 77 * @param fResetOnLinux It's safe to do reset on linux, we can deal with devices 94 78 * being logically reconnected. … … 96 80 DECLR3CALLBACKMEMBER(int, pfnReset, (PUSBPROXYDEV pProxyDev, bool fResetOnLinux)); 97 81 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 */ 99 89 DECLR3CALLBACKMEMBER(int, pfnSetConfig, (PUSBPROXYDEV pProxyDev, int iCfg)); 100 90 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 */ 102 98 DECLR3CALLBACKMEMBER(int, pfnClaimInterface, (PUSBPROXYDEV pProxyDev, int iIf)); 103 99 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 */ 105 107 DECLR3CALLBACKMEMBER(int, pfnReleaseInterface, (PUSBPROXYDEV pProxyDev, int iIf)); 106 108 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)); 115 136 116 137 /** 117 138 * Cancel an in-flight URB. 118 139 * 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)); 123 145 124 146 /** … … 127 149 * @returns Pointer to a completed URB. 128 150 * @returns NULL if no URB was completed. 129 * @param p Dev The device.130 * @param cMillies Number of milliseconds to wait. Use 0 to not131 * 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. 132 154 */ 133 155 DECLR3CALLBACKMEMBER(PVUSBURB, pfnUrbReap, (PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)); … … 137 159 * 138 160 * @returns VBox status code. 139 * @param pProxyDev The device.161 * @param pProxyDev The USB Proxy Device instance. 140 162 */ 141 163 DECLR3CALLBACKMEMBER(int, pfnWakeup, (PUSBPROXYDEV pProxyDev)); -
trunk/src/VBox/Devices/USB/darwin/USBProxyDevice-darwin.cpp
r50231 r50234 1482 1482 { 1483 1483 Log(("usbProxyDarwinSetConfig: Set configuration -> %#x\n", irc)); 1484 return false;1484 return RTErrConvertFromDarwin(irc); 1485 1485 } 1486 1486 1487 1487 usbProxyDarwinReleaseAllInterfaces(pDevOsX); 1488 1488 usbProxyDarwinSeizeAllInterfaces(pDevOsX, true /* make the best out of it */); 1489 return true;1489 return VINF_SUCCESS; 1490 1490 } 1491 1491 … … 1497 1497 * open/reset/setconfig time. 1498 1498 * 1499 * @returns success indicator (always true).1499 * @returns success indicator (always VINF_SUCCESS). 1500 1500 */ 1501 1501 static DECLCALLBACK(int) usbProxyDarwinClaimInterface(PUSBPROXYDEV pProxyDev, int iIf) 1502 1502 { 1503 return true;1503 return VINF_SUCCESS; 1504 1504 } 1505 1505 … … 1515 1515 static DECLCALLBACK(int) usbProxyDarwinReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf) 1516 1516 { 1517 return true;1517 return VINF_SUCCESS; 1518 1518 } 1519 1519 … … 1540 1540 { 1541 1541 usbProxyDarwinGetPipeProperties(pDevOsX, pIf); 1542 return true;1542 return VINF_SUCCESS; 1543 1543 } 1544 1544 } … … 1558 1558 irc = (*pDevOsX->ppDevI)->DeviceRequest(pDevOsX->ppDevI, &Req); 1559 1559 Log(("usbProxyDarwinSetInterface: SET_INTERFACE(%d,%d) -> irc=%#x\n", iIf, iAlt, irc)); 1560 return true;1560 return VINF_SUCCESS; 1561 1561 } 1562 1562 } … … 1564 1564 LogFlow(("usbProxyDarwinSetInterface: pProxyDev=%s eiIf=%#x iAlt=%#x - failure - pIf=%p irc=%#x\n", 1565 1565 pProxyDev->pUsbIns->pszName, iIf, iAlt, pIf, irc)); 1566 return false;1566 return RTErrConvertFromDarwin(irc); 1567 1567 } 1568 1568 … … 1571 1571 * Clears the halted endpoint 'EndPt'. 1572 1572 */ 1573 static DECLCALLBACK( bool) usbProxyDarwinClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)1573 static DECLCALLBACK(int) usbProxyDarwinClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt) 1574 1574 { 1575 1575 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); … … 1581 1581 */ 1582 1582 if (EndPt == 0) 1583 return true;1583 return VINF_SUCCESS; 1584 1584 1585 1585 /* … … 1595 1595 irc = (*pIf->ppIfI)->ClearPipeStallBothEnds(pIf->ppIfI, u8PipeRef); 1596 1596 if (irc == kIOReturnSuccess) 1597 return true;1597 return VINF_SUCCESS; 1598 1598 AssertMsg(irc == kIOReturnNoDevice || irc == kIOReturnNotResponding, ("irc=#x (control pipe?)\n", irc)); 1599 1599 } … … 1601 1601 LogFlow(("usbProxyDarwinClearHaltedEp: pProxyDev=%s EndPt=%#x - failure - pIf=%p irc=%#x\n", 1602 1602 pProxyDev->pUsbIns->pszName, EndPt, pIf, irc)); 1603 return false;1603 return RTErrConvertFromDarwin(irc); 1604 1604 } 1605 1605 … … 1608 1608 * @copydoc USBPROXYBACK::pfnUrbQueue 1609 1609 */ 1610 static DECLCALLBACK(int) usbProxyDarwinUrbQueue(PVUSBURB pUrb) 1611 { 1612 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 1610 static DECLCALLBACK(int) usbProxyDarwinUrbQueue(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb) 1611 { 1613 1612 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1614 1613 LogFlow(("%s: usbProxyDarwinUrbQueue: pProxyDev=%s pUrb=%p EndPt=%d cbData=%d\n", … … 1629 1628 LogFlow(("%s: usbProxyDarwinUrbQueue: pProxyDev=%s EndPt=%d cbData=%d - can't find interface / pipe!!!\n", 1630 1629 pUrb->pszDesc, pProxyDev->pUsbIns->pszName, pUrb->EndPt, pUrb->cbData)); 1631 return false;1630 return VERR_NOT_FOUND; 1632 1631 } 1633 1632 … … 1646 1645 PUSBPROXYURBOSX pUrbOsX = usbProxyDarwinUrbAlloc(pDevOsX); 1647 1646 if (!pUrbOsX) 1648 return false;1647 return VERR_NO_MEMORY; 1649 1648 1650 1649 pUrbOsX->u64SubmitTS = RTTimeMilliTS(); … … 1795 1794 { 1796 1795 Log(("%s: usbProxyDarwinUrbQueue: success\n", pUrb->pszDesc)); 1797 return true;1796 return VINF_SUCCESS; 1798 1797 } 1799 1798 switch (irc) … … 1804 1803 Log(("%s: usbProxyDarwinUrbQueue: pProxyDev=%s EndPt=%d cbData=%d - failed irc=%#x! (stall)\n", 1805 1804 pUrb->pszDesc, pProxyDev->pUsbIns->pszName, pUrb->EndPt, pUrb->cbData, irc)); 1806 return true;1805 return VINF_SUCCESS; 1807 1806 } 1808 1807 } … … 1810 1809 Log(("%s: usbProxyDarwinUrbQueue: pProxyDev=%s EndPt=%d cbData=%d - failed irc=%#x!\n", 1811 1810 pUrb->pszDesc, pProxyDev->pUsbIns->pszName, pUrb->EndPt, pUrb->cbData, irc)); 1812 return false;1811 return RTErrConvertFromDarwin(irc); 1813 1812 } 1814 1813 … … 1896 1895 * requests, we should probably be fine... 1897 1896 */ 1898 static DECLCALLBACK(void) usbProxyDarwinUrbCancel(PVUSBURB pUrb) 1899 { 1900 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 1897 static DECLCALLBACK(int) usbProxyDarwinUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb) 1898 { 1901 1899 PUSBPROXYDEVOSX pDevOsX = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVOSX); 1902 //PUSBPROXYURBOSX pUrbOsX = (PUSBPROXYURBOSX)pUrb->Dev.pvProxyUrb;1903 1900 LogFlow(("%s: usbProxyDarwinUrbCancel: pProxyDev=%s EndPt=%d\n", 1904 1901 pUrb->pszDesc, pProxyDev->pUsbIns->pszName, pUrb->EndPt)); … … 1921 1918 pProxyDev->pUsbIns->pszName, pUrb, pUrb->EndPt)); 1922 1919 } 1920 1921 int rc = VINF_SUCCESS; 1923 1922 if (irc != kIOReturnSuccess) 1923 { 1924 1924 Log(("usbProxyDarwinUrbCancel: pProxyDev=%s pUrb=%p EndPt=%d -> %#x!\n", 1925 1925 pProxyDev->pUsbIns->pszName, pUrb, pUrb->EndPt, irc)); 1926 rc = RTErrConvertFromDarwin(irc); 1927 } 1928 1929 return rc; 1926 1930 } 1927 1931 -
trunk/src/VBox/Devices/USB/freebsd/USBProxyDevice-freebsd.cpp
r50228 r50234 537 537 LogFlow(("usbProxyFreeBSDSetInterface: Freeing kernel resources " 538 538 "failed failed rc=%d\n", rc)); 539 return false;539 return rc; 540 540 } 541 541 … … 558 558 LogFlow(("usbProxyFreeBSDSetConfig: configuration " 559 559 "%d not found\n", iCfg)); 560 return false;560 return VERR_NOT_FOUND; 561 561 } 562 562 } … … 565 565 rc = usbProxyFreeBSDDoIoCtl(pProxyDev, USB_SET_CONFIG, &iCfgIndex, true); 566 566 if (RT_FAILURE(rc)) 567 return false;567 return rc; 568 568 569 569 /* Allocate kernel ressources again. */ 570 rc = usbProxyFreeBSDFsInit(pProxyDev); 571 if (RT_FAILURE(rc)) 572 return false; 573 574 return true; 570 return usbProxyFreeBSDFsInit(pProxyDev); 575 571 } 576 572 … … 590 586 * failures 591 587 */ 592 rc =usbProxyFreeBSDDoIoCtl(pProxyDev, USB_IFACE_DRIVER_DETACH, &iIf, true);588 usbProxyFreeBSDDoIoCtl(pProxyDev, USB_IFACE_DRIVER_DETACH, &iIf, true); 593 589 594 590 /* 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); 600 592 } 601 593 … … 611 603 "ifnum=%x\n", pProxyDev->pUsbIns->pszName, iIf)); 612 604 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); 618 606 } 619 607 … … 623 611 * @returns success indicator. 624 612 */ 625 static DECLCALLBACK(int) 626 usbProxyFreeBSDSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt) 613 static DECLCALLBACK(int) usbProxyFreeBSDSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt) 627 614 { 628 615 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); … … 639 626 LogFlow(("usbProxyFreeBSDSetInterface: Freeing kernel resources " 640 627 "failed failed rc=%d\n", rc)); 641 return false;628 return rc; 642 629 } 643 630 memset(&UsbIntAlt, 0, sizeof(UsbIntAlt)); … … 650 637 LogFlow(("usbProxyFreeBSDSetInterface: Setting interface %d %d " 651 638 "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); 660 643 } 661 644 … … 663 646 * Clears the halted endpoint 'ep_num'. 664 647 */ 665 static DECLCALLBACK(bool) usbProxyFreeBSDClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep_num) 666 { 667 struct usb_ctl_request Req; 668 int rc; 669 648 static DECLCALLBACK(int) usbProxyFreeBSDClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep_num) 649 { 670 650 LogFlow(("usbProxyFreeBSDClearHaltedEp: pProxyDev=%s ep_num=%u\n", 671 651 pProxyDev->pUsbIns->pszName, ep_num)); … … 676 656 */ 677 657 if ((ep_num & 0xF) == 0) 678 return true; 679 658 return VINF_SUCCESS; 659 660 struct usb_ctl_request Req; 680 661 memset(&Req, 0, sizeof(Req)); 681 682 662 usbProxyFreeBSDSetupReq(&Req.ucr_request, 683 663 VUSB_DIR_TO_DEV | VUSB_TO_ENDPOINT, 684 664 VUSB_REQ_CLEAR_FEATURE, 0, ep_num, 0); 685 665 686 rc = usbProxyFreeBSDDoIoCtl(pProxyDev, USB_DO_REQUEST, &Req, true);666 int rc = usbProxyFreeBSDDoIoCtl(pProxyDev, USB_DO_REQUEST, &Req, true); 687 667 688 668 LogFlow(("usbProxyFreeBSDClearHaltedEp: rc=%Rrc\n", rc)); 689 690 if (RT_FAILURE(rc)) 691 return false; 692 693 return true; 669 return rc; 694 670 } 695 671 … … 727 703 728 704 if (index < 0) 729 return false;705 return VERR_INVALID_PARAMETER; 730 706 731 707 pEndpointFBSD = &pDevFBSD->aSwEndpoint[index]; … … 997 973 * The URB requires reaping, so we don't change its state. 998 974 */ 999 static DECLCALLBACK(void) usbProxyFreeBSDUrbCancel(PVUSBURB pUrb) 1000 { 1001 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 975 static DECLCALLBACK(int) usbProxyFreeBSDUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb) 976 { 1002 977 int index; 1003 978 … … 1005 980 1006 981 if (index < 0 || index >= USBFBSD_MAXENDPOINTS) 1007 return ;982 return VINF_SUCCESS; /* invalid index, pretend success. */ 1008 983 1009 984 LogFlow(("usbProxyFreeBSDUrbCancel: epindex=%u\n", (unsigned)index)); 1010 1011 usbProxyFreeBSDEndpointClose(pProxyDev, index); 985 return usbProxyFreeBSDEndpointClose(pProxyDev, index); 1012 986 } 1013 987 -
trunk/src/VBox/Devices/USB/linux/USBProxyDevice-linux.cpp
r50228 r50234 1126 1126 { 1127 1127 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; 1131 1131 } 1132 1132 … … 1144 1144 { 1145 1145 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; 1149 1149 } 1150 1150 … … 1161 1161 { 1162 1162 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; 1166 1166 } 1167 1167 … … 1182 1182 { 1183 1183 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; 1187 1187 } 1188 1188 … … 1191 1191 * Clears the halted endpoint 'EndPt'. 1192 1192 */ 1193 static boolusbProxyLinuxClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)1193 static int usbProxyLinuxClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt) 1194 1194 { 1195 1195 LogFlow(("usbProxyLinuxClearHaltedEp: pProxyDev=%s EndPt=%u\n", usbProxyGetName(pProxyDev), EndPt)); … … 1206 1206 Log(("usb-linux: clear_halted_ep failed errno=%d. pProxyDev=%s ep=%d - IGNORED\n", 1207 1207 errno, usbProxyGetName(pProxyDev), EndPt)); 1208 return true;1208 return VINF_SUCCESS; 1209 1209 } 1210 1210 Log(("usb-linux: clear_halted_ep failed errno=%d. pProxyDev=%s ep=%d\n", 1211 1211 errno, usbProxyGetName(pProxyDev), EndPt)); 1212 return false;1213 } 1214 return true;1212 return RTErrConvertFromErrno(errno); 1213 } 1214 return VINF_SUCCESS; 1215 1215 } 1216 1216 … … 1277 1277 * retries 1278 1278 * 1279 * @returns true / false. 1280 */ 1281 static bool usbProxyLinuxSubmitURB(PUSBPROXYDEV pProxyDev, PUSBPROXYURBLNX pCur, PVUSBURB pUrb, bool *pfUnplugged) 1282 { 1279 * @returns VBox status code. 1280 */ 1281 static int usbProxyLinuxSubmitURB(PUSBPROXYDEV pProxyDev, PUSBPROXYURBLNX pCur, PVUSBURB pUrb, bool *pfUnplugged) 1282 { 1283 int rc = VINF_SUCCESS; 1283 1284 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 1284 1285 unsigned cTries = 0; … … 1292 1293 Log(("usbProxyLinuxSubmitURB: ENODEV -> unplugged. pProxyDev=%s\n", usbProxyGetName(pProxyDev))); 1293 1294 *pfUnplugged = true; 1294 return false;1295 return RTErrConvertFromErrno(errno); 1295 1296 } 1296 1297 … … 1302 1303 continue; 1303 1304 } 1304 return false;1305 } 1306 return true;1305 return RTErrConvertFromErrno(errno); 1306 } 1307 return VINF_SUCCESS; 1307 1308 } 1308 1309 … … 1353 1354 * URB at a time -> worse performance but correct behaviour. 1354 1355 * 1355 * @returns true / false.1356 * @returns VBox status code. 1356 1357 * @param pProxyDev The proxy device. 1357 1358 * @param pUrbLnx The linux URB which was rejected because of being too big. … … 1379 1380 AssertMsgFailed(("We can't split isochronous URBs!\n")); 1380 1381 usbProxyLinuxUrbFree(pProxyDev, pUrbLnx); 1381 return false;1382 return VERR_INVALID_PARAMETER; /** @todo: Better status code. */ 1382 1383 } 1383 1384 pUrbLnx->KUrb.endpoint = pUrb->EndPt; … … 1402 1403 pUrbLnx->cbSplitRemaining = cbLeft; 1403 1404 1404 bool fSucceeded = false;1405 int rc = VINF_SUCCESS; 1405 1406 bool fUnplugged = false; 1406 1407 if (pUrb->enmDir == VUSBDIRECTION_IN && !pUrb->fShortNotOk) … … 1409 1410 * and only if necessary. 1410 1411 */ 1411 fSucceeded = true;1412 1412 Log(("usb-linux: Large ShortOK read, only queuing first fragment.\n")); 1413 1413 Assert(pUrbLnx->cbSplitRemaining > 0 && pUrbLnx->cbSplitRemaining < 256 * _1K); 1414 fSucceeded= usbProxyLinuxSubmitURB(pProxyDev, pUrbLnx, pUrb, &fUnplugged);1414 rc = usbProxyLinuxSubmitURB(pProxyDev, pUrbLnx, pUrb, &fUnplugged); 1415 1415 } 1416 1416 else … … 1422 1422 pCur = usbProxyLinuxSplitURBFragment(pProxyDev, pUrbLnx, pCur); 1423 1423 if (!pCur) 1424 { 1425 return false; 1426 } 1424 return VERR_NO_MEMORY; 1427 1425 } 1428 1426 Assert(pCur->cbSplitRemaining == 0); … … 1432 1430 for (i = 0; i < cKUrbs; i++, pCur = pCur->pSplitNext) 1433 1431 { 1434 fSucceeded= usbProxyLinuxSubmitURB(pProxyDev, pCur, pUrb, &fUnplugged);1435 if ( !fSucceeded)1432 rc = usbProxyLinuxSubmitURB(pProxyDev, pCur, pUrb, &fUnplugged); 1433 if (RT_FAILURE(rc)) 1436 1434 break; 1437 1435 } 1438 1436 } 1439 1437 1440 if ( fSucceeded)1438 if (RT_SUCCESS(rc)) 1441 1439 { 1442 1440 pUrb->Dev.pvPrivate = pUrbLnx; 1443 1441 LogFlow(("usbProxyLinuxUrbQueueSplit: ok\n")); 1444 return true;1442 return VINF_SUCCESS; 1445 1443 } 1446 1444 1447 1445 usbProxyLinuxCleanupFailedSubmit(pProxyDev, pUrbLnx, pCur, pUrb, &fUnplugged); 1448 return false;1446 return rc; 1449 1447 } 1450 1448 … … 1453 1451 * @copydoc USBPROXYBACK::pfnUrbQueue 1454 1452 */ 1455 static DECLCALLBACK(int) usbProxyLinuxUrbQueue(PVUSBURB pUrb) 1456 { 1453 static DECLCALLBACK(int) usbProxyLinuxUrbQueue(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb) 1454 { 1455 int rc = VINF_SUCCESS; 1457 1456 unsigned cTries; 1458 #ifndef RDESKTOP1459 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);1460 #else1461 PUSBPROXYDEV pProxyDev = usbProxyFromVusbDev(pUrb->pDev);1462 #endif1463 1457 PUSBPROXYDEVLNX pDevLnx = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVLNX); 1464 1458 LogFlow(("usbProxyLinuxUrbQueue: pProxyDev=%s pUrb=%p EndPt=%d cbData=%d\n", … … 1470 1464 PUSBPROXYURBLNX pUrbLnx = usbProxyLinuxUrbAlloc(pProxyDev, NULL); 1471 1465 if (!pUrbLnx) 1472 return false;1466 return VERR_NO_MEMORY; 1473 1467 1474 1468 pUrbLnx->KUrb.endpoint = pUrb->EndPt | (pUrb->enmDir == VUSBDIRECTION_IN ? 0x80 : 0); … … 1491 1485 { 1492 1486 usbProxyLinuxUrbFree(pProxyDev, pUrbLnx); 1493 return false;1487 return VERR_BUFFER_UNDERFLOW; 1494 1488 } 1495 1489 usbProxyLinuxUrbSwapSetup((PVUSBSETUP)pUrb->abData); … … 1515 1509 break; 1516 1510 default: 1517 goto l_err;1511 rc = VERR_INVALID_PARAMETER; /** @todo: better status code. */ 1518 1512 } 1519 1513 … … 1534 1528 1535 1529 usbProxLinuxUrbUnplugged(pProxyDev); 1536 return false;1530 return RTErrConvertFromErrno(errno); 1537 1531 } 1538 1532 … … 1553 1547 if (errno != EBUSY && ++cTries < 3) /* this doesn't work for the floppy :/ */ 1554 1548 continue; 1549 1550 rc = RTErrConvertFromErrno(errno); 1551 1555 1552 l_err: 1556 1553 if (pUrb->enmType == VUSBXFERTYPE_MSG) 1557 1554 usbProxyLinuxUrbSwapSetup((PVUSBSETUP)pUrb->abData); 1558 1555 usbProxyLinuxUrbFree(pProxyDev, pUrbLnx); 1559 return false;1556 return rc; 1560 1557 } 1561 1558 pUrbLnx->u64SubmitTS = RTTimeMilliTS(); … … 1563 1560 LogFlow(("usbProxyLinuxUrbQueue: ok\n")); 1564 1561 pUrb->Dev.pvPrivate = pUrbLnx; 1565 return true;1562 return rc; 1566 1563 } 1567 1564 … … 1951 1948 * The URB requires reaping, so we don't change its state. 1952 1949 */ 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 1950 static DECLCALLBACK(int) usbProxyLinuxUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb) 1951 { 1952 int rc = VINF_SUCCESS; 1960 1953 PUSBPROXYURBLNX pUrbLnx = (PUSBPROXYURBLNX)pUrb->Dev.pvPrivate; 1961 1954 if (pUrbLnx->pSplitHead) … … 1973 1966 if (errno == ENODEV) 1974 1967 break; 1968 /** @todo: Think about how to handle errors wrt. to the status code. */ 1975 1969 Log(("usb-linux: Discard URB %p failed, errno=%d. pProxyDev=%s!!! (split)\n", 1976 1970 pUrb, errno, usbProxyGetName(pProxyDev))); … … 1983 1977 && errno != ENODEV /* deal with elsewhere. */ 1984 1978 && errno != ENOENT) 1979 { 1985 1980 Log(("usb-linux: Discard URB %p failed, errno=%d. pProxyDev=%s!!!\n", 1986 1981 pUrb, errno, usbProxyGetName(pProxyDev))); 1987 } 1982 rc = RTErrConvertFromErrno(errno); 1983 } 1984 } 1985 1986 return rc; 1988 1987 } 1989 1988 -
trunk/src/VBox/Devices/USB/solaris/USBProxyDevice-solaris.cpp
r50232 r50234 494 494 SetConfigReq.bConfigValue = iCfg; 495 495 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) 500 498 LogRel((USBPROXY ":usbProxySolarisSetConfig failed to switch configuration. rc=%Rrc\n", rc)); 501 499 502 return false;500 return rc; 503 501 } 504 502 … … 514 512 static DECLCALLBACK(int) usbProxySolarisClaimInterface(PUSBPROXYDEV pProxyDev, int iIf) 515 513 { 516 return true;514 return VINF_SUCCESS; 517 515 } 518 516 … … 528 526 static DECLCALLBACK(int) usbProxySolarisReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf) 529 527 { 530 return true;528 return VINF_SUCCESS; 531 529 } 532 530 … … 548 546 SetInterfaceReq.bAlternate = iAlt; 549 547 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) 554 550 LogRel((USBPROXY ":usbProxySolarisSetInterface failed to set interface. rc=%Rrc\n", rc)); 555 551 556 return false;552 return rc; 557 553 } 558 554 … … 561 557 * Clears the halted endpoint 'EndPt'. 562 558 */ 563 static DECLCALLBACK( bool) usbProxySolarisClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)559 static DECLCALLBACK(int) usbProxySolarisClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt) 564 560 { 565 561 LogFlowFunc((USBPROXY ":usbProxySolarisClearHaltedEp pProxyDev=%p EndPt=%#x\n", pProxyDev, EndPt)); … … 571 567 ClearEpReq.bEndpoint = EndPt; 572 568 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) 577 571 LogRel((USBPROXY ":usbProxySolarisClearHaltedEp failed! rc=%Rrc\n", rc)); 578 572 579 return false;573 return rc; 580 574 } 581 575 … … 596 590 { 597 591 LogRel((USBPROXY ":usbProxySolarisUrbQueue: Failed to allocate URB.\n")); 598 return false;592 return VERR_NO_MEMORY; 599 593 } 600 594 … … 632 626 LogFlow((USBPROXY ":usbProxySolarisUrbQueue success cbData=%d.\n", pUrb->cbData)); 633 627 pUrb->Dev.pvPrivate = pUrbSol; 634 return true;628 return VINF_SUCCESS; 635 629 } 636 630 … … 639 633 pProxyDev->pUsbIns->pszName, pUrb, pUrb->EndPt, UrbReq.bEndpoint, pUrb->enmType, pUrb->enmDir, pUrb->cbData, rc)); 640 634 641 return false;635 return rc; 642 636 } 643 637 … … 650 644 * on Solaris. So we just abort pending URBs on the pipe. 651 645 */ 652 static DECLCALLBACK( void) usbProxySolarisUrbCancel(PVUSBURB pUrb)646 static DECLCALLBACK(int) usbProxySolarisUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb) 653 647 { 654 648 PUSBPROXYURBSOL pUrbSol = (PUSBPROXYURBSOL)pUrb->Dev.pvPrivate; 655 656 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV);657 649 PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 658 650 AssertPtrReturnVoid(pDevSol); … … 662 654 /* Aborting the control pipe isn't supported, pretend success. */ 663 655 if (!pUrb->EndPt) 664 return ;656 return VINF_SUCCESS; 665 657 666 658 VBOXUSBREQ_ABORT_PIPE AbortPipeReq; 667 659 AbortPipeReq.bEndpoint = pUrb->EndPt | (pUrb->enmDir == VUSBDIRECTION_IN ? VUSB_DIR_TO_HOST : VUSB_DIR_TO_DEVICE); 668 660 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; 677 667 } 678 668 -
trunk/src/VBox/Devices/USB/vrdp/USBProxyDevice-vrdp.cpp
r50228 r50234 118 118 } 119 119 120 return RT_SUCCESS(rc);120 return rc; 121 121 } 122 122 … … 135 135 } 136 136 137 return RT_SUCCESS(rc);137 return rc; 138 138 } 139 139 … … 152 152 } 153 153 154 return RT_SUCCESS(rc);154 return rc; 155 155 } 156 156 … … 169 169 } 170 170 171 return RT_SUCCESS(rc);172 } 173 174 static DECLCALLBACK( bool) usbProxyVrdpClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep)171 return rc; 172 } 173 174 static DECLCALLBACK(int) usbProxyVrdpClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep) 175 175 { 176 176 LogFlow(("usbProxyVrdpClearHaltedEp: pProxyDev=%s ep=%u\n", pProxyDev->pUsbIns->pszName, ep)); … … 186 186 } 187 187 188 return RT_SUCCESS(rc);189 } 190 191 static DECLCALLBACK(int) usbProxyVrdpUrbQueue(P VUSBURB pUrb)188 return rc; 189 } 190 191 static DECLCALLBACK(int) usbProxyVrdpUrbQueue(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb) 192 192 { 193 193 LogFlow(("usbProxyVrdpUrbQueue: pUrb=%p\n", pUrb)); … … 197 197 { 198 198 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); 205 203 int rc = pDevVrdp->pCallback->pfnQueueURB (pDevVrdp->pDevice, pUrb->enmType, pUrb->EndPt, pUrb->enmDir, pUrb->cbData, 206 204 pUrb->abData, pUrb, (PREMOTEUSBQURB *)&pUrb->Dev.pvPrivate); … … 212 210 } 213 211 214 return RT_SUCCESS(rc);212 return rc; 215 213 } 216 214 … … 245 243 } 246 244 247 static DECLCALLBACK( void) usbProxyVrdpUrbCancel(PVUSBURB pUrb)245 static DECLCALLBACK(int) usbProxyVrdpUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb) 248 246 { 249 247 LogFlow(("usbProxyVrdpUrbCancel: pUrb=%p\n", pUrb)); 250 248 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); 254 250 pDevVrdp->pCallback->pfnCancelURB (pDevVrdp->pDevice, (PREMOTEUSBQURB)pUrb->Dev.pvPrivate); 251 return VINF_SUCCESS; /** @todo: Enhance remote interface to pass a status code. */ 255 252 } 256 253 … … 260 257 261 258 PUSBPROXYDEVVRDP pDevVrdp = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVVRDP); 262 263 259 return pDevVrdp->pCallback->pfnWakeup (pDevVrdp->pDevice); 264 260 } -
trunk/src/VBox/Devices/USB/win/USBProxyDevice-win.cpp
r50233 r50234 83 83 *******************************************************************************/ 84 84 static 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 */ 93 static 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 } 86 107 87 108 /** … … 279 300 cbReturned = 0; 280 301 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()); 293 305 } 294 306 … … 305 317 306 318 Assert(pPriv); 307 return true;319 return VINF_SUCCESS; 308 320 } 309 321 … … 314 326 315 327 Assert(pPriv); 316 return true;328 return VINF_SUCCESS; 317 329 } 318 330 … … 336 348 cbReturned = 0; 337 349 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()); 349 353 } 350 354 … … 352 356 * Clears the halted endpoint 'ep'. 353 357 */ 354 static DECLCALLBACK( bool) usbProxyWinClearHaltedEndPt(PUSBPROXYDEV pProxyDev, unsigned int ep)358 static DECLCALLBACK(int) usbProxyWinClearHaltedEndPt(PUSBPROXYDEV pProxyDev, unsigned int ep) 355 359 { 356 360 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); … … 365 369 cbReturned = 0; 366 370 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()); 378 374 } 379 375 … … 397 393 return VINF_SUCCESS; 398 394 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()); 409 396 } 410 397 … … 412 399 * @copydoc USBPROXYBACK::pfnUrbQueue 413 400 */ 414 static DECLCALLBACK(int) usbProxyWinUrbQueue(PVUSBURB pUrb) 415 { 416 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 401 static DECLCALLBACK(int) usbProxyWinUrbQueue(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb) 402 { 417 403 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 418 404 Assert(pPriv); … … 424 410 PQUEUED_URB pQUrbWin = (PQUEUED_URB)RTMemAllocZ(sizeof(QUEUED_URB)); 425 411 if (!pQUrbWin) 426 return false;412 return VERR_NO_MEMORY; 427 413 428 414 switch (pUrb->enmType) … … 443 429 default: 444 430 AssertMsgFailed(("Invalid type %d\n", pUrb->enmType)); 445 return false;431 return VERR_INVALID_PARAMETER; 446 432 } 447 433 … … 460 446 default: 461 447 AssertMsgFailed(("Invalid direction %d\n", pUrb->enmDir)); 462 return false;448 return VERR_INVALID_PARAMETER; 463 449 } 464 450 … … 474 460 pQUrbWin->urbwin.flags = USBSUP_FLAG_SHORT_OK; 475 461 462 int rc = VINF_SUCCESS; 476 463 pQUrbWin->overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); 477 464 if (pQUrbWin->overlapped.hEvent != INVALID_HANDLE_VALUE) … … 492 479 RTCritSectLeave(&pPriv->CritSect); 493 480 SetEvent(pPriv->hEventWakeup); 494 return true;481 return VINF_SUCCESS; 495 482 } 496 483 else … … 500 487 || dwErr == ERROR_BAD_COMMAND) 501 488 { 502 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pQUrbWin->urb->pUsbIns, PUSBPROXYDEV);503 489 Log(("usbproxy: device %p unplugged!!\n", pPriv->hDev)); 504 490 pProxyDev->fDetached = true; … … 506 492 else 507 493 AssertMsgFailed(("dwErr=%X urbwin.error=%d (submit urb)\n", dwErr, pQUrbWin->urbwin.error)); 494 rc = RTErrConvertFromWin32(dwErr); 508 495 CloseHandle(pQUrbWin->overlapped.hEvent); 509 496 pQUrbWin->overlapped.hEvent = INVALID_HANDLE_VALUE; … … 514 501 { 515 502 AssertMsgFailed(("FAILED!!, hEvent(0x%p)\n", pQUrbWin->overlapped.hEvent)); 503 rc = VERR_NO_MEMORY; 516 504 } 517 505 #endif … … 519 507 Assert(pQUrbWin->overlapped.hEvent == INVALID_HANDLE_VALUE); 520 508 RTMemFree(pQUrbWin); 521 return false;509 return rc; 522 510 } 523 511 … … 587 575 RTCritSectEnter(&pPriv->CritSect); 588 576 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. */ 592 578 if (pPriv->cQueuedUrbs + pPriv->cPendingUrbs + 1 > pPriv->cAllocatedUrbs) 593 579 { … … 719 705 * exactly what the guest wants to do. 720 706 */ 721 static DECLCALLBACK(void) usbProxyWinUrbCancel(PVUSBURB pUrb) 722 { 723 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 707 static DECLCALLBACK(int) usbProxyWinUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb) 708 { 724 709 PPRIV_USBW32 pPriv = USBPROXYDEV_2_DATA(pProxyDev, PPRIV_USBW32); 725 710 PQUEUED_URB pQUrbWin = (PQUEUED_URB)pUrb->Dev.pvPrivate; 726 int rc;727 711 USBSUP_CLEAR_ENDPOINT in; 728 712 DWORD cbReturned; 729 Assert(pQUrbWin); 713 714 AssertPtrReturn(pQUrbWin, VERR_INVALID_PARAMETER); 730 715 731 716 in.bEndpoint = pUrb->EndPt | (pUrb->enmDir == VUSBDIRECTION_IN ? 0x80 : 0); … … 734 719 cbReturned = 0; 735 720 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_STATE740 || 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) 741 726 { 742 727 Log(("usbproxy: device %x unplugged!!\n", pPriv->hDev)); 743 728 pProxyDev->fDetached = true; 729 return VINF_SUCCESS; /* Fake success and deal with the unplugged device elsewhere. */ 744 730 } 745 731 else -
trunk/src/VBox/RDP/client/vrdp/rdpusb.c
r50228 r50234 133 133 } 134 134 135 static inline int op_usbproxy_back_queue_urb(P VUSBURB pUrb)136 { 137 return g_USBProxyDeviceHost.pfnUrbQueue(p Urb);135 static inline int op_usbproxy_back_queue_urb(PUSBPROXYDEV pDev, PVUSBURB pUrb) 136 { 137 return g_USBProxyDeviceHost.pfnUrbQueue(pDev, pUrb); 138 138 } 139 139 … … 148 148 } 149 149 150 static inline void op_usbproxy_back_cancel_urb(PVUSBURB pUrb)151 { 152 return g_USBProxyDeviceHost.pfnUrbCancel (p Urb);150 static inline int op_usbproxy_back_cancel_urb(PUSBPROXYDEV pDev, PVUSBURB pUrb) 151 { 152 return g_USBProxyDeviceHost.pfnUrbCancel (pDev, pUrb); 153 153 } 154 154 … … 699 699 } 700 700 701 rc = op_usbproxy_back_queue_urb(p Urb);701 rc = op_usbproxy_back_queue_urb(proxy, pUrb); 702 702 703 703 /* No reply required. */ … … 772 772 if (pUrb) 773 773 { 774 op_usbproxy_back_cancel_urb(p Urb);774 op_usbproxy_back_cancel_urb(proxy, pUrb); 775 775 776 776 /* No reply required. */
Note:
See TracChangeset
for help on using the changeset viewer.