As Dan Streetman points out, the entire point of locking for is to
stop sysfs accesses, so they're elided entirely in the !SYSFS case.
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
unsigned int num_syms;
/* Kernel parameters. */
unsigned int num_syms;
/* Kernel parameters. */
struct kernel_param *kp;
unsigned int num_kp;
struct kernel_param *kp;
unsigned int num_kp;
+static void init_param_lock(struct module *mod)
+{
+ mutex_init(&mod->param_lock);
+}
#else /* !CONFIG_SYSFS */
static int mod_sysfs_setup(struct module *mod,
#else /* !CONFIG_SYSFS */
static int mod_sysfs_setup(struct module *mod,
+static void init_param_lock(struct module *mod)
+{
+}
#endif /* CONFIG_SYSFS */
static void mod_sysfs_teardown(struct module *mod)
#endif /* CONFIG_SYSFS */
static void mod_sysfs_teardown(struct module *mod)
if (err)
goto unlink_mod;
if (err)
goto unlink_mod;
- mutex_init(&mod->param_lock);
/* Now we've got everything in the final locations, we can
* find optional sections. */
/* Now we've got everything in the final locations, we can
* find optional sections. */
#include <linux/slab.h>
#include <linux/ctype.h>
#include <linux/slab.h>
#include <linux/ctype.h>
/* 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 */
#define KPARAM_MUTEX(mod) ((mod) ? &(mod)->param_lock : ¶m_lock)
/* 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 */
#define KPARAM_MUTEX(mod) ((mod) ? &(mod)->param_lock : ¶m_lock)
-#define KPARAM_IS_LOCKED(mod) mutex_is_locked(KPARAM_MUTEX(mod))
+
+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 {
/* This just allows us to keep track of which parameters are kmalloced. */
struct kmalloced_param {
/* nul-terminate and parse */
save = val[len];
((char *)val)[len] = '\0';
/* 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)
ret = set(val, &kp);
if (ret != 0)
if (i)
buffer[off++] = ',';
p.arg = arr->elem + arr->elemsize * i;
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;
ret = arr->ops->get(buffer + off, &p);
if (ret < 0)
return ret;
#define __modinit __init
#endif
#define __modinit __init
#endif
void kernel_param_lock(struct module *mod)
{
mutex_lock(KPARAM_MUTEX(mod));
void kernel_param_lock(struct module *mod)
{
mutex_lock(KPARAM_MUTEX(mod));
mutex_unlock(KPARAM_MUTEX(mod));
}
mutex_unlock(KPARAM_MUTEX(mod));
}
EXPORT_SYMBOL(kernel_param_lock);
EXPORT_SYMBOL(kernel_param_unlock);
EXPORT_SYMBOL(kernel_param_lock);
EXPORT_SYMBOL(kernel_param_unlock);