aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2010-02-09 06:49:49 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-12 16:27:45 -0500
commitb3d95c5c93d4b57eaea0ad3f582b08a6b5fb3eb1 (patch)
tree3dc48783dc30ed1769b3a50c18861eadd2b67136 /include/linux/netdevice.h
parentba211e3ec35820eced89bfe12e2d94e6352a4c5f (diff)
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>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index a51228ac9331..1412dde16d00 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2165,6 +2165,59 @@ do { \
2165#define netdev_WARN(dev, format, args...) \ 2165#define netdev_WARN(dev, format, args...) \
2166 WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args); 2166 WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args);
2167 2167
2168/* netif printk helpers, similar to netdev_printk */
2169
2170#define netif_printk(priv, type, level, dev, fmt, args...) \
2171do { \
2172 if (netif_msg_##type(priv)) \
2173 netdev_printk(level, (dev), fmt, ##args); \
2174} while (0)
2175
2176#define netif_emerg(priv, type, dev, fmt, args...) \
2177 netif_printk(priv, type, KERN_EMERG, dev, fmt, ##args)
2178#define netif_alert(priv, type, dev, fmt, args...) \
2179 netif_printk(priv, type, KERN_ALERT, dev, fmt, ##args)
2180#define netif_crit(priv, type, dev, fmt, args...) \
2181 netif_printk(priv, type, KERN_CRIT, dev, fmt, ##args)
2182#define netif_err(priv, type, dev, fmt, args...) \
2183 netif_printk(priv, type, KERN_ERR, dev, fmt, ##args)
2184#define netif_warn(priv, type, dev, fmt, args...) \
2185 netif_printk(priv, type, KERN_WARNING, dev, fmt, ##args)
2186#define netif_notice(priv, type, dev, fmt, args...) \
2187 netif_printk(priv, type, KERN_NOTICE, dev, fmt, ##args)
2188#define netif_info(priv, type, dev, fmt, args...) \
2189 netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args)
2190
2191#if defined(DEBUG)
2192#define netif_dbg(priv, type, dev, format, args...) \
2193 netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
2194#elif defined(CONFIG_DYNAMIC_DEBUG)
2195#define netif_dbg(priv, type, netdev, format, args...) \
2196do { \
2197 if (netif_msg_##type(priv)) \
2198 dynamic_dev_dbg((netdev)->dev.parent, \
2199 "%s: " format, \
2200 netdev_name(netdev), ##args); \
2201} while (0)
2202#else
2203#define netif_dbg(priv, type, dev, format, args...) \
2204({ \
2205 if (0) \
2206 netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
2207 0; \
2208})
2209#endif
2210
2211#if defined(VERBOSE_DEBUG)
2212#define netif_vdbg netdev_dbg
2213#else
2214#define netif_vdbg(priv, type, dev, format, args...) \
2215({ \
2216 if (0) \
2217 netif_printk(KERN_DEBUG, dev, format, ##args); \
2218 0; \
2219})
2220#endif
2168 2221
2169#endif /* __KERNEL__ */ 2222#endif /* __KERNEL__ */
2170 2223