summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorerictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-25 05:13:22 +0000
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-25 05:13:22 +0000
commitc4b8c2d807b17641b73863d3636069cf26dc5c69 (patch)
tree05edb51ccd5314e9259e20025a36e8d08c96387b /MdeModulePkg
parentef949581ea3c622f42ad83337fd2625faa77c17f (diff)
downloadedk2-platforms-c4b8c2d807b17641b73863d3636069cf26dc5c69.tar.xz
Error handling refinement at UsbIoResetPort() to avoid device state machine getting corrupted when the device disconnect happens
Signed-off-by: erictian Reviewed-by: niruiyu git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12204 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
index b592913bd3..c3a9c734b8 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
@@ -818,7 +818,6 @@ UsbIoPortReset (
USB_INTERFACE *UsbIf;
USB_INTERFACE *HubIf;
USB_DEVICE *Dev;
- UINT8 Address;
EFI_TPL OldTpl;
EFI_STATUS Status;
@@ -843,27 +842,26 @@ UsbIoPortReset (
}
//
- // Reset the device to its current address. The device now has a
- // address of ZERO, so need to set Dev->Address to zero first for
- // host to communicate with the device
+ // Reset the device to its current address. The device now has an address
+ // of ZERO after port reset, so need to set Dev->Address to the device again for
+ // host to communicate with it.
//
- Address = Dev->Address;
- Dev->Address = 0;
- Status = UsbSetAddress (Dev, Address);
+ Status = UsbSetAddress (Dev, Dev->Address);
gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL);
if (EFI_ERROR (Status)) {
+ //
+ // It may fail due to device disconnection or other reasons.
+ //
DEBUG (( EFI_D_ERROR, "UsbIoPortReset: failed to set address for device %d - %r\n",
- Address, Status));
+ Dev->Address, Status));
goto ON_EXIT;
}
- Dev->Address = Address;
+ DEBUG (( EFI_D_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Dev->Address));
- DEBUG (( EFI_D_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Address));
-
//
// Reset the current active configure, after this device
// is in CONFIGURED state.
@@ -873,7 +871,7 @@ UsbIoPortReset (
if (EFI_ERROR (Status)) {
DEBUG (( EFI_D_ERROR, "UsbIoPortReset: failed to set configure for device %d - %r\n",
- Address, Status));
+ Dev->Address, Status));
}
}