/* Find out available slot in transfer list of a UFS device. */
EFI_STATUS UfsFindAvailableSlotInTrl(IN UFS_PASS_THRU_PRIVATE_DATA *Private, OUT UINT8 *Slot)
/* Find out available slot in transfer list of a UFS device. */
EFI_STATUS UfsFindAvailableSlotInTrl(IN UFS_PASS_THRU_PRIVATE_DATA *Private, OUT UINT8 *Slot)
{
  UINT8       Nutrs;
  UINT8       Index;
  UINT32      Data;
  EFI_STATUS  Status;
  ASSERT ((Private != NULL) && (Slot != NULL));
  Status = UfsMmioRead32 (Private, UFS_HC_UTRLDBR_OFFSET, &Data);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  Nutrs = (UINT8)((Private->UfsHcInfo.Capabilities & UFS_HC_CAP_NUTRS) + 1);
  for (Index = 0; Index < Nutrs; Index++) {
    if ((Data & (BIT0 << Index)) == 0) {
      *Slot = Index;
      return EFI_SUCCESS;
    }
  }
  return EFI_NOT_READY;
}