dynamic_debug: combine parse_args callbacks together
Refactor ddebug_dyndbg_boot_param_cb and ddebug_dyndbg_module_param_cb into a common helper function, and call it from both. The handling of foo.dyndbg is unneeded by the latter, but harmless. The 2 callers differ only by pr_info and the return code they pass to the helper for when an unknown param is handled. I could slightly reduce dmesg clutter by putting the vpr_info in the common helper, after the return on_err, but that loses __func__ context, is overly silent on module_cb unknown param errors, and the clutter is only when dynamic_debug.verbose=1 anyway. Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Acked-by: Jason Baron <jbaron@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f0b919d967
commit
6ab676e964
|
@ -862,39 +862,43 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(ddebug_add_module);
|
EXPORT_SYMBOL_GPL(ddebug_add_module);
|
||||||
|
|
||||||
/* handle both dyndbg=".." and $module.dyndbg=".." params at boot */
|
/* helper for ddebug_dyndbg_(boot|module)_param_cb */
|
||||||
static int ddebug_dyndbg_boot_param_cb(char *param, char *val,
|
static int ddebug_dyndbg_param_cb(char *param, char *val,
|
||||||
const char *unused)
|
const char *modname, int on_err)
|
||||||
{
|
{
|
||||||
const char *modname = NULL;
|
|
||||||
char *sep;
|
char *sep;
|
||||||
|
|
||||||
sep = strchr(param, '.');
|
sep = strchr(param, '.');
|
||||||
if (sep) {
|
if (sep) {
|
||||||
|
/* needed only for ddebug_dyndbg_boot_param_cb */
|
||||||
*sep = '\0';
|
*sep = '\0';
|
||||||
modname = param;
|
modname = param;
|
||||||
param = sep + 1;
|
param = sep + 1;
|
||||||
}
|
}
|
||||||
if (strcmp(param, "dyndbg"))
|
if (strcmp(param, "dyndbg"))
|
||||||
return 0; /* skip all other params w/o error */
|
return on_err; /* determined by caller */
|
||||||
|
|
||||||
vpr_info("module: %s %s=\"%s\"\n", modname, param, val);
|
|
||||||
|
|
||||||
ddebug_exec_queries(val ? val : "+p");
|
ddebug_exec_queries(val ? val : "+p");
|
||||||
return 0; /* query failure shouldnt stop module load */
|
return 0; /* query failure shouldnt stop module load */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle dyndbg args to modprobe */
|
/* handle both dyndbg and $module.dyndbg params at boot */
|
||||||
int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *doing)
|
static int ddebug_dyndbg_boot_param_cb(char *param, char *val,
|
||||||
|
const char *unused)
|
||||||
{
|
{
|
||||||
if (strcmp(param, "dyndbg"))
|
vpr_info("%s=\"%s\"\n", param, val);
|
||||||
return -ENOENT;
|
return ddebug_dyndbg_param_cb(param, val, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
vpr_info("module: %s %s=\"%s\"\n", doing, param, val);
|
/*
|
||||||
|
* modprobe foo finds foo.params in boot-args, strips "foo.", and
|
||||||
ddebug_exec_queries((val ? val : "+p"));
|
* passes them to load_module(). This callback gets unknown params,
|
||||||
|
* processes dyndbg params, rejects others.
|
||||||
return 0; /* query failure shouldnt stop module load */
|
*/
|
||||||
|
int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *module)
|
||||||
|
{
|
||||||
|
vpr_info("module: %s %s=\"%s\"\n", module, param, val);
|
||||||
|
return ddebug_dyndbg_param_cb(param, val, module, -ENOENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ddebug_table_free(struct ddebug_table *dt)
|
static void ddebug_table_free(struct ddebug_table *dt)
|
||||||
|
|
Loading…
Reference in New Issue