/* If Slot is the slot number of the last slot on the SD controller, then EFI_NOT_FOUND is returned. */
EFI_STATUS EFIAPI SdMmcPassThruGetNextSlot(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This, IN OUT UINT8 *Slot)
/* If Slot is the slot number of the last slot on the SD controller, then EFI_NOT_FOUND is returned. */
EFI_STATUS EFIAPI SdMmcPassThruGetNextSlot(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This, IN OUT UINT8 *Slot)
{
  SD_MMC_HC_PRIVATE_DATA  *Private;
  UINT8                   Index;
  if ((This == NULL) || (Slot == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  Private = SD_MMC_HC_PRIVATE_FROM_THIS (This);
  if (*Slot == 0xFF) {
    for (Index = 0; Index < SD_MMC_HC_MAX_SLOT; Index++) {
      if (Private->Slot[Index].Enable) {
        *Slot                 = Index;
        Private->PreviousSlot = Index;
        return EFI_SUCCESS;
      }
    }
    return EFI_NOT_FOUND;
  } else if (*Slot == Private->PreviousSlot) {
    for (Index = *Slot + 1; Index < SD_MMC_HC_MAX_SLOT; Index++) {
      if (Private->Slot[Index].Enable) {
        *Slot                 = Index;
        Private->PreviousSlot = Index;
        return EFI_SUCCESS;
      }
    }
    return EFI_NOT_FOUND;
  } else {
    return EFI_INVALID_PARAMETER;
  }
}