On some architectures (MIPS is a good example), the timebase
rolls over every few seconds. This patch alters the 'sleep'
shell command to use a total counter of the udelay(100)
sleeps instead of an end time marker to determine the end
of the sleep, making the 'sleep' command capable of sleeping
for any number of seconds on all architectures.

Signed-off-by: Jason McMullan <[EMAIL PROTECTED]>
---
 common/cmd_misc.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/common/cmd_misc.c b/common/cmd_misc.c
index 126b538..2b84896 100644
--- a/common/cmd_misc.c
+++ b/common/cmd_misc.c
@@ -29,7 +29,6 @@
 
 int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
-       ulong start = get_timer(0);
        ulong delay;
 
        if (argc != 2) {
@@ -37,13 +36,18 @@ int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char 
*argv[])
                return 1;
        }
 
-       delay = simple_strtoul(argv[1], NULL, 10) * CFG_HZ;
+       /* Sleep in 100ms increments, as some the time base of
+        * some architectures can roll over after only a few
+        * seconds (MIPS is a good example of this)
+        */
+       delay = simple_strtoul(argv[1], NULL, 10) * 10;
 
-       while (get_timer(start) < delay) {
+       while (delay > 0) {
                if (ctrlc ()) {
                        return (-1);
                }
                udelay (100);
+               delay--;
        }
 
        return 0;
-- 
1.5.4.3


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users

Reply via email to