From: Randy Dunlap <randy.dunlap@oracle.com>
To: Auke Kok <auke-jan.h.kok@intel.com>
Cc: netdev@vger.kernel.org, jeff@garzik.org, davem@davemloft.net,
arjan@linux.intel.com, joe@perches.com,
shemminger@linux-foundation.org
Subject: Re: [PATCH 1/2] [RFC] NET: Implement a standard ndev_printk family
Date: Mon, 11 Jun 2007 15:00:37 -0700 [thread overview]
Message-ID: <20070611150037.34a33f43.randy.dunlap@oracle.com> (raw)
In-Reply-To: <20070611213721.23014.4812.stgit@localhost.localdomain>
On Mon, 11 Jun 2007 14:37:21 -0700 Auke Kok wrote:
> include/linux/netdevice.h | 38 ++++++++++++++++++++++++++++++++++++++
> net/core/dev.c | 5 +++++
> net/core/ethtool.c | 14 +++++++-------
> 3 files changed, 50 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 3a70f55..d185f41 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -540,6 +540,8 @@ struct net_device
> struct device dev;
> /* space for optional statistics and wireless sysfs groups */
> struct attribute_group *sysfs_groups[3];
> +
> + int msg_enable;
> };
> #define to_net_dev(d) container_of(d, struct net_device, dev)
>
> @@ -838,6 +840,42 @@ enum {
> NETIF_MSG_WOL = 0x4000,
> };
>
> +#define ndev_err(netdev, level, format, arg...) \
> + do { if ((netdev)->msg_enable & NETIF_MSG_##level) { \
> + printk(KERN_ERR "%s: %s: " format, (netdev)->name, \
> + (netdev)->dev.parent->bus_id, ## arg); } } while (0)
> +
I would still do what Steve H. suggested, i.e., only evaluate
macro args one time. E.g. (not tested & reformatted :)
+#define ndev_err(netdev, level, format, arg...) \
+ do { \
+ struct net_device *__nd = netdev; \
+ if ((__nd)->msg_enable & NETIF_MSG_##level) \
+ printk(KERN_ERR "%s: %s: " format, (__nd)->name, \
+ (__nd)->dev.parent->bus_id, ## arg); \
+ } while (0)
+
Dropping the braces around the printk() too.
etc...
> +#define ndev_warn(netdev, level, format, arg...) \
> + do { if ((netdev)->msg_enable & NETIF_MSG_##level) { \
> + printk(KERN_WARNING "%s: %s: " format, (netdev)->name, \
> + (netdev)->dev.parent->bus_id, ## arg); } } while (0)
> +
> +#define ndev_notice(netdev, level, format, arg...) \
> + do { if ((netdev)->msg_enable & NETIF_MSG_##level) { \
> + printk(KERN_NOTICE "%s: %s: " format, (netdev)->name, \
> + (netdev)->dev.parent->bus_id, ## arg); } } while (0)
> +
> +#define ndev_info(netdev, level, format, arg...) \
> + do { if ((netdev)->msg_enable & NETIF_MSG_##level) { \
> + printk(KERN_INFO "%s: %s: " format, (netdev)->name, \
> + (netdev)->dev.parent->bus_id, ## arg); } } while (0)
> +
> +#ifdef DEBUG
> +#define ndev_debug(netdev, level, format, arg...) \
> + do { if ((netdev)->msg_enable & NETIF_MSG_##level) { \
> + printk(KERN_DEBUG "%s: %s: " format, (netdev)->name, \
> + (netdev)->dev.parent->bus_id, ## arg); } } while (0)
> +#else
> +/* Force type-checking on ndev_dbg() when DEBUG is not set */
> +static inline int __attribute__ ((format (printf, 3, 4)))
> +__ndev_dbg(struct net_device * netdev, u32 level, const char *format, ...)
> +{
> + return 0;
> +}
> +#define ndev_dbg(netdev, level, fmt, args...) \
> + __ndev_dbg(netdev, NETIF_MSG_##level, fmt, ##args)
> +#endif
> +
> #define netif_msg_drv(p) ((p)->msg_enable & NETIF_MSG_DRV)
> #define netif_msg_probe(p) ((p)->msg_enable & NETIF_MSG_PROBE)
> #define netif_msg_link(p) ((p)->msg_enable & NETIF_MSG_LINK)
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
next prev parent reply other threads:[~2007-06-11 22:02 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-11 21:37 [PATCH 1/2] [RFC] NET: Implement a standard ndev_printk family Auke Kok
2007-06-11 21:37 ` [PATCH 2/2] [RFC] NET: Convert several drivers to ndev_printk Auke Kok
2007-06-11 21:52 ` [PATCH 1/2] [RFC] NET: Implement a standard ndev_printk family Kok, Auke
2007-06-11 21:54 ` Joe Perches
2007-06-11 22:01 ` Kok, Auke
2007-06-11 22:24 ` Joe Perches
2007-06-11 22:00 ` Randy Dunlap [this message]
2007-06-11 22:04 ` Kok, Auke
2007-06-11 22:19 ` Stephen Hemminger
2007-06-11 22:43 ` Kok, Auke
-- strict thread matches above, loose matches on Subject: below --
2007-06-08 22:00 Auke Kok
2007-06-08 23:24 ` Stephen Hemminger
2007-06-08 23:42 ` Kok, Auke
2007-06-09 0:10 ` Stephen Hemminger
2007-06-09 3:06 ` Kok, Auke
2007-06-09 3:18 ` Kok, Auke
2007-06-11 17:30 ` Kok, Auke
2007-06-11 17:50 ` Stephen Hemminger
2007-06-11 18:28 ` Joe Perches
2007-06-11 20:28 ` Kok, Auke
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=20070611150037.34a33f43.randy.dunlap@oracle.com \
--to=randy.dunlap@oracle.com \
--cc=arjan@linux.intel.com \
--cc=auke-jan.h.kok@intel.com \
--cc=davem@davemloft.net \
--cc=jeff@garzik.org \
--cc=joe@perches.com \
--cc=netdev@vger.kernel.org \
--cc=shemminger@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).