Skip to contentSkip to conversation

kernel.h: Add pr_debug_noopt

RFC PATCH In review Joe Perches 2 participants 3 messages Oct 1, 2009

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 kernel.h: Add pr_debug_noopt

Many times a developer always wants to emit a KERN_DEBUG level logging message even if DEBUG is not defined.

These messages today do not have a "pr_<level>" equivalent and must be coded with printk(KERN_DEBUG.

This means that pr_fmt is not used with these logging messages.

I propose a new shortcut #define pr_<level> be added to kernel.h to handle these KERN_DEBUG cases not prefixed with pr_fmt.

I'm not happy with the name. Some good alternatives are already in use in a couple of places.

pr_dbg is #defined in drivers/char/isicom.c pr_vdebug is #defined in drivers/usb/gadget/u_serial.c

I think it's appropriate to remove and substitute one or both of these #defines from the files in drivers and use one or both in kernel.h

Suggestions?

include/linux/kernel.h +2 -0
index d3cd23f..f1f53b9 100644
@@ -380,6 +380,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
         printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
 #define pr_info(fmt, ...) \
         printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_debug_noopt(fmt, ...) \
+	printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
 #define pr_cont(fmt, ...) \
 	printk(KERN_CONT fmt, ##__VA_ARGS__)
 
#1 lore raw
Quoted 28 lines · Joe Perches

Many times a developer always wants to emit a KERN_DEBUG level logging message even if DEBUG is not defined.

These messages today do not have a "pr_<level>" equivalent and must be coded with printk(KERN_DEBUG.

This means that pr_fmt is not used with these logging messages.

I propose a new shortcut #define pr_<level> be added to kernel.h to handle these KERN_DEBUG cases not prefixed with pr_fmt.

I'm not happy with the name. Some good alternatives are already in use in a couple of places.

pr_dbg is #defined in drivers/char/isicom.c pr_vdebug is #defined in drivers/usb/gadget/u_serial.c

I think it's appropriate to remove and substitute one or both of these #defines from the files in drivers and use one or both in kernel.h

Suggestions?

include/linux/kernel.h +0 -0
index d3cd23f..f1f53b9 100644

include/linux/kernel.h static inline char *pack_hex_byte(char *buf, u8 byte) · line 384

Quoted 5 lines
include/linux/kernel.h +2 -0
@@ -380,6 +380,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
         printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
 #define pr_info(fmt, ...) \
         printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_debug_noopt(fmt, ...) \
+	printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)

To me, 'noopt' is too much like 'nop'.

How about 'mand' or 'ungated' or something similar?

In general I like the concept.

David Daney

#2 lore raw
Quoted 11 lines · David Daney

include/linux/kernel.h static inline char *pack_hex_byte(char *buf, u8 byte) · line 384

Quoted 8 lines · Joe Perches
include/linux/kernel.h +2 -0
@@ -380,6 +380,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
         printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
 #define pr_info(fmt, ...) \
         printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_debug_noopt(fmt, ...) \
+	printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)

To me, 'noopt' is too much like 'nop'.

noopt is not ideal. I'd prefer pr_dbg.

Quoted 1 line

How about 'mand' or 'ungated' or something similar?

Maybe pr_debug_always which is just 1 letter longer