lkml.org 
[lkml]   [2012]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 09/16] dynamic_debug: combine parse_args callbacks together
    Date
    From: Jim Cromie <jim.cromie@gmail.com>

    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.

    Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
    ---
    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 a3ab3bd..baff763 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,
    }
    EXPORT_SYMBOL_GPL(ddebug_add_module);

    -/* handle both dyndbg=".." and $module.dyndbg=".." params at boot */
    -static int ddebug_dyndbg_boot_param_cb(char *param, char *val,
    - const char *unused)
    +/* helper for ddebug_dyndbg_(boot|module)_param_cb */
    +static int ddebug_dyndbg_param_cb(char *param, char *val,
    + const char *modname, int on_err)
    {
    - const char *modname = NULL;
    char *sep;

    sep = strchr(param, '.');
    if (sep) {
    + /* needed only for ddebug_dyndbg_boot_param_cb */
    *sep = '\0';
    modname = param;
    param = sep + 1;
    }
    if (strcmp(param, "dyndbg"))
    - return 0; /* skip all other params w/o error */
    -
    - vpr_info("module: %s %s=\"%s\"\n", modname, param, val);
    + return on_err; /* determined by caller */

    ddebug_exec_queries(val ? val : "+p");
    return 0; /* query failure shouldnt stop module load */
    }

    -/* handle dyndbg args to modprobe */
    -int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *doing)
    +/* handle both dyndbg and $module.dyndbg params at boot */
    +static int ddebug_dyndbg_boot_param_cb(char *param, char *val,
    + const char *unused)
    {
    - if (strcmp(param, "dyndbg"))
    - return -ENOENT;
    -
    - vpr_info("module: %s %s=\"%s\"\n", doing, param, val);
    -
    - ddebug_exec_queries((val ? val : "+p"), doing);
    + vpr_info("%s=\"%s\"\n", param, val);
    + return ddebug_dyndbg_param_cb(param, val, NULL, 0);
    +}

    - return 0; /* query failure shouldnt stop module load */
    +/*
    + * modprobe foo finds foo.params in boot-args, strips "foo.", and
    + * passes them to load_module(). This callback gets unknown params,
    + * processes dyndbg params, rejects others.
    + */
    +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)
    --
    1.7.7.6


    \
     
     \ /
      Last update: 2012-03-26 01:31    [W:0.026 / U:1.860 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site