Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: General #define DVB_DEBUG ?



Patrick Boettcher wrote:
> 
> is there something like this? if not, would it make sense to introduce it?
> 
> In my dib*-drivers I used it to avoid the hundred's of debug-calls to be
> compiled in. I'm not a compiler expert, so I can't estimate the effort a
> running module has to do a lot of unnecessary 'if (debug)
> dprintk(...);'s. Because most of the normal users won't turn on debugging
> as they only want to use it and if they really want debug, they should use
> dvb-kernel to get the latest versions. Am I wrong ?

Well, there is no common method for debug output in the drivers, each
one does it a little bit different.

IMHO it makes sense to split debug output into hardcore developer
only stuff, enabled at compile time, and debug stuff which
is potentially useful for users, which can be enabled via a module
option. It's up to you to decide.

Usually we have something like:

  #ifdef DEBUG
  #define dprintk(args...) do { printk(args); } while (0)
  #else
  #define dprintk(args...) do { } while (0)
  #endif

or

  static int debug;
  module_param(debug, int, 0644);
  #define dprintk(args...) do { if (debug) printk(args); } while (0)

or you can have debug be a bitset or a verbosity level...
(sometimes we also have eprintk, iprintk etc., and MiHu
likes DEB_EE, DEB_D &c)

(BTW, 'if (debug) dprintk(...);' is double foobar.)

Johannes




Home | Main Index | Thread Index