/* Free an allocated URB. It is possible for it to be partially inited. */
VOID EhcFreeUrb(IN USB2_HC_DEV *Ehc, IN URB *Urb)
/* Free an allocated URB. It is possible for it to be partially inited. */
VOID EhcFreeUrb(IN USB2_HC_DEV *Ehc, IN URB *Urb)
{
  EFI_PCI_IO_PROTOCOL  *PciIo;
  PciIo = Ehc->PciIo;
  if (Urb->RequestPhy != NULL) {
    PciIo->Unmap (PciIo, Urb->RequestMap);
  }
  if (Urb->DataMap != NULL) {
    PciIo->Unmap (PciIo, Urb->DataMap);
  }
  if (Urb->Qh != NULL) {
    EhcFreeQtds (Ehc, &Urb->Qh->Qtds);
    UsbHcFreeMem (Ehc->MemPool, Urb->Qh, sizeof (EHC_QH));
  }
  gBS->FreePool (Urb);
}