diff options
Diffstat (limited to 'include/linux/moduleparam.h')
| -rw-r--r-- | include/linux/moduleparam.h | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index c47f4d60db0b..ea36486378d8 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h | |||
| @@ -47,14 +47,11 @@ 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 | |||
| 53 | struct kernel_param { | 50 | struct kernel_param { |
| 54 | const char *name; | 51 | const char *name; |
| 55 | const struct kernel_param_ops *ops; | 52 | const struct kernel_param_ops *ops; |
| 56 | u16 perm; | 53 | u16 perm; |
| 57 | u16 flags; | 54 | s16 level; |
| 58 | union { | 55 | union { |
| 59 | void *arg; | 56 | void *arg; |
| 60 | const struct kparam_string *str; | 57 | const struct kparam_string *str; |
| @@ -131,8 +128,40 @@ 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, 0) |
| 135 | name, ops, arg, __same_type((arg), bool *), perm) | 132 | |
| 133 | /** | ||
| 134 | * <level>_param_cb - general callback for a module/cmdline parameter | ||
| 135 | * to be evaluated before certain initcall level | ||
| 136 | * @name: a valid C identifier which is the parameter name. | ||
| 137 | * @ops: the set & get operations for this parameter. | ||
| 138 | * @perm: visibility in sysfs. | ||
| 139 | * | ||
| 140 | * The ops can have NULL set or get functions. | ||
| 141 | */ | ||
| 142 | #define __level_param_cb(name, ops, arg, perm, level) \ | ||
| 143 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level) | ||
| 144 | |||
| 145 | #define core_param_cb(name, ops, arg, perm) \ | ||
| 146 | __level_param_cb(name, ops, arg, perm, 1) | ||
| 147 | |||
| 148 | #define postcore_param_cb(name, ops, arg, perm) \ | ||
| 149 | __level_param_cb(name, ops, arg, perm, 2) | ||
| 150 | |||
| 151 | #define arch_param_cb(name, ops, arg, perm) \ | ||
| 152 | __level_param_cb(name, ops, arg, perm, 3) | ||
| 153 | |||
| 154 | #define subsys_param_cb(name, ops, arg, perm) \ | ||
| 155 | __level_param_cb(name, ops, arg, perm, 4) | ||
| 156 | |||
| 157 | #define fs_param_cb(name, ops, arg, perm) \ | ||
| 158 | __level_param_cb(name, ops, arg, perm, 5) | ||
| 159 | |||
| 160 | #define device_param_cb(name, ops, arg, perm) \ | ||
| 161 | __level_param_cb(name, ops, arg, perm, 6) | ||
| 162 | |||
| 163 | #define late_param_cb(name, ops, arg, perm) \ | ||
| 164 | __level_param_cb(name, ops, arg, perm, 7) | ||
| 136 | 165 | ||
| 137 | /* On alpha, ia64 and ppc64 relocations to global data cannot go into | 166 | /* 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 | 167 | read-only sections (which is part of respective UNIX ABI on these |
| @@ -146,7 +175,7 @@ struct kparam_array | |||
| 146 | 175 | ||
| 147 | /* This is the fundamental function for registering boot/module | 176 | /* This is the fundamental function for registering boot/module |
| 148 | parameters. */ | 177 | parameters. */ |
| 149 | #define __module_param_call(prefix, name, ops, arg, isbool, perm) \ | 178 | #define __module_param_call(prefix, name, ops, arg, perm, level) \ |
| 150 | /* Default value instead of permissions? */ \ | 179 | /* Default value instead of permissions? */ \ |
| 151 | static int __param_perm_check_##name __attribute__((unused)) = \ | 180 | static int __param_perm_check_##name __attribute__((unused)) = \ |
| 152 | BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \ | 181 | BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \ |
| @@ -155,8 +184,7 @@ struct kparam_array | |||
| 155 | static struct kernel_param __moduleparam_const __param_##name \ | 184 | static struct kernel_param __moduleparam_const __param_##name \ |
| 156 | __used \ | 185 | __used \ |
| 157 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ | 186 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ |
| 158 | = { __param_str_##name, ops, perm, isbool ? KPARAM_ISBOOL : 0, \ | 187 | = { __param_str_##name, ops, perm, level, { arg } } |
| 159 | { arg } } | ||
| 160 | 188 | ||
| 161 | /* Obsolete - use module_param_cb() */ | 189 | /* Obsolete - use module_param_cb() */ |
| 162 | #define module_param_call(name, set, get, arg, perm) \ | 190 | #define module_param_call(name, set, get, arg, perm) \ |
| @@ -164,8 +192,7 @@ struct kparam_array | |||
| 164 | { (void *)set, (void *)get }; \ | 192 | { (void *)set, (void *)get }; \ |
| 165 | __module_param_call(MODULE_PARAM_PREFIX, \ | 193 | __module_param_call(MODULE_PARAM_PREFIX, \ |
| 166 | name, &__param_ops_##name, arg, \ | 194 | name, &__param_ops_##name, arg, \ |
| 167 | __same_type(arg, bool *), \ | 195 | (perm) + sizeof(__check_old_set_param(set))*0, 0) |
| 168 | (perm) + sizeof(__check_old_set_param(set))*0) | ||
| 169 | 196 | ||
| 170 | /* We don't get oldget: it's often a new-style param_get_uint, etc. */ | 197 | /* We don't get oldget: it's often a new-style param_get_uint, etc. */ |
| 171 | static inline int | 198 | static inline int |
| @@ -245,8 +272,7 @@ static inline void __kernel_param_unlock(void) | |||
| 245 | */ | 272 | */ |
| 246 | #define core_param(name, var, type, perm) \ | 273 | #define core_param(name, var, type, perm) \ |
| 247 | param_check_##type(name, &(var)); \ | 274 | param_check_##type(name, &(var)); \ |
| 248 | __module_param_call("", name, ¶m_ops_##type, \ | 275 | __module_param_call("", name, ¶m_ops_##type, &var, perm, 0) |
| 249 | &var, __same_type(var, bool), perm) | ||
| 250 | #endif /* !MODULE */ | 276 | #endif /* !MODULE */ |
| 251 | 277 | ||
| 252 | /** | 278 | /** |
| @@ -264,7 +290,7 @@ static inline void __kernel_param_unlock(void) | |||
| 264 | = { len, string }; \ | 290 | = { len, string }; \ |
| 265 | __module_param_call(MODULE_PARAM_PREFIX, name, \ | 291 | __module_param_call(MODULE_PARAM_PREFIX, name, \ |
| 266 | ¶m_ops_string, \ | 292 | ¶m_ops_string, \ |
| 267 | .str = &__param_string_##name, 0, perm); \ | 293 | .str = &__param_string_##name, perm, 0); \ |
| 268 | __MODULE_PARM_TYPE(name, "string") | 294 | __MODULE_PARM_TYPE(name, "string") |
| 269 | 295 | ||
| 270 | /** | 296 | /** |
| @@ -292,6 +318,8 @@ extern int parse_args(const char *name, | |||
| 292 | char *args, | 318 | char *args, |
| 293 | const struct kernel_param *params, | 319 | const struct kernel_param *params, |
| 294 | unsigned num, | 320 | unsigned num, |
| 321 | s16 level_min, | ||
| 322 | s16 level_max, | ||
| 295 | int (*unknown)(char *param, char *val)); | 323 | int (*unknown)(char *param, char *val)); |
| 296 | 324 | ||
| 297 | /* Called by module remove. */ | 325 | /* Called by module remove. */ |
| @@ -403,7 +431,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp); | |||
| 403 | __module_param_call(MODULE_PARAM_PREFIX, name, \ | 431 | __module_param_call(MODULE_PARAM_PREFIX, name, \ |
| 404 | ¶m_array_ops, \ | 432 | ¶m_array_ops, \ |
| 405 | .arr = &__param_arr_##name, \ | 433 | .arr = &__param_arr_##name, \ |
| 406 | __same_type(array[0], bool), perm); \ | 434 | perm, 0); \ |
| 407 | __MODULE_PARM_TYPE(name, "array of " #type) | 435 | __MODULE_PARM_TYPE(name, "array of " #type) |
| 408 | 436 | ||
| 409 | extern struct kernel_param_ops param_array_ops; | 437 | extern struct kernel_param_ops param_array_ops; |
