In order to support generic parameter parsing carve out the parser from
_cmdline_parse(). As this generic function might be called after boot
remove the __init annotations from all called sub-functions.
Cc: Andrew Cooper
Cc: George Dunlap
Cc: Ian Jackson
Cc: Jan Beulich
Cc: Konrad Rzeszutek Wilk
Cc: Stefano Stabellini
Cc: Tim Deegan
Cc: Wei Liu
Signed-off-by: Juergen Gross
---
xen/common/kernel.c | 27 ---
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 3fd3abe79c..0d63685c4f 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -23,8 +23,7 @@ enum system_state system_state = SYS_STATE_early_boot;
xen_commandline_t saved_cmdline;
static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
-static int __init assign_integer_param(
-const struct kernel_param *param, uint64_t val)
+static int assign_integer_param(const struct kernel_param *param, uint64_t val)
{
unsigned int bits = param->len * 8;
@@ -50,12 +49,13 @@ static int __init assign_integer_param(
-EOVERFLOW : 0;
}
-static void __init _cmdline_parse(const char *cmdline)
+static int parse_params(const char *cmdline, const struct kernel_param *start,
+const struct kernel_param *end)
{
char opt[128], *optval, *optkey, *q;
const char *p = cmdline, *s;
const struct kernel_param *param;
-int bool_assert, rc = 0;
+int bool_assert, rc = 0, final_rc = 0;
for ( ; ; )
{
@@ -93,7 +93,7 @@ static void __init _cmdline_parse(const char *cmdline)
if ( !bool_assert )
optkey += 3;
-for ( param = __setup_start; param < __setup_end; param++ )
+for ( param = start; param < end; param++ )
{
if ( strcmp(param->name, optkey) )
{
@@ -158,11 +158,24 @@ static void __init _cmdline_parse(const char *cmdline)
}
if ( rc )
+{
printk("parameter \"%s\" has invalid value \"%s\"!\n", optkey,
optval);
-if ( param >= __setup_end )
+final_rc = rc;
+}
+if ( param >= end )
+{
printk("parameter \"%s\" unknown!\n", optkey);
+final_rc = -EINVAL;
+}
}
+
+return final_rc;
+}
+
+static void __init _cmdline_parse(const char *cmdline)
+{
+parse_params(cmdline, __setup_start, __setup_end);
}
/**
@@ -187,7 +200,7 @@ void __init cmdline_parse(const char *cmdline)
#endif
}
-int __init parse_bool(const char *s)
+int parse_bool(const char *s)
{
if ( !strcmp("no", s) ||
!strcmp("off", s) ||
--
2.12.3
___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel