Re: [PATCH 25/26] dynamic_debug: add pr_fmt_dbg() fordynamic_pr_debug

From: Joe Perches
Date: Tue Sep 27 2011 - 19:36:33 EST


On Tue, 2011-09-27 at 14:37 -0600, Jim Cromie wrote:
> On Thu, Sep 22, 2011 at 2:57 PM, Joe Perches <joe@xxxxxxxxxxx> wrote:
> > On Wed, 2011-09-21 at 15:55 -0600, jim.cromie@xxxxxxxxx wrote:
> >> dynamic_pr_debug can add module, function, file, and line selectively,
> > []
> >> diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
> > []
> >> +#ifndef pr_fmt_dbg
> >> +#define pr_fmt_dbg(fmt) fmt
> >> +#endif
> > []
> >> +#ifndef pr_fmt_dbg
> >> +#define pr_fmt_dbg(fmt) pr_fmt(fmt)
> >> +#endif
> >
> > This might better be placed in printk.h just
> > once.
> >
>
> yes. it seems to work smoothly.
> Only minor annoyance is having to put local defns
> above the #includes, but thats no different than previously.
>
>
> > I think pr_fmt_debug is better than pr_fmt_dbg
> > because the function/macro is named pr_debug.
>
> Ok. Done.
>
> > Maybe add all the pr_<level> variants too because
> > some like to prefix __func__ to pr_err but not pr_info
> > etc.
> >
>
> Done. Only wrinkle is wrt pr_warning() vs pr_warn()
> I added to your suggestion:
> +#define pr_fmt_warn pr_fmt_warning
>
> the imperfection is that user has 4 combos of warn/warning
> rather than 2 pairs, but the latter seems less defensible.

I'd just use pr_fmt_warn.

Instead of all this other extra stuff:

What did you think of avoiding all of this and
having __dynamic_pr_debug move the fmt pointer over
any initial KBUILD_MODULE ": "

int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
{
[...]
size_t modsize = strlen(descriptor->modname);
if (0 == strncmp(fmt, descriptor->modname, modsize) &&
0 == strncmp(fmt + modsize, ": ", 2))
fmt += modsize + 2;

vprintk(fmt, ...)

?

--
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/