
Dear Nishanth Menon,
In message 4CC6F23A.2040608@ti.com you wrote:
No. This code is always wrong. Please fix it as described.
Apologies on being a dudhead, I suppose you mean the following:
ulong start; start = get_timer(0); while (!(readl(&mmc_base->stat) & CC_MASK)) { if (get_timer(start) > usec2ticks(MAX_RETRY_US)) { printf("%s: timedout waiting for cc2!\n", __func__); return; } }
would this be better?
No, not at all, as get_timer() returns milliseconds, not ticks.
You probably want something like:
ulong start = get_timer(0);
while (!(readl(&mmc_base->stat) & CC_MASK)) { if (get_timer(0) - start >= MAX_RETRY_US/1000) { printf(...); return; } udelay(100); }
or such.
Best regards,
Wolfgang Denk