mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-06 02:24:14 +08:00
include/linux/netdevice.h: Add netif_printk helpers
Add macros to test a private structure for msg_enable bits and the netif_msg_##bit to test and call netdev_printk if set Simplifies logic in callers and adds message logging consistency Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ba211e3ec3
commit
b3d95c5c93
@ -2165,6 +2165,59 @@ do { \
|
||||
#define netdev_WARN(dev, format, args...) \
|
||||
WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args);
|
||||
|
||||
/* netif printk helpers, similar to netdev_printk */
|
||||
|
||||
#define netif_printk(priv, type, level, dev, fmt, args...) \
|
||||
do { \
|
||||
if (netif_msg_##type(priv)) \
|
||||
netdev_printk(level, (dev), fmt, ##args); \
|
||||
} while (0)
|
||||
|
||||
#define netif_emerg(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_EMERG, dev, fmt, ##args)
|
||||
#define netif_alert(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_ALERT, dev, fmt, ##args)
|
||||
#define netif_crit(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_CRIT, dev, fmt, ##args)
|
||||
#define netif_err(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_ERR, dev, fmt, ##args)
|
||||
#define netif_warn(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_WARNING, dev, fmt, ##args)
|
||||
#define netif_notice(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_NOTICE, dev, fmt, ##args)
|
||||
#define netif_info(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args)
|
||||
|
||||
#if defined(DEBUG)
|
||||
#define netif_dbg(priv, type, dev, format, args...) \
|
||||
netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
|
||||
#elif defined(CONFIG_DYNAMIC_DEBUG)
|
||||
#define netif_dbg(priv, type, netdev, format, args...) \
|
||||
do { \
|
||||
if (netif_msg_##type(priv)) \
|
||||
dynamic_dev_dbg((netdev)->dev.parent, \
|
||||
"%s: " format, \
|
||||
netdev_name(netdev), ##args); \
|
||||
} while (0)
|
||||
#else
|
||||
#define netif_dbg(priv, type, dev, format, args...) \
|
||||
({ \
|
||||
if (0) \
|
||||
netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
|
||||
0; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#if defined(VERBOSE_DEBUG)
|
||||
#define netif_vdbg netdev_dbg
|
||||
#else
|
||||
#define netif_vdbg(priv, type, dev, format, args...) \
|
||||
({ \
|
||||
if (0) \
|
||||
netif_printk(KERN_DEBUG, dev, format, ##args); \
|
||||
0; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user