/* As the minimum time is 1ms, to save time, we wait ready under 2 step: */
int nor_wait_ready(unsigned int ms, unsigned int times)
/* As the minimum time is 1ms, to save time, we wait ready under 2 step: */
int nor_wait_ready(unsigned int ms, unsigned int times)
{
    unsigned int _ms = ms, _times = times;
    do {
        if (nor_is_busy() == false)
            return 0;
        if (_ms)
            nor_msleep(1);
    } while (--_ms > 0);
    do {
        if (nor_is_busy() == false)
            return 0;
    } while (--_times > 0);
    if (nor_is_busy() == false)
        return 0;
    SPINOR_ERR("wait nor flash for %d ms and %d loop timeout", ms, times);
    return -EBUSY;
}