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
This commit is contained in:
erictian 2011-08-25 05:13:22 +00:00
parent ef949581ea
commit c4b8c2d807
1 changed files with 10 additions and 12 deletions

View File

@ -818,7 +818,6 @@ UsbIoPortReset (
USB_INTERFACE *UsbIf;
USB_INTERFACE *HubIf;
USB_DEVICE *Dev;
UINT8 Address;
EFI_TPL OldTpl;
EFI_STATUS Status;
@ -843,26 +842,25 @@ 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", Address));
DEBUG (( EFI_D_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Dev->Address));
//
// Reset the current active configure, after this device
@ -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));
}
}