/* Cleanup data buffers after data transfer. This function also takes care to copy all data to user memory pool for unaligned data transfers. */
VOID UfsReconcileDataTransferBuffer(IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UFS_PASS_THRU_TRANS_REQ *TransReq)
/* Cleanup data buffers after data transfer. This function also takes care to copy all data to user memory pool for unaligned data transfers. */
VOID UfsReconcileDataTransferBuffer(IN UFS_PASS_THRU_PRIVATE_DATA *Private, IN UFS_PASS_THRU_TRANS_REQ *TransReq)
{
  if (TransReq->DataBufMapping != NULL) {
    Private->UfsHostController->Unmap (
                                  Private->UfsHostController,
                                  TransReq->DataBufMapping
                                  );
  }
  if (TransReq->AlignedDataBuf != NULL) {
    if (TransReq->Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_READ) {
      CopyMem (TransReq->Packet->InDataBuffer, TransReq->AlignedDataBuf, TransReq->Packet->InTransferLength);
    }
    ZeroMem (TransReq->AlignedDataBuf, TransReq->AlignedDataBufSize);
    FreeAlignedPages (TransReq->AlignedDataBuf, EFI_SIZE_TO_PAGES (TransReq->AlignedDataBufSize));
    TransReq->AlignedDataBuf = NULL;
  }
}