]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
module_param: split perm field into flags and perm
authorRusty Russell <rusty@rustcorp.com.au>
Sat, 13 Jun 2009 03:46:56 +0000 (21:46 -0600)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 12 Jun 2009 12:16:56 +0000 (21:46 +0930)
Impact: cleanup

Rather than hack KPARAM_KMALLOCED into the perm field, separate it out.
Since the perm field was 32 bits and only needs 16, we don't add bloat.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
include/linux/moduleparam.h
kernel/params.c

index 9bbca8e8c19f7a5ad49645b40db10c7f196dfafb..009a5f768768555ca43a73b00a36a5aeea7415cd 100644 (file)
@@ -36,9 +36,13 @@ typedef int (*param_set_fn)(const char *val, struct kernel_param *kp);
 /* Returns length written or -errno.  Buffer is 4k (ie. be short!) */
 typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp);
 
+/* Flag bits for kernel_param.flags */
+#define KPARAM_KMALLOCED       1
+
 struct kernel_param {
        const char *name;
-       unsigned int perm;
+       u16 perm;
+       u16 flags;
        param_set_fn set;
        param_get_fn get;
        union {
@@ -88,7 +92,7 @@ struct kparam_array
        static struct kernel_param __moduleparam_const __param_##name   \
        __used                                                          \
     __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
-       = { __param_str_##name, perm, set, get, { arg } }
+       = { __param_str_##name, perm, 0, set, get, { arg } }
 
 #define module_param_call(name, set, get, arg, perm)                         \
        __module_param_call(MODULE_PARAM_PREFIX, name, set, get, arg, perm)
index 023abbf5f89f03dc9a4351c73b210d2d8d46e3e7..b4660dc13dbcbbe3bfbafc3498fb55b26078be76 100644 (file)
@@ -24,9 +24,6 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 
-/* We abuse the high bits of "perm" to record whether we kmalloc'ed. */
-#define KPARAM_KMALLOCED       0x80000000
-
 #if 0
 #define DEBUGP printk
 #else
@@ -220,13 +217,13 @@ int param_set_charp(const char *val, struct kernel_param *kp)
                return -ENOSPC;
        }
 
-       if (kp->perm & KPARAM_KMALLOCED)
+       if (kp->flags & KPARAM_KMALLOCED)
                kfree(*(char **)kp->arg);
 
        /* This is a hack.  We can't need to strdup in early boot, and we
         * don't need to; this mangled commandline is preserved. */
        if (slab_is_available()) {
-               kp->perm |= KPARAM_KMALLOCED;
+               kp->flags |= KPARAM_KMALLOCED;
                *(char **)kp->arg = kstrdup(val, GFP_KERNEL);
                if (!kp->arg)
                        return -ENOMEM;
@@ -591,7 +588,7 @@ void destroy_params(const struct kernel_param *params, unsigned num)
        unsigned int i;
 
        for (i = 0; i < num; i++)
-               if (params[i].perm & KPARAM_KMALLOCED)
+               if (params[i].flags & KPARAM_KMALLOCED)
                        kfree(*(char **)params[i].arg);
 }