diff options
author | Jim Cromie <jim.cromie@gmail.com> | 2012-04-27 16:30:37 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-04-30 16:24:34 -0400 |
commit | 6ab676e96422f33a873006096f928feeded7ce3b (patch) | |
tree | dbb5ae0912831f528db8cd654ca96a294a5afb33 /lib | |
parent | f0b919d967284313be4a767ba92ab5a88cb27410 (diff) |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dynamic_debug.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 09f2cda88058..3b06f926d5b8 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
@@ -862,39 +862,43 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, | |||
862 | } | 862 | } |
863 | EXPORT_SYMBOL_GPL(ddebug_add_module); | 863 | EXPORT_SYMBOL_GPL(ddebug_add_module); |
864 | 864 | ||
865 | /* handle both dyndbg=".." and $module.dyndbg=".." params at boot */ | 865 | /* helper for ddebug_dyndbg_(boot|module)_param_cb */ |
866 | static int ddebug_dyndbg_boot_param_cb(char *param, char *val, | 866 | static int ddebug_dyndbg_param_cb(char *param, char *val, |
867 | const char *unused) | 867 | const char *modname, int on_err) |
868 | { | 868 | { |
869 | const char *modname = NULL; | ||
870 | char *sep; | 869 | char *sep; |
871 | 870 | ||
872 | sep = strchr(param, '.'); | 871 | sep = strchr(param, '.'); |
873 | if (sep) { | 872 | if (sep) { |
873 | /* needed only for ddebug_dyndbg_boot_param_cb */ | ||
874 | *sep = '\0'; | 874 | *sep = '\0'; |
875 | modname = param; | 875 | modname = param; |
876 | param = sep + 1; | 876 | param = sep + 1; |
877 | } | 877 | } |
878 | if (strcmp(param, "dyndbg")) | 878 | if (strcmp(param, "dyndbg")) |
879 | return 0; /* skip all other params w/o error */ | 879 | return on_err; /* determined by caller */ |
880 | |||
881 | vpr_info("module: %s %s=\"%s\"\n", modname, param, val); | ||
882 | 880 | ||
883 | ddebug_exec_queries(val ? val : "+p"); | 881 | ddebug_exec_queries(val ? val : "+p"); |
884 | return 0; /* query failure shouldnt stop module load */ | 882 | return 0; /* query failure shouldnt stop module load */ |
885 | } | 883 | } |
886 | 884 | ||
887 | /* handle dyndbg args to modprobe */ | 885 | /* handle both dyndbg and $module.dyndbg params at boot */ |
888 | int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *doing) | 886 | static int ddebug_dyndbg_boot_param_cb(char *param, char *val, |
887 | const char *unused) | ||
889 | { | 888 | { |
890 | if (strcmp(param, "dyndbg")) | 889 | vpr_info("%s=\"%s\"\n", param, val); |
891 | return -ENOENT; | 890 | return ddebug_dyndbg_param_cb(param, val, NULL, 0); |
892 | 891 | } | |
893 | vpr_info("module: %s %s=\"%s\"\n", doing, param, val); | ||
894 | |||
895 | ddebug_exec_queries((val ? val : "+p")); | ||
896 | 892 | ||
897 | return 0; /* query failure shouldnt stop module load */ | 893 | /* |
894 | * modprobe foo finds foo.params in boot-args, strips "foo.", and | ||
895 | * passes them to load_module(). This callback gets unknown params, | ||
896 | * processes dyndbg params, rejects others. | ||
897 | */ | ||
898 | int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *module) | ||
899 | { | ||
900 | vpr_info("module: %s %s=\"%s\"\n", module, param, val); | ||
901 | return ddebug_dyndbg_param_cb(param, val, module, -ENOENT); | ||
898 | } | 902 | } |
899 | 903 | ||
900 | static void ddebug_table_free(struct ddebug_table *dt) | 904 | static void ddebug_table_free(struct ddebug_table *dt) |