/* Internal helper function which will signal the caller event and clean up resources. */
VOID EFIAPI SignalCallerEvent(IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UFS_PASS_THRU_TRANS_REQ *TransReq)
/* Internal helper function which will signal the caller event and clean up resources. */
VOID EFIAPI SignalCallerEvent(IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UFS_PASS_THRU_TRANS_REQ *TransReq)
{
  EDKII_UFS_HOST_CONTROLLER_PROTOCOL  *UfsHc;
  EFI_EVENT                           CallerEvent;
  ASSERT ((Private != NULL) && (TransReq != NULL));
  UfsHc       = Private->UfsHostController;
  CallerEvent = TransReq->CallerEvent;
  RemoveEntryList (&TransReq->TransferList);
  UfsHc->Flush (UfsHc);
  UfsStopExecCmd (Private, TransReq->Slot);
  UfsReconcileDataTransferBuffer (Private, TransReq);
  if (TransReq->CmdDescMapping != NULL) {
    UfsHc->Unmap (UfsHc, TransReq->CmdDescMapping);
  }
  if (TransReq->CmdDescHost != NULL) {
    UfsHc->FreeBuffer (
             UfsHc,
             EFI_SIZE_TO_PAGES (TransReq->CmdDescSize),
             TransReq->CmdDescHost
             );
  }
  FreePool (TransReq);
  gBS->SignalEvent (CallerEvent);
  return;
}