\r
Usb bus enumeration support.\r
\r
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
@param UsbIf The USB interface to free.\r
\r
+ @retval EFI_ACCESS_DENIED The interface is still occupied.\r
+ @retval EFI_SUCCESS The interface is freed.\r
**/\r
-VOID\r
+EFI_STATUS\r
UsbFreeInterface (\r
IN USB_INTERFACE *UsbIf\r
)\r
{\r
- UsbCloseHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);\r
+ EFI_STATUS Status;\r
\r
- gBS->UninstallMultipleProtocolInterfaces (\r
- UsbIf->Handle,\r
- &gEfiDevicePathProtocolGuid,\r
- UsbIf->DevicePath,\r
- &gEfiUsbIoProtocolGuid,\r
- &UsbIf->UsbIo,\r
- NULL\r
- );\r
+ UsbCloseHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);\r
\r
- if (UsbIf->DevicePath != NULL) {\r
- FreePool (UsbIf->DevicePath);\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ UsbIf->Handle,\r
+ &gEfiDevicePathProtocolGuid, UsbIf->DevicePath,\r
+ &gEfiUsbIoProtocolGuid, &UsbIf->UsbIo,\r
+ NULL\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ if (UsbIf->DevicePath != NULL) {\r
+ FreePool (UsbIf->DevicePath);\r
+ }\r
+ FreePool (UsbIf);\r
+ } else {\r
+ UsbOpenHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);\r
}\r
-\r
- FreePool (UsbIf);\r
+ return Status;\r
}\r
\r
\r
\r
Status = UsbDisconnectDriver (UsbIf);\r
if (!EFI_ERROR (Status)) {\r
- UsbFreeInterface (UsbIf);\r
+ Status = UsbFreeInterface (UsbIf);\r
+ if (EFI_ERROR (Status)) {\r
+ UsbConnectDriver (UsbIf);\r
+ }\r
+ }\r
+\r
+ if (!EFI_ERROR (Status)) {\r
Device->Interfaces[Index] = NULL;\r
} else {\r
ReturnStatus = Status;\r