@@ -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';
+ if ( !arg )
+ arg = strchr(str, '\0');
choice = parse_bool(str);
- 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 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(
@@ -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 */
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@suse.com> Signed-off-by: Juergen Gross <jgross@suse.com> --- 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 | 37 +++++++++++++++++++++++++------------ xen/include/acpi/cpufreq/cpufreq.h | 2 -- 2 files changed, 25 insertions(+), 14 deletions(-)