]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/module.c
fix struct user_info export's sysfs interaction
[linux-2.6-omap-h63xx.git] / kernel / module.c
index 91fe6958b6e1b253f98c2ab08518693df00a1497..d03fcd9d652cd78523c559cc53d2929ee405727d 100644 (file)
@@ -47,8 +47,6 @@
 #include <asm/cacheflush.h>
 #include <linux/license.h>
 
-extern int module_sysfs_initialized;
-
 #if 0
 #define DEBUGP printk
 #else
@@ -1122,7 +1120,7 @@ static void add_notes_attrs(struct module *mod, unsigned int nsect,
                ++loaded;
        }
 
-       notes_attrs->dir = kobject_add_dir(&mod->mkobj.kobj, "notes");
+       notes_attrs->dir = kobject_create_and_add("notes", &mod->mkobj.kobj);
        if (!notes_attrs->dir)
                goto out;
 
@@ -1223,7 +1221,8 @@ int mod_sysfs_init(struct module *mod)
        err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->name);
        if (err)
                goto out;
-       kobj_set_kset_s(&mod->mkobj, module_subsys);
+       mod->mkobj.kobj.kset = module_kset;
+       mod->mkobj.kobj.ktype = &module_ktype;
        mod->mkobj.mod = mod;
 
        kobject_init(&mod->mkobj.kobj);
@@ -1243,7 +1242,7 @@ int mod_sysfs_setup(struct module *mod,
        if (err)
                goto out;
 
-       mod->holders_dir = kobject_add_dir(&mod->mkobj.kobj, "holders");
+       mod->holders_dir = kobject_create_and_add("holders", &mod->mkobj.kobj);
        if (!mod->holders_dir) {
                err = -ENOMEM;
                goto out_unreg;
@@ -2214,29 +2213,34 @@ static const char *get_ksymbol(struct module *mod,
 /* For kallsyms to ask for address resolution.  NULL means not found.
    We don't lock, as this is used for oops resolution and races are a
    lesser concern. */
+/* FIXME: Risky: returns a pointer into a module w/o lock */
 const char *module_address_lookup(unsigned long addr,
                                  unsigned long *size,
                                  unsigned long *offset,
                                  char **modname)
 {
        struct module *mod;
+       const char *ret = NULL;
 
+       preempt_disable();
        list_for_each_entry(mod, &modules, list) {
                if (within(addr, mod->module_init, mod->init_size)
                    || within(addr, mod->module_core, mod->core_size)) {
                        if (modname)
                                *modname = mod->name;
-                       return get_ksymbol(mod, addr, size, offset);
+                       ret = get_ksymbol(mod, addr, size, offset);
+                       break;
                }
        }
-       return NULL;
+       preempt_enable();
+       return ret;
 }
 
 int lookup_module_symbol_name(unsigned long addr, char *symname)
 {
        struct module *mod;
 
-       mutex_lock(&module_mutex);
+       preempt_disable();
        list_for_each_entry(mod, &modules, list) {
                if (within(addr, mod->module_init, mod->init_size) ||
                    within(addr, mod->module_core, mod->core_size)) {
@@ -2246,12 +2250,12 @@ int lookup_module_symbol_name(unsigned long addr, char *symname)
                        if (!sym)
                                goto out;
                        strlcpy(symname, sym, KSYM_NAME_LEN);
-                       mutex_unlock(&module_mutex);
+                       preempt_enable();
                        return 0;
                }
        }
 out:
-       mutex_unlock(&module_mutex);
+       preempt_enable();
        return -ERANGE;
 }
 
@@ -2260,7 +2264,7 @@ int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size,
 {
        struct module *mod;
 
-       mutex_lock(&module_mutex);
+       preempt_disable();
        list_for_each_entry(mod, &modules, list) {
                if (within(addr, mod->module_init, mod->init_size) ||
                    within(addr, mod->module_core, mod->core_size)) {
@@ -2273,12 +2277,12 @@ int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size,
                                strlcpy(modname, mod->name, MODULE_NAME_LEN);
                        if (name)
                                strlcpy(name, sym, KSYM_NAME_LEN);
-                       mutex_unlock(&module_mutex);
+                       preempt_enable();
                        return 0;
                }
        }
 out:
-       mutex_unlock(&module_mutex);
+       preempt_enable();
        return -ERANGE;
 }
 
@@ -2287,7 +2291,7 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
 {
        struct module *mod;
 
-       mutex_lock(&module_mutex);
+       preempt_disable();
        list_for_each_entry(mod, &modules, list) {
                if (symnum < mod->num_symtab) {
                        *value = mod->symtab[symnum].st_value;
@@ -2296,12 +2300,12 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
                                KSYM_NAME_LEN);
                        strlcpy(module_name, mod->name, MODULE_NAME_LEN);
                        *exported = is_exported(name, mod);
-                       mutex_unlock(&module_mutex);
+                       preempt_enable();
                        return 0;
                }
                symnum -= mod->num_symtab;
        }
-       mutex_unlock(&module_mutex);
+       preempt_enable();
        return -ERANGE;
 }
 
@@ -2324,6 +2328,7 @@ unsigned long module_kallsyms_lookup_name(const char *name)
        unsigned long ret = 0;
 
        /* Don't lock: we're in enough trouble already. */
+       preempt_disable();
        if ((colon = strchr(name, ':')) != NULL) {
                *colon = '\0';
                if ((mod = find_module(name)) != NULL)
@@ -2334,6 +2339,7 @@ unsigned long module_kallsyms_lookup_name(const char *name)
                        if ((ret = mod_find_symname(mod, name)) != 0)
                                break;
        }
+       preempt_enable();
        return ret;
 }
 #endif /* CONFIG_KALLSYMS */
@@ -2514,7 +2520,7 @@ static void module_create_drivers_dir(struct module_kobject *mk)
        if (!mk || mk->drivers_dir)
                return;
 
-       mk->drivers_dir = kobject_add_dir(&mk->kobj, "drivers");
+       mk->drivers_dir = kobject_create_and_add("drivers", &mk->kobj);
 }
 
 void module_add_driver(struct module *mod, struct device_driver *drv)
@@ -2532,7 +2538,7 @@ void module_add_driver(struct module *mod, struct device_driver *drv)
                struct kobject *mkobj;
 
                /* Lookup built-in module entry in /sys/modules */
-               mkobj = kset_find_obj(&module_subsys, drv->mod_name);
+               mkobj = kset_find_obj(module_kset, drv->mod_name);
                if (mkobj) {
                        mk = container_of(mkobj, struct module_kobject, kobj);
                        /* remember our module structure */