/* Traverse the attached ATA devices list to find out the device to access. */
LIST_ENTRY* EFIAPI SearchDeviceInfoList(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT16 Port, IN UINT16 PortMultiplier, IN EFI_ATA_DEVICE_TYPE DeviceType)
/* Traverse the attached ATA devices list to find out the device to access. */
LIST_ENTRY* EFIAPI SearchDeviceInfoList(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT16 Port, IN UINT16 PortMultiplier, IN EFI_ATA_DEVICE_TYPE DeviceType)
{
  EFI_ATA_DEVICE_INFO  *DeviceInfo;
  LIST_ENTRY           *Node;
  Node = GetFirstNode (&Instance->DeviceList);
  while (!IsNull (&Instance->DeviceList, Node)) {
    DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
    if ((Instance->Mode == EfiAtaAhciMode) &&
        (DeviceInfo->Type == EfiIdeCdrom) &&
        (PortMultiplier == 0xFF))
    {
      PortMultiplier = 0xFFFF;
    }
    if ((DeviceInfo->Type == DeviceType) &&
        (Port == DeviceInfo->Port) &&
        (PortMultiplier == DeviceInfo->PortMultiplier))
    {
      return Node;
    }
    Node = GetNextNode (&Instance->DeviceList, Node);
  }
  return NULL;
}