On 26.10.2010 18:26, Wolfgang Denk wrote: > Dear Nishanth Menon, > > In message<4cc6f23a.2040...@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); > }
This will work, of course, but the original semantics of get_timer() seems to be: ulong start = get_timer(0); loop { if (get_timer(start) >= timeout_in_ms) we_have_timeout(); } --> get_timer(x) returns (time - x) the subtraction is done internally. Reinhard _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot