aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/moduleparam.h
diff options
context:
space:
mode:
authorPawel Moll <pawel.moll@arm.com>2012-03-25 22:20:51 -0400
committerRusty Russell <rusty@rustcorp.com.au>2012-03-25 22:20:51 -0400
commit026cee0086fe1df4cf74691cf273062cc769617d (patch)
tree22735ecd2132de4570fbad81e5716f7fee3448d5 /include/linux/moduleparam.h
parent8b8252813dee8e8cd453bb219731c36b268c69a7 (diff)
params: <level>_initcall-like kernel parameters
This patch adds a set of macros that can be used to declare kernel parameters to be parsed _before_ initcalls at a chosen level are executed. We rename the now-unused "flags" field of struct kernel_param as the level. It's signed, for when we use this for early params as well, in future. Linker macro collating init calls had to be modified in order to add additional symbols between levels that are later used by the init code to split the calls into blocks. Signed-off-by: Pawel Moll <pawel.moll@arm.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include/linux/moduleparam.h')
-rw-r--r--include/linux/moduleparam.h51
1 files changed, 43 insertions, 8 deletions
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 4daa895648d9..ea36486378d8 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -51,7 +51,7 @@ struct kernel_param {
51 const char *name; 51 const char *name;
52 const struct kernel_param_ops *ops; 52 const struct kernel_param_ops *ops;
53 u16 perm; 53 u16 perm;
54 u16 flags; 54 s16 level;
55 union { 55 union {
56 void *arg; 56 void *arg;
57 const struct kparam_string *str; 57 const struct kparam_string *str;
@@ -128,7 +128,40 @@ struct kparam_array
128 * The ops can have NULL set or get functions. 128 * The ops can have NULL set or get functions.
129 */ 129 */
130#define module_param_cb(name, ops, arg, perm) \ 130#define module_param_cb(name, ops, arg, perm) \
131 __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm) 131 __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, 0)
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)
132 165
133/* 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
134 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
@@ -142,7 +175,7 @@ struct kparam_array
142 175
143/* This is the fundamental function for registering boot/module 176/* This is the fundamental function for registering boot/module
144 parameters. */ 177 parameters. */
145#define __module_param_call(prefix, name, ops, arg, perm) \ 178#define __module_param_call(prefix, name, ops, arg, perm, level) \
146 /* Default value instead of permissions? */ \ 179 /* Default value instead of permissions? */ \
147 static int __param_perm_check_##name __attribute__((unused)) = \ 180 static int __param_perm_check_##name __attribute__((unused)) = \
148 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \ 181 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \
@@ -151,7 +184,7 @@ struct kparam_array
151 static struct kernel_param __moduleparam_const __param_##name \ 184 static struct kernel_param __moduleparam_const __param_##name \
152 __used \ 185 __used \
153 __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ 186 __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
154 = { __param_str_##name, ops, perm, 0, { arg } } 187 = { __param_str_##name, ops, perm, level, { arg } }
155 188
156/* Obsolete - use module_param_cb() */ 189/* Obsolete - use module_param_cb() */
157#define module_param_call(name, set, get, arg, perm) \ 190#define module_param_call(name, set, get, arg, perm) \
@@ -159,7 +192,7 @@ struct kparam_array
159 { (void *)set, (void *)get }; \ 192 { (void *)set, (void *)get }; \
160 __module_param_call(MODULE_PARAM_PREFIX, \ 193 __module_param_call(MODULE_PARAM_PREFIX, \
161 name, &__param_ops_##name, arg, \ 194 name, &__param_ops_##name, arg, \
162 (perm) + sizeof(__check_old_set_param(set))*0) 195 (perm) + sizeof(__check_old_set_param(set))*0, 0)
163 196
164/* 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. */
165static inline int 198static inline int
@@ -239,7 +272,7 @@ static inline void __kernel_param_unlock(void)
239 */ 272 */
240#define core_param(name, var, type, perm) \ 273#define core_param(name, var, type, perm) \
241 param_check_##type(name, &(var)); \ 274 param_check_##type(name, &(var)); \
242 __module_param_call("", name, &param_ops_##type, &var, perm) 275 __module_param_call("", name, &param_ops_##type, &var, perm, 0)
243#endif /* !MODULE */ 276#endif /* !MODULE */
244 277
245/** 278/**
@@ -257,7 +290,7 @@ static inline void __kernel_param_unlock(void)
257 = { len, string }; \ 290 = { len, string }; \
258 __module_param_call(MODULE_PARAM_PREFIX, name, \ 291 __module_param_call(MODULE_PARAM_PREFIX, name, \
259 &param_ops_string, \ 292 &param_ops_string, \
260 .str = &__param_string_##name, perm); \ 293 .str = &__param_string_##name, perm, 0); \
261 __MODULE_PARM_TYPE(name, "string") 294 __MODULE_PARM_TYPE(name, "string")
262 295
263/** 296/**
@@ -285,6 +318,8 @@ extern int parse_args(const char *name,
285 char *args, 318 char *args,
286 const struct kernel_param *params, 319 const struct kernel_param *params,
287 unsigned num, 320 unsigned num,
321 s16 level_min,
322 s16 level_max,
288 int (*unknown)(char *param, char *val)); 323 int (*unknown)(char *param, char *val));
289 324
290/* Called by module remove. */ 325/* Called by module remove. */
@@ -396,7 +431,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
396 __module_param_call(MODULE_PARAM_PREFIX, name, \ 431 __module_param_call(MODULE_PARAM_PREFIX, name, \
397 &param_array_ops, \ 432 &param_array_ops, \
398 .arr = &__param_arr_##name, \ 433 .arr = &__param_arr_##name, \
399 perm); \ 434 perm, 0); \
400 __MODULE_PARM_TYPE(name, "array of " #type) 435 __MODULE_PARM_TYPE(name, "array of " #type)
401 436
402extern struct kernel_param_ops param_array_ops; 437extern struct kernel_param_ops param_array_ops;