From: Joe Perches <joe@perches.com>
To: Neshama Parhoti <pneshama@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: pr_* versus dev_*
Date: Tue, 30 Mar 2010 09:52:40 -0700 [thread overview]
Message-ID: <1269967960.4558.162.camel@Joe-Laptop.home> (raw)
In-Reply-To: <912ec82a1003300907o7edeb73bp92d56741cfee1064@mail.gmail.com>
On Tue, 2010-03-30 at 19:07 +0300, Neshama Parhoti wrote:
> Which set of macros should I use in my driver ?
>
> pr_info, pr_err, etc... or dev_info, dev_err, etc. ?
Possibly all of them.
> what are the advantages of the dev_* macros over the pr_* macros
> (why does it take the device pointer as an argument) ?
>
> obviously I don't have access to my device pointer in all my functions..
> so pr_info is easier to use..
> but if it's wanted, obviously I can arrange to have my device pointer
> accessible..
You should also use dev_<level> where possible.
You should also use netdev_<level> and netif_<level> if your
device is a networking driver.
You should #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
to have a standard prefix for your driver.
Function Benefit
pr_<level>: Slightly shorter than printk(KERN_<LEVEL>)
Gets a standard prefix with pr_fmt
dev_<level>: Standardized device information:
dev_driver_string, then dev_name
dev_driver_string is the device's driver's name
if it is bound to a device. If the device is not
bound to a device, the name of the bus it is
attached to. If it is not attached to a bus but
has a class, the class name.
If no class, you'll find an empty dance card.
netdev_<level>: Appends struct net_device.name to dev_<level> prefix
Use dev_<level> until alloc_netdev or alloc_etherdev
has been called successfully.
netif_<level>: Test network interface message level (netif_msg_<foo>)
before calling netdev_<level>
Message logging with KERN_DEBUG levels are a bit more complicated:
These calls are optimized away and never printed unless
DEBUG is #defined or CONFIG_DYNAMIC_DEBUG is enabled.
pr_debug
dev_dbg
netdev_dbg
netif_dbg
To always have these emitted, use the appropriate printk calls
printk(KERN_DEBUG this does not get a standard prefix
use printk(KERN_DEBUG pr_fmt(fmt) if desired
dev_printk(KERN_DEBUG
netdev_printk(KERN_DEBUG
netif_printk(priv, msg, KERN_DEBUG
There are _vdbg variants for even more verbose output if
VERBOSE_DEBUG is #defined.
next prev parent reply other threads:[~2010-03-30 16:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-30 16:07 Neshama Parhoti
2010-03-30 16:52 ` Joe Perches [this message]
2010-03-31 5:42 ` Neshama Parhoti
2010-03-31 5:48 ` Joe Perches
2010-03-31 5:57 ` Neshama Parhoti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1269967960.4558.162.camel@Joe-Laptop.home \
--to=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pneshama@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®