pr_* versus dev_*
Which set of macros should I use in my driver ?
pr_info, pr_err, etc... or dev_info, dev_err, etc. ?
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..
thank you
~pnesh
Quoted 3 lines · Neshama Parhoti
Which set of macros should I use in my driver ?
pr_info,pr_err, etc... ordev_info,dev_err, etc. ?
Possibly all of them.
Quoted 7 lines
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_infois 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_debugdev_dbgnetdev_dbgnetif_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.
Quoted 51 lines · Joe Perches
Quoted 3 lines · Neshama Parhoti
Which set of macros should I use in my driver ?
pr_info,pr_err, etc... ordev_info,dev_err, etc. ?Possibly all of them.
Quoted 7 lines
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_infois 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 #definepr_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 withpr_fmtdev_<level>: Standardized device information:
dev_driver_string, thendev_namedev_driver_stringis 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> untilalloc_netdevoralloc_etherdevhas been called successfully.
netif_<level>: Test network interface message level (netif_msg_<foo>) before calling netdev_<level>Message logging with
KERN_DEBUGlevels are a bit more complicated:These calls are optimized away and never printed unless DEBUG is #defined or
CONFIG_DYNAMIC_DEBUGis enabled.
pr_debugdev_dbgnetdev_dbgnetif_dbgTo always have these emitted, use the appropriate printk calls
Quoted 8 lines
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_DEBUGThere are _vdbg variants for even more verbose output if
VERBOSE_DEBUGis #defined.
thank you.
so i should use whatever print call that adds most information right ?
even if that means that some part of the driver uses pr_* and some part of the driver use dev_* ?
thank you again
Quoted 2 lines
Quoted 1 line · Neshama Parhoti
so i should use whatever print call that adds most information right ?
I think so.
Quoted 2 lines
even if that means that some part of the driver uses pr_* and some part of the driver use dev_* ?
Yes.
Quoted 11 lines · Joe Perches
Quoted 1 line · Neshama Parhoti
so i should use whatever print call that adds most information right ?
I think so.
Quoted 2 lines
even if that means that some part of the driver uses pr_* and some part of the driver use dev_* ?
Yes.
thank you !