aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/moduleparam.h19
-rw-r--r--kernel/params.c23
2 files changed, 8 insertions, 34 deletions
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index c47f4d60db0b..4daa895648d9 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -47,9 +47,6 @@ struct kernel_param_ops {
47 void (*free)(void *arg); 47 void (*free)(void *arg);
48}; 48};
49 49
50/* Flag bits for kernel_param.flags */
51#define KPARAM_ISBOOL 2
52
53struct kernel_param { 50struct kernel_param {
54 const char *name; 51 const char *name;
55 const struct kernel_param_ops *ops; 52 const struct kernel_param_ops *ops;
@@ -131,8 +128,7 @@ struct kparam_array
131 * The ops can have NULL set or get functions. 128 * The ops can have NULL set or get functions.
132 */ 129 */
133#define module_param_cb(name, ops, arg, perm) \ 130#define module_param_cb(name, ops, arg, perm) \
134 __module_param_call(MODULE_PARAM_PREFIX, \ 131 __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm)
135 name, ops, arg, __same_type((arg), bool *), perm)
136 132
137/* On alpha, ia64 and ppc64 relocations to global data cannot go into 133/* On alpha, ia64 and ppc64 relocations to global data cannot go into
138 read-only sections (which is part of respective UNIX ABI on these 134 read-only sections (which is part of respective UNIX ABI on these
@@ -146,7 +142,7 @@ struct kparam_array
146 142
147/* This is the fundamental function for registering boot/module 143/* This is the fundamental function for registering boot/module
148 parameters. */ 144 parameters. */
149#define __module_param_call(prefix, name, ops, arg, isbool, perm) \ 145#define __module_param_call(prefix, name, ops, arg, perm) \
150 /* Default value instead of permissions? */ \ 146 /* Default value instead of permissions? */ \
151 static int __param_perm_check_##name __attribute__((unused)) = \ 147 static int __param_perm_check_##name __attribute__((unused)) = \
152 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \ 148 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \
@@ -155,8 +151,7 @@ struct kparam_array
155 static struct kernel_param __moduleparam_const __param_##name \ 151 static struct kernel_param __moduleparam_const __param_##name \
156 __used \ 152 __used \
157 __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ 153 __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
158 = { __param_str_##name, ops, perm, isbool ? KPARAM_ISBOOL : 0, \ 154 = { __param_str_##name, ops, perm, 0, { arg } }
159 { arg } }
160 155
161/* Obsolete - use module_param_cb() */ 156/* Obsolete - use module_param_cb() */
162#define module_param_call(name, set, get, arg, perm) \ 157#define module_param_call(name, set, get, arg, perm) \
@@ -164,7 +159,6 @@ struct kparam_array
164 { (void *)set, (void *)get }; \ 159 { (void *)set, (void *)get }; \
165 __module_param_call(MODULE_PARAM_PREFIX, \ 160 __module_param_call(MODULE_PARAM_PREFIX, \
166 name, &__param_ops_##name, arg, \ 161 name, &__param_ops_##name, arg, \
167 __same_type(arg, bool *), \
168 (perm) + sizeof(__check_old_set_param(set))*0) 162 (perm) + sizeof(__check_old_set_param(set))*0)
169 163
170/* We don't get oldget: it's often a new-style param_get_uint, etc. */ 164/* We don't get oldget: it's often a new-style param_get_uint, etc. */
@@ -245,8 +239,7 @@ static inline void __kernel_param_unlock(void)
245 */ 239 */
246#define core_param(name, var, type, perm) \ 240#define core_param(name, var, type, perm) \
247 param_check_##type(name, &(var)); \ 241 param_check_##type(name, &(var)); \
248 __module_param_call("", name, &param_ops_##type, \ 242 __module_param_call("", name, &param_ops_##type, &var, perm)
249 &var, __same_type(var, bool), perm)
250#endif /* !MODULE */ 243#endif /* !MODULE */
251 244
252/** 245/**
@@ -264,7 +257,7 @@ static inline void __kernel_param_unlock(void)
264 = { len, string }; \ 257 = { len, string }; \
265 __module_param_call(MODULE_PARAM_PREFIX, name, \ 258 __module_param_call(MODULE_PARAM_PREFIX, name, \
266 &param_ops_string, \ 259 &param_ops_string, \
267 .str = &__param_string_##name, 0, perm); \ 260 .str = &__param_string_##name, perm); \
268 __MODULE_PARM_TYPE(name, "string") 261 __MODULE_PARM_TYPE(name, "string")
269 262
270/** 263/**
@@ -403,7 +396,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
403 __module_param_call(MODULE_PARAM_PREFIX, name, \ 396 __module_param_call(MODULE_PARAM_PREFIX, name, \
404 &param_array_ops, \ 397 &param_array_ops, \
405 .arr = &__param_arr_##name, \ 398 .arr = &__param_arr_##name, \
406 __same_type(array[0], bool), perm); \ 399 perm); \
407 __MODULE_PARM_TYPE(name, "array of " #type) 400 __MODULE_PARM_TYPE(name, "array of " #type)
408 401
409extern struct kernel_param_ops param_array_ops; 402extern struct kernel_param_ops param_array_ops;
diff --git a/kernel/params.c b/kernel/params.c
index 47f5bf12434a..508828afb874 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -297,35 +297,18 @@ EXPORT_SYMBOL(param_ops_charp);
297/* Actually could be a bool or an int, for historical reasons. */ 297/* Actually could be a bool or an int, for historical reasons. */
298int param_set_bool(const char *val, const struct kernel_param *kp) 298int param_set_bool(const char *val, const struct kernel_param *kp)
299{ 299{
300 bool v;
301 int ret;
302
303 /* No equals means "set"... */ 300 /* No equals means "set"... */
304 if (!val) val = "1"; 301 if (!val) val = "1";
305 302
306 /* One of =[yYnN01] */ 303 /* One of =[yYnN01] */
307 ret = strtobool(val, &v); 304 return strtobool(val, kp->arg);
308 if (ret)
309 return ret;
310
311 if (kp->flags & KPARAM_ISBOOL)
312 *(bool *)kp->arg = v;
313 else
314 *(int *)kp->arg = v;
315 return 0;
316} 305}
317EXPORT_SYMBOL(param_set_bool); 306EXPORT_SYMBOL(param_set_bool);
318 307
319int param_get_bool(char *buffer, const struct kernel_param *kp) 308int param_get_bool(char *buffer, const struct kernel_param *kp)
320{ 309{
321 bool val;
322 if (kp->flags & KPARAM_ISBOOL)
323 val = *(bool *)kp->arg;
324 else
325 val = *(int *)kp->arg;
326
327 /* Y and N chosen as being relatively non-coder friendly */ 310 /* Y and N chosen as being relatively non-coder friendly */
328 return sprintf(buffer, "%c", val ? 'Y' : 'N'); 311 return sprintf(buffer, "%c", *(bool *)kp->arg ? 'Y' : 'N');
329} 312}
330EXPORT_SYMBOL(param_get_bool); 313EXPORT_SYMBOL(param_get_bool);
331 314
@@ -343,7 +326,6 @@ int param_set_invbool(const char *val, const struct kernel_param *kp)
343 struct kernel_param dummy; 326 struct kernel_param dummy;
344 327
345 dummy.arg = &boolval; 328 dummy.arg = &boolval;
346 dummy.flags = KPARAM_ISBOOL;
347 ret = param_set_bool(val, &dummy); 329 ret = param_set_bool(val, &dummy);
348 if (ret == 0) 330 if (ret == 0)
349 *(bool *)kp->arg = !boolval; 331 *(bool *)kp->arg = !boolval;
@@ -372,7 +354,6 @@ int param_set_bint(const char *val, const struct kernel_param *kp)
372 /* Match bool exactly, by re-using it. */ 354 /* Match bool exactly, by re-using it. */
373 boolkp = *kp; 355 boolkp = *kp;
374 boolkp.arg = &v; 356 boolkp.arg = &v;
375 boolkp.flags |= KPARAM_ISBOOL;
376 357
377 ret = param_set_bool(val, &boolkp); 358 ret = param_set_bool(val, &boolkp);
378 if (ret == 0) 359 if (ret == 0)