motivation behind pr_xxx macros

Mulyadi Santosa mulyadi.santosa at
Sun Jan 30 13:19:43 EST 2011


On Sun, Jan 30, 2011 at 22:11, Himanshu Aggarwal
<lkml.himanshu at> wrote:
> While writing some code on 2.6.32, I have come across some of these
> macros that in turn call printk:
> pr_emerg
> pr_alert
> ...
> pr_debug
> Is there any case when should these macros be preferred over explicit
> printk statements?

I personally think it's a matter of "putting another layer of
abstraction". That way, if somehow the definition of...let's "emerg"
facility differ, you don't need to change the whole code. Just edit
the pr_emerg and you're back into the game.

IIRC too, it might have something to do with dynamic printk
activation...something like "ok I need to turn that, that and that
printk...on...". So to ease that thing, wrapper is created ...and it
decide what it has to do when printk() is enabled or not.


Mulyadi Santosa
Freelance Linux trainer and consultant


More information about the Kernelnewbies mailing list