Commit b8ccd5de authored by Jim Cromie's avatar Jim Cromie Committed by Greg Kroah-Hartman

dynamic_debug: replace if (verbose) pr_info with macro vpr_info

Use vpr_info to declutter code, reduce indenting, and change one
additional pr_info call in ddebug_exec_queries.
Signed-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
Acked-by: default avatarJason Baron <jbaron@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c0a67209
...@@ -107,20 +107,22 @@ static char *ddebug_describe_flags(struct _ddebug *dp, char *buf, ...@@ -107,20 +107,22 @@ static char *ddebug_describe_flags(struct _ddebug *dp, char *buf,
return buf; return buf;
} }
#define vpr_info_dq(q, msg) \ #define vpr_info(fmt, ...) \
do { \ if (verbose) do { pr_info(fmt, ##__VA_ARGS__); } while (0)
if (verbose) \
/* trim last char off format print */ \ #define vpr_info_dq(q, msg) \
pr_info("%s: func=\"%s\" file=\"%s\" " \ do { \
"module=\"%s\" format=\"%.*s\" " \ /* trim last char off format print */ \
"lineno=%u-%u", \ vpr_info("%s: func=\"%s\" file=\"%s\" " \
msg, \ "module=\"%s\" format=\"%.*s\" " \
q->function ? q->function : "", \ "lineno=%u-%u", \
q->filename ? q->filename : "", \ msg, \
q->module ? q->module : "", \ q->function ? q->function : "", \
(int)(q->format ? strlen(q->format) - 1 : 0), \ q->filename ? q->filename : "", \
q->format ? q->format : "", \ q->module ? q->module : "", \
q->first_lineno, q->last_lineno); \ (int)(q->format ? strlen(q->format) - 1 : 0), \
q->format ? q->format : "", \
q->first_lineno, q->last_lineno); \
} while (0) } while (0)
/* /*
...@@ -180,12 +182,11 @@ static int ddebug_change(const struct ddebug_query *query, ...@@ -180,12 +182,11 @@ static int ddebug_change(const struct ddebug_query *query,
if (newflags == dp->flags) if (newflags == dp->flags)
continue; continue;
dp->flags = newflags; dp->flags = newflags;
if (verbose) vpr_info("changed %s:%d [%s]%s =%s\n",
pr_info("changed %s:%d [%s]%s =%s\n", trim_prefix(dp->filename), dp->lineno,
trim_prefix(dp->filename), dp->lineno, dt->mod_name, dp->function,
dt->mod_name, dp->function, ddebug_describe_flags(dp, flagbuf,
ddebug_describe_flags(dp, flagbuf, sizeof(flagbuf)));
sizeof(flagbuf)));
} }
} }
mutex_unlock(&ddebug_lock); mutex_unlock(&ddebug_lock);
...@@ -410,8 +411,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, ...@@ -410,8 +411,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
default: default:
return -EINVAL; return -EINVAL;
} }
if (verbose) vpr_info("op='%c'\n", op);
pr_info("op='%c'\n", op);
for ( ; *str ; ++str) { for ( ; *str ; ++str) {
for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) {
...@@ -423,8 +423,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, ...@@ -423,8 +423,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
if (i < 0) if (i < 0)
return -EINVAL; return -EINVAL;
} }
if (verbose) vpr_info("flags=0x%x\n", flags);
pr_info("flags=0x%x\n", flags);
/* calculate final *flagsp, *maskp according to mask and op */ /* calculate final *flagsp, *maskp according to mask and op */
switch (op) { switch (op) {
...@@ -441,8 +440,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, ...@@ -441,8 +440,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
*flagsp = 0; *flagsp = 0;
break; break;
} }
if (verbose) vpr_info("*flagsp=0x%x *maskp=0x%x\n", *flagsp, *maskp);
pr_info("*flagsp=0x%x *maskp=0x%x\n", *flagsp, *maskp);
return 0; return 0;
} }
...@@ -487,8 +485,7 @@ static int ddebug_exec_queries(char *query) ...@@ -487,8 +485,7 @@ static int ddebug_exec_queries(char *query)
if (!query || !*query || *query == '#') if (!query || !*query || *query == '#')
continue; continue;
if (verbose) vpr_info("query %d: \"%s\"\n", i, query);
pr_info("query %d: \"%s\"\n", i, query);
rc = ddebug_exec_query(query); rc = ddebug_exec_query(query);
if (rc < 0) { if (rc < 0) {
...@@ -498,7 +495,7 @@ static int ddebug_exec_queries(char *query) ...@@ -498,7 +495,7 @@ static int ddebug_exec_queries(char *query)
nfound += rc; nfound += rc;
i++; i++;
} }
pr_info("processed %d queries, with %d matches, %d errs\n", vpr_info("processed %d queries, with %d matches, %d errs\n",
i, nfound, errs); i, nfound, errs);
if (exitcode) if (exitcode)
...@@ -653,8 +650,7 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf, ...@@ -653,8 +650,7 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
return -EFAULT; return -EFAULT;
} }
tmpbuf[len] = '\0'; tmpbuf[len] = '\0';
if (verbose) vpr_info("read %d bytes from userspace\n", (int)len);
pr_info("read %d bytes from userspace\n", (int)len);
ret = ddebug_exec_queries(tmpbuf); ret = ddebug_exec_queries(tmpbuf);
kfree(tmpbuf); kfree(tmpbuf);
...@@ -717,8 +713,7 @@ static void *ddebug_proc_start(struct seq_file *m, loff_t *pos) ...@@ -717,8 +713,7 @@ static void *ddebug_proc_start(struct seq_file *m, loff_t *pos)
struct _ddebug *dp; struct _ddebug *dp;
int n = *pos; int n = *pos;
if (verbose) vpr_info("called m=%p *pos=%lld\n", m, (unsigned long long)*pos);
pr_info("called m=%p *pos=%lld\n", m, (unsigned long long)*pos);
mutex_lock(&ddebug_lock); mutex_lock(&ddebug_lock);
...@@ -742,9 +737,8 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos) ...@@ -742,9 +737,8 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos)
struct ddebug_iter *iter = m->private; struct ddebug_iter *iter = m->private;
struct _ddebug *dp; struct _ddebug *dp;
if (verbose) vpr_info("called m=%p p=%p *pos=%lld\n",
pr_info("called m=%p p=%p *pos=%lld\n", m, p, (unsigned long long)*pos);
m, p, (unsigned long long)*pos);
if (p == SEQ_START_TOKEN) if (p == SEQ_START_TOKEN)
dp = ddebug_iter_first(iter); dp = ddebug_iter_first(iter);
...@@ -766,8 +760,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) ...@@ -766,8 +760,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
struct _ddebug *dp = p; struct _ddebug *dp = p;
char flagsbuf[10]; char flagsbuf[10];
if (verbose) vpr_info("called m=%p p=%p\n", m, p);
pr_info("called m=%p p=%p\n", m, p);
if (p == SEQ_START_TOKEN) { if (p == SEQ_START_TOKEN) {
seq_puts(m, seq_puts(m,
...@@ -791,8 +784,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) ...@@ -791,8 +784,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
*/ */
static void ddebug_proc_stop(struct seq_file *m, void *p) static void ddebug_proc_stop(struct seq_file *m, void *p)
{ {
if (verbose) vpr_info("called m=%p p=%p\n", m, p);
pr_info("called m=%p p=%p\n", m, p);
mutex_unlock(&ddebug_lock); mutex_unlock(&ddebug_lock);
} }
...@@ -815,8 +807,7 @@ static int ddebug_proc_open(struct inode *inode, struct file *file) ...@@ -815,8 +807,7 @@ static int ddebug_proc_open(struct inode *inode, struct file *file)
struct ddebug_iter *iter; struct ddebug_iter *iter;
int err; int err;
if (verbose) vpr_info("called\n");
pr_info("called\n");
iter = kzalloc(sizeof(*iter), GFP_KERNEL); iter = kzalloc(sizeof(*iter), GFP_KERNEL);
if (iter == NULL) if (iter == NULL)
...@@ -866,8 +857,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, ...@@ -866,8 +857,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
list_add_tail(&dt->link, &ddebug_tables); list_add_tail(&dt->link, &ddebug_tables);
mutex_unlock(&ddebug_lock); mutex_unlock(&ddebug_lock);
if (verbose) vpr_info("%u debug prints in module %s\n", n, dt->mod_name);
pr_info("%u debug prints in module %s\n", n, dt->mod_name);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(ddebug_add_module); EXPORT_SYMBOL_GPL(ddebug_add_module);
...@@ -888,8 +878,7 @@ int ddebug_remove_module(const char *mod_name) ...@@ -888,8 +878,7 @@ int ddebug_remove_module(const char *mod_name)
struct ddebug_table *dt, *nextdt; struct ddebug_table *dt, *nextdt;
int ret = -ENOENT; int ret = -ENOENT;
if (verbose) vpr_info("removing module \"%s\"\n", mod_name);
pr_info("removing module \"%s\"\n", mod_name);
mutex_lock(&ddebug_lock); mutex_lock(&ddebug_lock);
list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) { list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment