[U-Boot] [PATCH v1 (WIP) 09/16] [Timer]Replace get_timer() usage in drivers/block/
Simon Glass
sjg at chromium.org
Wed Jun 29 06:40:59 CEST 2011
Hi Graeme,
On Tue, Jun 28, 2011 at 4:41 AM, Graeme Russ <graeme.russ at gmail.com> wrote:
>
> Signed-off-by: Graeme Russ <graeme.russ at gmail.com>
> ---
> drivers/block/mg_disk.c | 9 ++++-----
> 1 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
> index 2198017..c8cc195 100644
> --- a/drivers/block/mg_disk.c
> +++ b/drivers/block/mg_disk.c
> @@ -88,17 +88,16 @@ static void mg_dump_status (const char *msg, unsigned int stat, unsigned err)
> static unsigned int mg_wait (u32 expect, u32 msec)
> {
> u8 status;
> - u32 from, cur, err;
> + u32 ts, err;
>
> err = MG_ERR_NONE;
> #ifdef CONFIG_NIOS2
> reset_timer();
> #endif
> - from = get_timer(0);
> + ts = time_now_ms();
>
> status = readb(mg_base() + MG_REG_STATUS);
> do {
> - cur = get_timer(from);
...
> - } while (cur < msec);
> + } while (time_since_ms(ts) < msec);
>
Well I know i have asked this before, but I feel I should ask again
because I didn't like the answer much.
Imagine we change this code to:
ts = time_now_ms() + msec
do {
...
} while (time_since_ms(ts) < 0);
That should be legal, right? But I don't think this can work since the
'since' functions return an unsigned.
[aside: this provides for another idiom that I think we talked about:
ts = time_future_ms(msec)
do {
...
} while (!time_passed(ts))
which I am not at all suggesting should be in the API :-)
end aside]
Regards.
Simon
> - if (cur >= msec)
> + if (time_since_ms(ts) >= msec)
> err = MG_ERR_TIMEOUT;
>
> return err;
> --
> 1.7.5.2.317.g391b14
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
More information about the U-Boot
mailing list