diff options
author | Luis R. Rodriguez <mcgrof@suse.com> | 2015-03-30 19:20:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-05-20 03:25:24 -0400 |
commit | ecc8617053e0a97272ef2eee138809f30080e84b (patch) | |
tree | f9433e1dd51aea5b6f66db03460a9f2c1c3f4f4d /init/main.c | |
parent | 6570a9a1ce3a1dd227a065fd8ad16778d827b753 (diff) |
module: add extra argument for parse_params() callback
This adds an extra argument onto parse_params() to be used
as a way to make the unused callback a bit more useful and
generic by allowing the caller to pass on a data structure
of its choice. An example use case is to allow us to easily
make module parameters for every module which we will do
next.
@ parse @
identifier name, args, params, num, level_min, level_max;
identifier unknown, param, val, doing;
type s16;
@@
extern char *parse_args(const char *name,
char *args,
const struct kernel_param *params,
unsigned num,
s16 level_min,
s16 level_max,
+ void *arg,
int (*unknown)(char *param, char *val,
const char *doing
+ , void *arg
));
@ parse_mod @
identifier name, args, params, num, level_min, level_max;
identifier unknown, param, val, doing;
type s16;
@@
char *parse_args(const char *name,
char *args,
const struct kernel_param *params,
unsigned num,
s16 level_min,
s16 level_max,
+ void *arg,
int (*unknown)(char *param, char *val,
const char *doing
+ , void *arg
))
{
...
}
@ parse_args_found @
expression R, E1, E2, E3, E4, E5, E6;
identifier func;
@@
(
R =
parse_args(E1, E2, E3, E4, E5, E6,
+ NULL,
func);
|
R =
parse_args(E1, E2, E3, E4, E5, E6,
+ NULL,
&func);
|
R =
parse_args(E1, E2, E3, E4, E5, E6,
+ NULL,
NULL);
|
parse_args(E1, E2, E3, E4, E5, E6,
+ NULL,
func);
|
parse_args(E1, E2, E3, E4, E5, E6,
+ NULL,
&func);
|
parse_args(E1, E2, E3, E4, E5, E6,
+ NULL,
NULL);
)
@ parse_args_unused depends on parse_args_found @
identifier parse_args_found.func;
@@
int func(char *param, char *val, const char *unused
+ , void *arg
)
{
...
}
@ mod_unused depends on parse_args_found @
identifier parse_args_found.func;
expression A1, A2, A3;
@@
- func(A1, A2, A3);
+ func(A1, A2, A3, NULL);
Generated-by: Coccinelle SmPL
Cc: cocci@systeme.lip6.fr
Cc: Tejun Heo <tj@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Felipe Contreras <felipe.contreras@gmail.com>
Cc: Ewan Milne <emilne@redhat.com>
Cc: Jean Delvare <jdelvare@suse.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Tejun Heo <tj@kernel.org>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'init/main.c')
-rw-r--r-- | init/main.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/init/main.c b/init/main.c index 2115055faeac..edcb13440646 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -235,7 +235,8 @@ static int __init loglevel(char *str) | |||
235 | early_param("loglevel", loglevel); | 235 | early_param("loglevel", loglevel); |
236 | 236 | ||
237 | /* Change NUL term back to "=", to make "param" the whole string. */ | 237 | /* Change NUL term back to "=", to make "param" the whole string. */ |
238 | static int __init repair_env_string(char *param, char *val, const char *unused) | 238 | static int __init repair_env_string(char *param, char *val, |
239 | const char *unused, void *arg) | ||
239 | { | 240 | { |
240 | if (val) { | 241 | if (val) { |
241 | /* param=val or param="val"? */ | 242 | /* param=val or param="val"? */ |
@@ -252,14 +253,15 @@ static int __init repair_env_string(char *param, char *val, const char *unused) | |||
252 | } | 253 | } |
253 | 254 | ||
254 | /* Anything after -- gets handed straight to init. */ | 255 | /* Anything after -- gets handed straight to init. */ |
255 | static int __init set_init_arg(char *param, char *val, const char *unused) | 256 | static int __init set_init_arg(char *param, char *val, |
257 | const char *unused, void *arg) | ||
256 | { | 258 | { |
257 | unsigned int i; | 259 | unsigned int i; |
258 | 260 | ||
259 | if (panic_later) | 261 | if (panic_later) |
260 | return 0; | 262 | return 0; |
261 | 263 | ||
262 | repair_env_string(param, val, unused); | 264 | repair_env_string(param, val, unused, NULL); |
263 | 265 | ||
264 | for (i = 0; argv_init[i]; i++) { | 266 | for (i = 0; argv_init[i]; i++) { |
265 | if (i == MAX_INIT_ARGS) { | 267 | if (i == MAX_INIT_ARGS) { |
@@ -276,9 +278,10 @@ static int __init set_init_arg(char *param, char *val, const char *unused) | |||
276 | * Unknown boot options get handed to init, unless they look like | 278 | * Unknown boot options get handed to init, unless they look like |
277 | * unused parameters (modprobe will find them in /proc/cmdline). | 279 | * unused parameters (modprobe will find them in /proc/cmdline). |
278 | */ | 280 | */ |
279 | static int __init unknown_bootoption(char *param, char *val, const char *unused) | 281 | static int __init unknown_bootoption(char *param, char *val, |
282 | const char *unused, void *arg) | ||
280 | { | 283 | { |
281 | repair_env_string(param, val, unused); | 284 | repair_env_string(param, val, unused, NULL); |
282 | 285 | ||
283 | /* Handle obsolete-style parameters */ | 286 | /* Handle obsolete-style parameters */ |
284 | if (obsolete_checksetup(param)) | 287 | if (obsolete_checksetup(param)) |
@@ -410,7 +413,8 @@ static noinline void __init_refok rest_init(void) | |||
410 | } | 413 | } |
411 | 414 | ||
412 | /* Check for early params. */ | 415 | /* Check for early params. */ |
413 | static int __init do_early_param(char *param, char *val, const char *unused) | 416 | static int __init do_early_param(char *param, char *val, |
417 | const char *unused, void *arg) | ||
414 | { | 418 | { |
415 | const struct obs_kernel_param *p; | 419 | const struct obs_kernel_param *p; |
416 | 420 | ||
@@ -429,7 +433,8 @@ static int __init do_early_param(char *param, char *val, const char *unused) | |||
429 | 433 | ||
430 | void __init parse_early_options(char *cmdline) | 434 | void __init parse_early_options(char *cmdline) |
431 | { | 435 | { |
432 | parse_args("early options", cmdline, NULL, 0, 0, 0, do_early_param); | 436 | parse_args("early options", cmdline, NULL, 0, 0, 0, NULL, |
437 | do_early_param); | ||
433 | } | 438 | } |
434 | 439 | ||
435 | /* Arch code calls this early on, or if not, just before other parsing. */ | 440 | /* Arch code calls this early on, or if not, just before other parsing. */ |
@@ -535,10 +540,10 @@ asmlinkage __visible void __init start_kernel(void) | |||
535 | after_dashes = parse_args("Booting kernel", | 540 | after_dashes = parse_args("Booting kernel", |
536 | static_command_line, __start___param, | 541 | static_command_line, __start___param, |
537 | __stop___param - __start___param, | 542 | __stop___param - __start___param, |
538 | -1, -1, &unknown_bootoption); | 543 | -1, -1, NULL, &unknown_bootoption); |
539 | if (!IS_ERR_OR_NULL(after_dashes)) | 544 | if (!IS_ERR_OR_NULL(after_dashes)) |
540 | parse_args("Setting init args", after_dashes, NULL, 0, -1, -1, | 545 | parse_args("Setting init args", after_dashes, NULL, 0, -1, -1, |
541 | set_init_arg); | 546 | NULL, set_init_arg); |
542 | 547 | ||
543 | jump_label_init(); | 548 | jump_label_init(); |
544 | 549 | ||
@@ -847,7 +852,7 @@ static void __init do_initcall_level(int level) | |||
847 | initcall_command_line, __start___param, | 852 | initcall_command_line, __start___param, |
848 | __stop___param - __start___param, | 853 | __stop___param - __start___param, |
849 | level, level, | 854 | level, level, |
850 | &repair_env_string); | 855 | NULL, &repair_env_string); |
851 | 856 | ||
852 | for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) | 857 | for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) |
853 | do_one_initcall(*fn); | 858 | do_one_initcall(*fn); |