Changeset 93956 in vbox for trunk/src/VBox/Devices/USB
- Timestamp:
- Feb 25, 2022 4:21:22 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 150186
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp
r93955 r93956 400 400 401 401 402 /** 403 * Detaches the given device from the given roothub. 404 * 405 * @returns VBox status code. 406 * @param pThis The roothub to detach the device from. 407 * @param pDev The device to detach. 408 */ 409 static int vusbHubDetach(PVUSBROOTHUB pThis, PVUSBDEV pDev) 410 { 411 PVUSBHUB pHub = &pThis->Hub; 412 413 Assert(pDev->i16Port != -1); 414 415 /* Cancel all in-flight URBs from this device. */ 416 vusbDevCancelAllUrbs(pDev, true); 417 418 /* 419 * Detach the device and mark the port as available. 420 */ 421 unsigned uPort = pDev->i16Port; 422 pDev->i16Port = -1; 423 pThis->pIRhPort->pfnDetach(pThis->pIRhPort, uPort); 424 ASMBitSet(&pThis->Bitmap, uPort); 425 pHub->cDevices--; 426 427 /* Check that it's attached and remove it. */ 428 RTCritSectEnter(&pThis->CritSectDevices); 429 Assert(pThis->apDevByPort[uPort] == pDev); 430 pThis->apDevByPort[uPort] = NULL; 431 432 if (pDev->u8Address == VUSB_DEFAULT_ADDRESS) 433 { 434 AssertPtr(pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS]); 435 436 if (pDev == pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS]) 437 pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS] = pDev->pNextDefAddr; 438 else 439 { 440 /* Search the list for the device and remove it. */ 441 PVUSBDEV pDevPrev = pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS]; 442 443 while ( pDevPrev 444 && pDevPrev->pNextDefAddr != pDev) 445 pDevPrev = pDevPrev->pNextDefAddr; 446 447 AssertPtr(pDevPrev); 448 pDevPrev->pNextDefAddr = pDev->pNextDefAddr; 449 } 450 451 pDev->pNextDefAddr = NULL; 452 } 453 else 454 { 455 Assert(pThis->apDevByAddr[pDev->u8Address] == pDev); 456 pThis->apDevByAddr[pDev->u8Address] = NULL; 457 } 458 RTCritSectLeave(&pThis->CritSectDevices); 459 460 /* Free resources. */ 461 vusbDevDetach(pDev); 462 return VINF_SUCCESS; 463 } 464 465 466 402 467 /* -=-=-=-=-=- PDMUSBHUBREG methods -=-=-=-=-=- */ 403 468 … … 440 505 Assert(pDev); 441 506 507 LogRel(("VUSB: Detached '%s' from port %u on %s\n", pDev->pUsbIns->pszName, pDev->i16Port, pHub->pszName)); 508 442 509 /* 443 510 * Deal with pending async reset. … … 445 512 */ 446 513 vusbDevSetStateCmp(pDev, VUSB_DEVICE_STATE_DEFAULT, VUSB_DEVICE_STATE_RESET); 447 Assert(pDev->i16Port != -1); 448 449 /* Cancel all in-flight URBs from this device. */ 450 vusbDevCancelAllUrbs(pDev, true); 451 452 /* 453 * Detach the device and mark the port as available. 454 */ 455 unsigned uPort = pDev->i16Port; 456 pDev->i16Port = -1; 457 pThis->pIRhPort->pfnDetach(pThis->pIRhPort, uPort); 458 ASMBitSet(&pThis->Bitmap, uPort); 459 pHub->cDevices--; 460 461 /* Check that it's attached and remove it. */ 462 RTCritSectEnter(&pThis->CritSectDevices); 463 Assert(pThis->apDevByPort[uPort] == pDev); 464 pThis->apDevByPort[uPort] = NULL; 465 466 if (pDev->u8Address == VUSB_DEFAULT_ADDRESS) 467 { 468 AssertPtr(pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS]); 469 470 if (pDev == pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS]) 471 pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS] = pDev->pNextDefAddr; 472 else 473 { 474 /* Search the list for the device and remove it. */ 475 PVUSBDEV pDevPrev = pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS]; 476 477 while ( pDevPrev 478 && pDevPrev->pNextDefAddr != pDev) 479 pDevPrev = pDevPrev->pNextDefAddr; 480 481 AssertPtr(pDevPrev); 482 pDevPrev->pNextDefAddr = pDev->pNextDefAddr; 483 } 484 485 pDev->pNextDefAddr = NULL; 486 } 487 else 488 { 489 Assert(pThis->apDevByAddr[pDev->u8Address] == pDev); 490 pThis->apDevByAddr[pDev->u8Address] = NULL; 491 } 492 RTCritSectLeave(&pThis->CritSectDevices); 493 494 /* 495 * Detach and free resources. 496 */ 497 vusbDevDetach(pDev); 498 499 LogRel(("VUSB: Detached '%s' from port %u on %s\n", pDev->pUsbIns->pszName, uPort, pHub->pszName)); 514 vusbHubDetach(pThis, pDev); 500 515 vusbDevRelease(pDev); 501 516 return VINF_SUCCESS; … … 1317 1332 if (!VUSBIDevIsSavedStateSupported(&pDev->IDevice)) 1318 1333 { 1319 int rc = vusb DevDetach(pDev);1334 int rc = vusbHubDetach(pThis, pDev); 1320 1335 AssertRC(rc); 1321 1336 … … 1413 1428 { 1414 1429 Load.apDevs[Load.cDevs++] = pDev; 1415 vusb DevDetach(pDev);1430 vusbHubDetach(pThis, pDev); 1416 1431 Assert(!pThis->apDevByPort[i]); 1417 1432 }
Note:
See TracChangeset
for help on using the changeset viewer.