[linux-dvb] [PATCH] mxl500x: Add module parameter to enable/disable debug messages

Andy Walls awalls at radix.net
Sat Apr 26 03:59:42 CEST 2008


On Fri, 2008-04-25 at 14:55 +1000, Nick Andrew wrote:
> On Thu, Apr 24, 2008 at 11:16:18PM -0400, Andy Walls wrote:
> > +#define dprintk(level, fmt, arg...)                                       \
> > +	do {                                                              \
> > +		if (debug >= level)                                       \
> > +			printk(KERN_DEBUG "%s: " fmt, "mxl500x", ## arg); \
> > +	} while (0)
> 
> I think this code will be far more useful in kernel/printk.c rather
> than every device driver and subsystem rolling their own (as seems to 
> happen at this time).

Probably.  But I certainly don't have the credentials to move that idea
very far forward. :)

> Also see dev_dbg() and dev_printk() in include/linux/device.h.

I looked at those, since Documentation/Codingstyle mentioned them.  They
reduce right back down to almost the same "printk()" statement used in
the macro above.

If it's any real heartburn for anyone, the printk() in the macro quoted
above could be changed to dev_dbg() with a change of arguments.  I'd
need to scrounge up a "struct dev *" every time the module needs to
print out a debug message though.  It's not very pretty (without another
macro!) to dig that out of state->fe->dvb->device all the time, and it
would be more perturbation than necessary just to squelch the spew into
the kernel ring buffer and logs.


> What those macros are missing is what you have here 

To give credit where credit is due, that macro is a work derived from
the macro in linux/drivers/media/dvb/frontends/xc5000.c, (C) Xceive and
Steven Toth.

> - messages
> printed or ignored depending on the value of a module variable
> and/or parameter.

Yes, dev_dbg() and friends are missing that.  My imagination fails me at
the moment, as how to write a generically useful set of functions, with
that characteristic, that a large subset of the drivers could use.


> Nick.

Thanks for the comments.

Regards,
Andy




More information about the linux-dvb mailing list