mtd: nand: Clarify Kconfig entry for software Hamming ECC entries
[sfrench/cifs-2.6.git] / lib / dynamic_debug.c
index dbf2b457e47e6a688f15d01d16d956fce7520b5b..7bdf98c37e91771079bb06ed584195832d3221f5 100644 (file)
@@ -847,17 +847,19 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
                             const char *name)
 {
        struct ddebug_table *dt;
-       const char *new_name;
 
        dt = kzalloc(sizeof(*dt), GFP_KERNEL);
-       if (dt == NULL)
-               return -ENOMEM;
-       new_name = kstrdup_const(name, GFP_KERNEL);
-       if (new_name == NULL) {
-               kfree(dt);
+       if (dt == NULL) {
+               pr_err("error adding module: %s\n", name);
                return -ENOMEM;
        }
-       dt->mod_name = new_name;
+       /*
+        * For built-in modules, name lives in .rodata and is
+        * immortal. For loaded modules, name points at the name[]
+        * member of struct module, which lives at least as long as
+        * this struct ddebug_table.
+        */
+       dt->mod_name = name;
        dt->num_ddebugs = n;
        dt->ddebugs = tab;
 
@@ -868,7 +870,6 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
        vpr_info("%u debug prints in module %s\n", n, dt->mod_name);
        return 0;
 }
-EXPORT_SYMBOL_GPL(ddebug_add_module);
 
 /* helper for ddebug_dyndbg_(boot|module)_param_cb */
 static int ddebug_dyndbg_param_cb(char *param, char *val,
@@ -913,7 +914,6 @@ int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *module)
 static void ddebug_table_free(struct ddebug_table *dt)
 {
        list_del_init(&dt->link);
-       kfree_const(dt->mod_name);
        kfree(dt);
 }
 
@@ -930,15 +930,15 @@ int ddebug_remove_module(const char *mod_name)
 
        mutex_lock(&ddebug_lock);
        list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) {
-               if (!strcmp(dt->mod_name, mod_name)) {
+               if (dt->mod_name == mod_name) {
                        ddebug_table_free(dt);
                        ret = 0;
+                       break;
                }
        }
        mutex_unlock(&ddebug_lock);
        return ret;
 }
-EXPORT_SYMBOL_GPL(ddebug_remove_module);
 
 static void ddebug_remove_all_tables(void)
 {