Re: [PATCH] [media] lmedm04: Neaten logging

From: Joe Perches
Date: Tue Jun 09 2015 - 19:30:55 EST


On Tue, 2015-06-09 at 19:07 -0300, Mauro Carvalho Chehab wrote:
> Hi Joe,

Marhaba Mauro.

> Em Mon, 25 May 2015 01:29:07 -0700
> Joe Perches <joe@xxxxxxxxxxx> escreveu:
>
> > Use a more current logging style.
> >
> > o Use pr_fmt
> > o Add missing newlines to formats
> > o Remove used-once lme_debug macro incorporating it into dbg_info
> > o Remove unnecessary allocation error messages
> > o Remove unnecessary semicolons from #defines
> > o Remove info macro and convert uses to pr_info
> > o Fix spelling of snippet
> > o Use %phN extension
>
> There are a few checkpatch warnings:

I hardly use checkpatch tbh

The long lines I don't care about, I presume all the others are
existing, but I'll run --fix on it and resubmit if you want.

> > diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
[]
> > /* debug */
> > static int dvb_usb_lme2510_debug;
> > -#define lme_debug(var, level, args...) do { \
> > - if ((var >= level)) \
> > - pr_debug(DVB_USB_LOG_PREFIX": " args); \
> > +#define deb_info(level, fmt, ...) \
> > +do { \
> > + if (dvb_usb_lme2510_debug >= level) \
> > + pr_debug(fmt, ##__VA_ARGS__); \
> > } while (0)
>
>
> The usage of both a debug level and pr_debug() is not nice, as,
> if CONFIG_DYNAMIC_DEBUG is enabled (with is the case on most distros),
> one needing to debug would need to both pass a debug level AND to enable
> the debug line via sysfs, with is not nice.

> We might of course remove debug levels as a hole and just use
> pr_debug(), but the end result is generally worse (didn't chec
> the specifics on this file).
>
> So, the better here would be to use printk like:
>
> #define deb_info(level, fmt, ...)\
> do { if (dvb_usb_lme2510_debug >= level)\
> printk(KERN_DEBUG pr_fmt(fmt), ## arg);\
> } while (0)
>
> Ok, this issue were already present on the old code, but IMHO the
> best is to either use the above definition of deb_info() or to just
> call pr_debug() and get rid of dvb_usb_lme2510_debug.

Alternately, you could #define DEBUG and these would be enabled
by default for CONFIG_DYNAMIC_DEBUG and act the same otherwise.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/