/* Pop a controller device path from a globle device path list */
EFI_STATUS EFIAPI PopDevPathStack(OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
/* Pop a controller device path from a globle device path list */
EFI_STATUS EFIAPI PopDevPathStack(OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
{
  DEVICE_PATH_STACK_ITEM  *DevicePathStackItem;
  LIST_ENTRY              *ItemListIndex;
  ItemListIndex = mDevicePathStack.BackLink;
  if (ItemListIndex != &mDevicePathStack) {
    DevicePathStackItem = CR (ItemListIndex, DEVICE_PATH_STACK_ITEM, Link, DEVICE_PATH_STACK_ITEM_SIGNATURE);
    if (DevicePath != NULL) {
      *DevicePath = DuplicateDevicePath (DevicePathStackItem->DevicePath);
    }
    FreePool (DevicePathStackItem->DevicePath);
    RemoveEntryList (&DevicePathStackItem->Link);
    FreePool (DevicePathStackItem);
    return EFI_SUCCESS;
  }
  return EFI_NOT_FOUND;
}