Skip to contentSkip to conversation

adds ndelay function (just like udelay)

PATCH New eran.liberty at gmail.com 2 participants 2 messages Jul 3, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 adds ndelay function (just like udelay)

Though most cpu's do not support delay of such resolution it is prudent to insert this delay where the hardware specs demands it.

time.c +10 -1
Index: lib_ppc/time.c
===================================================================
@@ -53,8 +53,17 @@
  */
 void udelay(unsigned long usec)
 {
-	ulong ticks = usec2ticks (usec);
+	ulong ticks = usec2ticks(usec);
 
+	wait_ticks(ticks);
+}
+
+/* ------------------------------------------------------------------------- */
+
+void ndelay (unsigned long nsec)
+{
+	ulong ticks = usec2ticks (1) * nsec / 1000 + 1;
+
 	wait_ticks (ticks);
 }
 
exports.h +1 -0
Index: include/exports.h
===================================================================
@@ -17,6 +17,7 @@
 void *malloc(size_t);
 void free(void*);
 void udelay(unsigned long);
+void ndelay(unsigned long);
 unsigned long get_timer(unsigned long);
 void vprintf(const char *, va_list);
 void do_reset (void);
common.h +1 -0
Index: include/common.h
===================================================================
@@ -559,6 +559,7 @@
 
 /* lib_$(ARCH)/time.c */
 void	udelay	      (unsigned long);
+void ndelay(unsigned long);
 ulong	usec2ticks    (unsigned long usec);
 ulong	ticks2usec    (unsigned long ticks);
 int	init_timebase (void);
#1 lore raw

PATCH 1/1 adds ndelay function (just like udelay)

Quoted 4 lines · eran.liberty at gmail.com

Though most cpu's do not support delay of such resolution it is prudent to insert this delay where the hardware specs demands it.

Yeah, okay. Looks pretty benign, but could cause confusion when high resolution delays are not available.

Cheers,
g.

Signature · 4 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
grant.likely at secretlab.ca
(403) 399-0195