lkml.org 
[lkml]   [2011]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 4/6] printk: Break out printk_time
Clean up printk_time by making it a separate function.

Signed-off-by: Mike Travis <travis@sgi.com>
---
kernel/printk.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)

--- linux.orig/kernel/printk.c
+++ linux/kernel/printk.c
@@ -726,6 +726,24 @@ static inline void printk_delay(void)
}
}

+/* Follow the token with the time */
+static inline int printk_emit_time(void)
+{
+ char tbuf[50], *tp;
+ unsigned tlen;
+ unsigned long long t;
+ unsigned long microsec_rem;
+
+ t = cpu_clock(printk_cpu);
+ microsec_rem = do_div(t, 1000000000) / 1000;
+ tlen = sprintf(tbuf, "[%5lu.%06lu] ", (unsigned long)t, microsec_rem);
+
+ for (tp = tbuf; tp < tbuf + tlen; tp++)
+ emit_log_char(*tp);
+
+ return tlen;
+}
+
asmlinkage int vprintk(const char *fmt, va_list args)
{
int printed_len = 0;
@@ -810,23 +828,9 @@ asmlinkage int vprintk(const char *fmt,
printed_len += 3;
new_text_line = 0;

- if (printk_time) {
- /* Follow the token with the time */
- char tbuf[50], *tp;
- unsigned tlen;
- unsigned long long t;
- unsigned long nanosec_rem;
-
- t = cpu_clock(printk_cpu);
- nanosec_rem = do_div(t, 1000000000);
- tlen = sprintf(tbuf, "[%5lu.%06lu] ",
- (unsigned long) t,
- nanosec_rem / 1000);
-
- for (tp = tbuf; tp < tbuf + tlen; tp++)
- emit_log_char(*tp);
- printed_len += tlen;
- }
+ /* add time if requested */
+ if (printk_time)
+ printed_len += printk_emit_time();

if (!*p)
break;
--


\
 
 \ /
  Last update: 2011-02-19 03:49    [W:0.184 / U:0.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site