/* Wait the operation register's bit as specified by Bit to become set (or clear). */
EFI_STATUS EhcWaitOpRegBit(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit, IN BOOLEAN WaitToSet, IN UINT32 Timeout)
/* Wait the operation register's bit as specified by Bit to become set (or clear). */
EFI_STATUS EhcWaitOpRegBit(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit, IN BOOLEAN WaitToSet, IN UINT32 Timeout)
{
  UINT32  Index;
  for (Index = 0; Index < Timeout / EHC_SYNC_POLL_INTERVAL + 1; Index++) {
    if (EHC_REG_BIT_IS_SET (Ehc, Offset, Bit) == WaitToSet) {
      return EFI_SUCCESS;
    }
    gBS->Stall (EHC_SYNC_POLL_INTERVAL);
  }
  return EFI_TIMEOUT;
}