[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v4 32/53] xen/drivers/cpufreq/cpufreq.c: let custom parameter parsing routines return errno
Modify the custom parameter parsing routines in: xen/drivers/cpufreq/cpufreq.c to indicate whether the parameter value was parsed successfully. Cc: Jan Beulich <jbeulich@xxxxxxxx> Signed-off-by: Juergen Gross <jgross@xxxxxxxx> --- V4: - add __initdata (Jan Beulich) - adapt parse_bool() call V3: - dont modify option value in handling function - remove prototype of cpufreq_cmdline_parse() from cpufreq.h and make it static --- xen/drivers/cpufreq/cpufreq.c | 39 +++++++++++++++++++++++++------------- xen/include/acpi/cpufreq/cpufreq.h | 2 -- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c index 5580bd370d..212f48f9f4 100644 --- a/xen/drivers/cpufreq/cpufreq.c +++ b/xen/drivers/cpufreq/cpufreq.c @@ -62,37 +62,41 @@ LIST_HEAD_READ_MOSTLY(cpufreq_governor_list); /* set xen as default cpufreq */ enum cpufreq_controller cpufreq_controller = FREQCTL_xen; -static void __init setup_cpufreq_option(char *str) +static int __init cpufreq_cmdline_parse(const char *s); + +static int __init setup_cpufreq_option(const char *str) { - char *arg = strpbrk(str, ",:"); + const char *arg = strpbrk(str, ",:"); int choice; - if ( arg ) - *arg++ = '\0'; - choice = parse_bool(str, NULL); + if ( !arg ) + arg = strchr(str, '\0'); + choice = parse_bool(str, arg); - if ( choice < 0 && !strcmp(str, "dom0-kernel") ) + if ( choice < 0 && !strncmp(str, "dom0-kernel", arg - str) ) { xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX; cpufreq_controller = FREQCTL_dom0_kernel; opt_dom0_vcpus_pin = 1; - return; + return 0; } - if ( choice == 0 || !strcmp(str, "none") ) + if ( choice == 0 || !strncmp(str, "none", arg - str) ) { xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX; cpufreq_controller = FREQCTL_none; - return; + return 0; } - if ( choice > 0 || !strcmp(str, "xen") ) + if ( choice > 0 || !strncmp(str, "xen", arg - str) ) { xen_processor_pmbits |= XEN_PROCESSOR_PM_PX; cpufreq_controller = FREQCTL_xen; - if ( arg && *arg ) - cpufreq_cmdline_parse(arg); + if ( *arg && *(arg + 1) ) + return cpufreq_cmdline_parse(arg + 1); } + + return (choice < 0) ? -EINVAL : 0; } custom_param("cpufreq", setup_cpufreq_option); @@ -571,7 +575,7 @@ static int __init cpufreq_handle_common_option(const char *name, const char *val return 0; } -void __init cpufreq_cmdline_parse(char *str) +static int __init cpufreq_cmdline_parse(const char *s) { static struct cpufreq_governor *__initdata cpufreq_governors[] = { @@ -581,8 +585,12 @@ void __init cpufreq_cmdline_parse(char *str) &cpufreq_gov_performance, &cpufreq_gov_powersave }; + static char __initdata buf[128]; + char *str = buf; unsigned int gov_index = 0; + int rc = 0; + strlcpy(buf, s, sizeof(buf)); do { char *val, *end = strchr(str, ','); unsigned int i; @@ -611,11 +619,16 @@ void __init cpufreq_cmdline_parse(char *str) if (str && !cpufreq_handle_common_option(str, val) && (!cpufreq_governors[gov_index]->handle_option || !cpufreq_governors[gov_index]->handle_option(str, val))) + { printk(XENLOG_WARNING "cpufreq/%s: option '%s' not recognized\n", cpufreq_governors[gov_index]->name, str); + rc = -EINVAL; + } str = end; } while (str); + + return rc; } static int cpu_callback( diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/cpufreq.h index 48ad1d0004..a5cd7d08a1 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -79,8 +79,6 @@ DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy); extern int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_policy *policy); -void cpufreq_cmdline_parse(char *); - #define CPUFREQ_SHARED_TYPE_NONE (0) /* None */ #define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */ #define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */ -- 2.12.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |