]> err.no Git - linux-2.6/blobdiff - kernel/params.c
[POWERPC] 83xx: Add default config file for Wind River SBC8349 board
[linux-2.6] / kernel / params.c
index 1fc4ac746cd8b7c5f9fd9310741beee1397f8c9b..7686417ee00eba070b7d9b5c9dd293f9991199f1 100644 (file)
@@ -252,8 +252,9 @@ int param_get_bool(char *buffer, struct kernel_param *kp)
 int param_set_invbool(const char *val, struct kernel_param *kp)
 {
        int boolval, ret;
-       struct kernel_param dummy = { .arg = &boolval };
+       struct kernel_param dummy;
 
+       dummy.arg = &boolval;
        ret = param_set_bool(val, &dummy);
        if (ret == 0)
                *(int *)kp->arg = !boolval;
@@ -262,14 +263,10 @@ int param_set_invbool(const char *val, struct kernel_param *kp)
 
 int param_get_invbool(char *buffer, struct kernel_param *kp)
 {
-       int val;
-       struct kernel_param dummy = { .arg = &val };
-
-       val = !*(int *)kp->arg;
-       return param_get_bool(buffer, &dummy);
+       return sprintf(buffer, "%c", (*(int *)kp->arg) ? 'N' : 'Y');
 }
 
-/* We cheat here and temporarily mangle the string. */
+/* We break the rule and mangle the string. */
 static int param_array(const char *name,
                       const char *val,
                       unsigned int min, unsigned int max,
@@ -325,7 +322,7 @@ static int param_array(const char *name,
 
 int param_array_set(const char *val, struct kernel_param *kp)
 {
-       struct kparam_array *arr = kp->arg;
+       const struct kparam_array *arr = kp->arr;
        unsigned int temp_num;
 
        return param_array(kp->name, val, 1, arr->max, arr->elem,
@@ -335,7 +332,7 @@ int param_array_set(const char *val, struct kernel_param *kp)
 int param_array_get(char *buffer, struct kernel_param *kp)
 {
        int i, off, ret;
-       struct kparam_array *arr = kp->arg;
+       const struct kparam_array *arr = kp->arr;
        struct kernel_param p;
 
        p = *kp;
@@ -354,7 +351,7 @@ int param_array_get(char *buffer, struct kernel_param *kp)
 
 int param_set_copystring(const char *val, struct kernel_param *kp)
 {
-       struct kparam_string *kps = kp->arg;
+       const struct kparam_string *kps = kp->str;
 
        if (!val) {
                printk(KERN_ERR "%s: missing param set value\n", kp->name);
@@ -371,7 +368,7 @@ int param_set_copystring(const char *val, struct kernel_param *kp)
 
 int param_get_string(char *buffer, struct kernel_param *kp)
 {
-       struct kparam_string *kps = kp->arg;
+       const struct kparam_string *kps = kp->str;
        return strlcpy(buffer, kps->string, kps->maxlen);
 }
 
@@ -491,7 +488,6 @@ param_sysfs_setup(struct module_kobject *mk,
                        pattr->mattr.show = param_attr_show;
                        pattr->mattr.store = param_attr_store;
                        pattr->mattr.attr.name = (char *)&kp->name[name_skip];
-                       pattr->mattr.attr.owner = mk->mod;
                        pattr->mattr.attr.mode = kp->perm;
                        *(gattr++) = &(pattr++)->mattr.attr;
                }
@@ -568,7 +564,12 @@ static void __init kernel_param_sysfs_setup(const char *name,
        kobject_set_name(&mk->kobj, name);
        kobject_init(&mk->kobj);
        ret = kobject_add(&mk->kobj);
-       BUG_ON(ret < 0);
+       if (ret) {
+               printk(KERN_ERR "Module '%s' failed to be added to sysfs, "
+                     "error number %d\n", name, ret);
+               printk(KERN_ERR "The system will be unstable now.\n");
+               return;
+       }
        param_sysfs_setup(mk, kparam, num_params, name_skip);
        kobject_uevent(&mk->kobj, KOBJ_ADD);
 }
@@ -591,13 +592,16 @@ static void __init param_sysfs_builtin(void)
 
        for (i=0; i < __stop___param - __start___param; i++) {
                char *dot;
+               size_t max_name_len;
 
                kp = &__start___param[i];
+               max_name_len =
+                       min_t(size_t, MAX_KBUILD_MODNAME, strlen(kp->name));
 
-               /* We do not handle args without periods. */
-               dot = memchr(kp->name, '.', MAX_KBUILD_MODNAME);
+               dot = memchr(kp->name, '.', max_name_len);
                if (!dot) {
-                       DEBUGP("couldn't find period in %s\n", kp->name);
+                       DEBUGP("couldn't find period in first %d characters "
+                              "of %s\n", MAX_KBUILD_MODNAME, kp->name);
                        continue;
                }
                name_len = dot - kp->name;
@@ -691,9 +695,20 @@ static struct kset_uevent_ops module_uevent_ops = {
 };
 
 decl_subsys(module, &module_ktype, &module_uevent_ops);
+int module_sysfs_initialized;
+
+static void module_release(struct kobject *kobj)
+{
+       /*
+        * Stupid empty release function to allow the memory for the kobject to
+        * be properly cleaned up.  This will not need to be present for 2.6.25
+        * with the upcoming kobject core rework.
+        */
+}
 
 static struct kobj_type module_ktype = {
        .sysfs_ops =    &module_sysfs_ops,
+       .release =      module_release,
 };
 
 /*
@@ -709,6 +724,7 @@ static int __init param_sysfs_init(void)
                        __FILE__, __LINE__, ret);
                return ret;
        }
+       module_sysfs_initialized = 1;
 
        param_sysfs_builtin();