@@ -51,7 +51,7 @@ struct kernel_param {
5151 const char * name ;
5252 const struct kernel_param_ops * ops ;
5353 u16 perm ;
54- u16 flags ;
54+ s16 level ;
5555 union {
5656 void * arg ;
5757 const struct kparam_string * str ;
@@ -128,7 +128,40 @@ struct kparam_array
128128 * The ops can have NULL set or get functions.
129129 */
130130#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)
132165
133166/* On alpha, ia64 and ppc64 relocations to global data cannot go into
134167 read-only sections (which is part of respective UNIX ABI on these
@@ -142,7 +175,7 @@ struct kparam_array
142175
143176/* This is the fundamental function for registering boot/module
144177 parameters. */
145- #define __module_param_call (prefix , name , ops , arg , perm ) \
178+ #define __module_param_call (prefix , name , ops , arg , perm , level ) \
146179 /* Default value instead of permissions? */ \
147180 static int __param_perm_check_##name __attribute__((unused)) = \
148181 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \
@@ -151,15 +184,15 @@ struct kparam_array
151184 static struct kernel_param __moduleparam_const __param_##name \
152185 __used \
153186 __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
154- = { __param_str_##name, ops, perm, 0 , { arg } }
187+ = { __param_str_##name, ops, perm, level , { arg } }
155188
156189/* Obsolete - use module_param_cb() */
157190#define module_param_call (name , set , get , arg , perm ) \
158191 static struct kernel_param_ops __param_ops_##name = \
159192 { (void *)set, (void *)get }; \
160193 __module_param_call(MODULE_PARAM_PREFIX, \
161194 name, &__param_ops_##name, arg, \
162- (perm) + sizeof(__check_old_set_param(set))*0)
195+ (perm) + sizeof(__check_old_set_param(set))*0, 0 )
163196
164197/* We don't get oldget: it's often a new-style param_get_uint, etc. */
165198static inline int
@@ -239,7 +272,7 @@ static inline void __kernel_param_unlock(void)
239272 */
240273#define core_param (name , var , type , perm ) \
241274 param_check_##type(name, &(var)); \
242- __module_param_call("", name, ¶m_ops_##type, &var, perm)
275+ __module_param_call("", name, ¶m_ops_##type, &var, perm, 0 )
243276#endif /* !MODULE */
244277
245278/**
@@ -257,7 +290,7 @@ static inline void __kernel_param_unlock(void)
257290 = { len, string }; \
258291 __module_param_call(MODULE_PARAM_PREFIX, name, \
259292 ¶m_ops_string, \
260- .str = &__param_string_##name, perm); \
293+ .str = &__param_string_##name, perm, 0 ); \
261294 __MODULE_PARM_TYPE(name, "string")
262295
263296/**
@@ -285,6 +318,8 @@ extern int parse_args(const char *name,
285318 char * args ,
286319 const struct kernel_param * params ,
287320 unsigned num ,
321+ s16 level_min ,
322+ s16 level_max ,
288323 int (* unknown )(char * param , char * val ));
289324
290325/* Called by module remove. */
@@ -396,7 +431,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
396431 __module_param_call(MODULE_PARAM_PREFIX, name, \
397432 ¶m_array_ops, \
398433 .arr = &__param_arr_##name, \
399- perm); \
434+ perm, 0 ); \
400435 __MODULE_PARM_TYPE(name, "array of " #type)
401436
402437extern struct kernel_param_ops param_array_ops ;
0 commit comments