All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kok, Auke" <auke-jan.h.kok@intel.com>
To: Stephen Hemminger <shemminger@linux-foundation.org>
Cc: netdev@vger.kernel.org, jeff@garzik.org, davem@davemloft.net,
	arjan@linux.intel.com
Subject: Re: [PATCH 1/2] [RFC] NET: Implement a standard ndev_printk family
Date: Fri, 08 Jun 2007 20:06:30 -0700	[thread overview]
Message-ID: <466A1936.7090701@intel.com> (raw)
In-Reply-To: <20070608171040.2b4a2dd7@localhost.localdomain>

Stephen Hemminger wrote:
> On Fri, 08 Jun 2007 16:42:31 -0700
> "Kok, Auke" <auke-jan.h.kok@intel.com> wrote:
> 
>> Stephen Hemminger wrote:
>>>>  
>>>> +#define ndev_printk(kern_level, netif_level, netdev, format, arg...) \
>>>> +	do { if ((netdev)->msg_enable & NETIF_MSG_##netif_level) { \
>>>> +		printk(kern_level "%s: " format, \
>>>> +		(netdev)->name, ## arg); } } while (0)
>>> Could you make a version that doesn't evaluate the arguments twice?
>> hmm you lost me there a bit; Do you want me to duplicate this code for all the 
>> ndev_err/ndev_info functions instead so that ndev_err doesn't direct back to 
>> ndev_printk?
> 
> It is good practice in a macro to avoid potential problems with usage
> by only touching the arguments once. Otherwise, something (bogus) like
> 	ndev_printk(KERN_DEBUG, NETIF_MSG_PKTDATA, "got %d\n",
> 		    dev++, skb->len)
> would increment dev twice.

agreed, but

> My preference would be something more like dev_printk or even use that?
> You want to show both device name, and physical attachment in the message.

actually these ndev_* macros are almost an exact copy of dev_printk, which is 
how I modeled them in the first place!

See for yourself - here's the relevant snipplet from linux/device.h:

500 #define dev_printk(level, dev, format, arg...)  \
501         printk(level "%s %s: " format , dev_driver_string(dev) , 
(dev)->bus_id , ## arg)
502
503 #ifdef DEBUG
504 #define dev_dbg(dev, format, arg...)            \
505         dev_printk(KERN_DEBUG , dev , format , ## arg)
506 #else
507 #define dev_dbg(dev, format, arg...) do { (void)(dev); } while (0)
508 #endif
509
510 #define dev_err(dev, format, arg...)            \
511         dev_printk(KERN_ERR , dev , format , ## arg)
512 #define dev_info(dev, format, arg...)           \
513         dev_printk(KERN_INFO , dev , format , ## arg)
514 #define dev_warn(dev, format, arg...)           \
515         dev_printk(KERN_WARNING , dev , format , ## arg)
516 #define dev_notice(dev, format, arg...)         \
517         dev_printk(KERN_NOTICE , dev , format , ## arg)

using dev_printk however ignores msg_enable completely and also omits 
netdev->name, which may even change, so for netdevices it's much less suitable, 
maybe only at init time.

We can fix the dev_printk macro family as well, that's allright, but the need 
for a netdev-centric printk should be obvious: almost every netdevice driver has 
it's own variant :)

Auke

  reply	other threads:[~2007-06-09  3:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-08 22:00 [PATCH 1/2] [RFC] NET: Implement a standard ndev_printk family Auke Kok
2007-06-08 22:00 ` [PATCH 2/2] [RFC] NET: Convert several drivers to ndev_printk Auke Kok
2007-06-08 23:24 ` [PATCH 1/2] [RFC] NET: Implement a standard ndev_printk family Stephen Hemminger
2007-06-08 23:42   ` Kok, Auke
2007-06-09  0:10     ` Stephen Hemminger
2007-06-09  3:06       ` Kok, Auke [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2007-06-11 21:37 Auke Kok
2007-06-11 21:52 ` 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
2007-06-11 22:04   ` Kok, Auke
2007-06-11 22:19 ` Stephen Hemminger
2007-06-11 22:43   ` 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=466A1936.7090701@intel.com \
    --to=auke-jan.h.kok@intel.com \
    --cc=arjan@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=jeff@garzik.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.