All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] Make sleep shell command is reliable for all architectures
@ 2008-05-20 13:57 Jason McMullan
  2008-05-20 14:23 ` Wolfgang Denk
  0 siblings, 1 reply; 5+ messages in thread
From: Jason McMullan @ 2008-05-20 13:57 UTC (permalink / raw)
  To: u-boot

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 <mcmullan@netapp.com>
---
 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-05-20 18:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-20 13:57 [U-Boot-Users] [PATCH] Make sleep shell command is reliable for all architectures Jason McMullan
2008-05-20 14:23 ` Wolfgang Denk
2008-05-20 15:05   ` [U-Boot-Users] [PATCH] Make sleep shell command is reliablefor " McMullan, Jason
2008-05-20 15:24     ` Scott Wood
2008-05-20 18:42     ` Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.