[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 31/52] 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>
Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/drivers/cpufreq/cpufreq.c      | 18 +++++++++++++-----
 xen/include/acpi/cpufreq/cpufreq.h |  2 +-
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c
index fd82ef5dce..daec558f97 100644
--- a/xen/drivers/cpufreq/cpufreq.c
+++ b/xen/drivers/cpufreq/cpufreq.c
@@ -62,7 +62,7 @@ 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 setup_cpufreq_option(char *str)
 {
     char *arg = strpbrk(str, ",:");
     int choice;
@@ -76,14 +76,14 @@ static void __init setup_cpufreq_option(char *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") )
     {
         xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX;
         cpufreq_controller = FREQCTL_none;
-        return;
+        return 0;
     }
 
     if ( choice > 0 || !strcmp(str, "xen") )
@@ -91,8 +91,10 @@ static void __init setup_cpufreq_option(char *str)
         xen_processor_pmbits |= XEN_PROCESSOR_PM_PX;
         cpufreq_controller = FREQCTL_xen;
         if ( arg && *arg )
-            cpufreq_cmdline_parse(arg);
+            return cpufreq_cmdline_parse(arg);
     }
+
+    return (choice < 0) ? -EINVAL : 0;
 }
 custom_param("cpufreq", setup_cpufreq_option);
 
@@ -571,7 +573,7 @@ static int __init cpufreq_handle_common_option(const char 
*name, const char *val
     return 0;
 }
 
-void __init cpufreq_cmdline_parse(char *str)
+int __init cpufreq_cmdline_parse(char *str)
 {
     static struct cpufreq_governor *__initdata cpufreq_governors[] =
     {
@@ -582,6 +584,7 @@ void __init cpufreq_cmdline_parse(char *str)
         &cpufreq_gov_powersave
     };
     unsigned int gov_index = 0;
+    int rc = 0;
 
     do {
         char *val, *end = strchr(str, ',');
@@ -611,11 +614,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..5c41747cbf 100644
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/acpi/cpufreq/cpufreq.h
@@ -79,7 +79,7 @@ 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 *);
+int cpufreq_cmdline_parse(char *);
 
 #define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
 #define CPUFREQ_SHARED_TYPE_HW   (1) /* HW does needed coordination */
-- 
2.12.3


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.