lkml.org 
[lkml]   [2009]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/7] printk: move the printing of the loglevel tag into a separate function
Date
This is preparation only; it does not change any behaviour.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
---
kernel/printk.c | 48 ++++++++++++++++++++++++++----------------------
1 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index 9d3d594..69f717a 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -667,6 +667,30 @@ static inline void printk_delay(void)
}
}

+static void printk_token(int log_level)
+{
+ emit_log_char('<');
+ emit_log_char(log_level + '0');
+ emit_log_char('>');
+
+ 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);
+ }
+}
+
asmlinkage int vprintk(const char *fmt, va_list args)
{
int message_len = 0;
@@ -744,30 +768,10 @@ asmlinkage int vprintk(const char *fmt, va_list args)
*/
for ( ; *p; p++) {
if (new_text_line) {
- /* Always output the token */
- emit_log_char('<');
- emit_log_char(current_log_level + '0');
- emit_log_char('>');
- 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;
- }
+ /* Always output the token */
+ printk_token(current_log_level);

if (!*p)
break;
--
1.6.3.2


\
 
 \ /
  Last update: 2009-10-07 10:59    [W:0.151 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site