/* This function is used to check if the CMD/DATA bus is idle or not.  */
s32 XSdPs_CheckBusIdle(XSdPs *InstancePtr, u32 Value)
/* This function is used to check if the CMD/DATA bus is idle or not.  */
s32 XSdPs_CheckBusIdle(XSdPs *InstancePtr, u32 Value)
{
    u32 Timeout = 10000000U;
    u32 PresentStateReg;
    u32 StatusReg;
    s32 Status;
    PresentStateReg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress,
            XSDPS_PRES_STATE_OFFSET);
    if ((PresentStateReg & XSDPS_PSR_CARD_INSRT_MASK) != 0U) {
        do {
            StatusReg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress,
                    XSDPS_PRES_STATE_OFFSET);
            Timeout = Timeout - 1;
            usleep(1);
        } while (((StatusReg & Value) != 0U)
                && (Timeout != 0U));
    }
    if (Timeout == 0U) {
        Status = XST_FAILURE;
        goto RETURN_PATH ;
    }
    Status = XST_SUCCESS;
RETURN_PATH:
    return Status;
}