OSDN Git Service

Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[uclinux-h8/linux.git] / kernel / params.c
index 8890d0b..b6554aa 100644 (file)
 #include <linux/slab.h>
 #include <linux/ctype.h>
 
+#ifdef CONFIG_SYSFS
 /* Protects all built-in parameters, modules use their own param_lock */
 static DEFINE_MUTEX(param_lock);
 
 /* Use the module's mutex, or if built-in use the built-in mutex */
+#ifdef CONFIG_MODULES
 #define KPARAM_MUTEX(mod)      ((mod) ? &(mod)->param_lock : &param_lock)
-#define KPARAM_IS_LOCKED(mod)  mutex_is_locked(KPARAM_MUTEX(mod))
+#else
+#define KPARAM_MUTEX(mod)      (&param_lock)
+#endif
+
+static inline void check_kparam_locked(struct module *mod)
+{
+       BUG_ON(!mutex_is_locked(KPARAM_MUTEX(mod)));
+}
+#else
+static inline void check_kparam_locked(struct module *mod)
+{
+}
+#endif /* !CONFIG_SYSFS */
 
 /* This just allows us to keep track of which parameters are kmalloced. */
 struct kmalloced_param {
@@ -110,8 +124,9 @@ static int parse_one(char *param,
                     unsigned num_params,
                     s16 min_level,
                     s16 max_level,
+                    void *arg,
                     int (*handle_unknown)(char *param, char *val,
-                                    const char *doing))
+                                    const char *doing, void *arg))
 {
        unsigned int i;
        int err;
@@ -138,7 +153,7 @@ static int parse_one(char *param,
 
        if (handle_unknown) {
                pr_debug("doing %s: %s='%s'\n", doing, param, val);
-               return handle_unknown(param, val, doing);
+               return handle_unknown(param, val, doing, arg);
        }
 
        pr_debug("Unknown argument '%s'\n", param);
@@ -204,7 +219,9 @@ char *parse_args(const char *doing,
                 unsigned num,
                 s16 min_level,
                 s16 max_level,
-                int (*unknown)(char *param, char *val, const char *doing))
+                void *arg,
+                int (*unknown)(char *param, char *val,
+                               const char *doing, void *arg))
 {
        char *param, *val;
 
@@ -224,7 +241,7 @@ char *parse_args(const char *doing,
                        return args;
                irq_was_disabled = irqs_disabled();
                ret = parse_one(param, val, doing, params, num,
-                               min_level, max_level, unknown);
+                               min_level, max_level, arg, unknown);
                if (irq_was_disabled && !irqs_disabled())
                        pr_warn("%s: option '%s' enabled irq's!\n",
                                doing, param);
@@ -459,7 +476,7 @@ static int param_array(struct module *mod,
                /* nul-terminate and parse */
                save = val[len];
                ((char *)val)[len] = '\0';
-               BUG_ON(!KPARAM_IS_LOCKED(mod));
+               check_kparam_locked(mod);
                ret = set(val, &kp);
 
                if (ret != 0)
@@ -496,7 +513,7 @@ static int param_array_get(char *buffer, const struct kernel_param *kp)
                if (i)
                        buffer[off++] = ',';
                p.arg = arr->elem + arr->elemsize * i;
-               BUG_ON(!KPARAM_IS_LOCKED(p.mod));
+               check_kparam_locked(p.mod);
                ret = arr->ops->get(buffer + off, &p);
                if (ret < 0)
                        return ret;
@@ -616,6 +633,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr,
 #define __modinit __init
 #endif
 
+#ifdef CONFIG_SYSFS
 void kernel_param_lock(struct module *mod)
 {
        mutex_lock(KPARAM_MUTEX(mod));
@@ -626,7 +644,6 @@ void kernel_param_unlock(struct module *mod)
        mutex_unlock(KPARAM_MUTEX(mod));
 }
 
-#ifdef CONFIG_SYSFS
 EXPORT_SYMBOL(kernel_param_lock);
 EXPORT_SYMBOL(kernel_param_unlock);