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

[Xen-changelog] [xen-unstable] consolidate custom parameter parsing routines looking for boolean values



# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1290173154 0
# Node ID 437576a0f2026ded6dcc4b11558714dad1d1d042
# Parent  ff98da15205f18744bc01a32df7cb983ca69e115
consolidate custom parameter parsing routines looking for boolean values

Have a single function for this, rather than doing the same in half a
dozen places.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/arch/x86/cpu/amd.c                |   15 ++++++++++-----
 xen/arch/x86/setup.c                  |    2 +-
 xen/arch/x86/x86_64/mmconfig-shared.c |    3 +--
 xen/common/kernel.c                   |   26 +++++++++++++++++++++-----
 xen/drivers/passthrough/iommu.c       |    3 +--
 xen/drivers/passthrough/vtd/x86/ats.c |   12 +++++++-----
 xen/include/xen/lib.h                 |    1 +
 7 files changed, 42 insertions(+), 20 deletions(-)

diff -r ff98da15205f -r 437576a0f202 xen/arch/x86/cpu/amd.c
--- a/xen/arch/x86/cpu/amd.c    Fri Nov 19 13:24:00 2010 +0000
+++ b/xen/arch/x86/cpu/amd.c    Fri Nov 19 13:25:54 2010 +0000
@@ -240,13 +240,18 @@ int cpu_has_amd_erratum(const struct cpu
  * amd_flush_filter={on,off}. Forcibly Enable or disable the TLB flush
  * filter on AMD 64-bit processors.
  */
-static int flush_filter_force;
-static void flush_filter(char *s)
-{
-       if (!strcmp(s, "off"))
+static int __read_mostly flush_filter_force;
+static void __init flush_filter(char *s)
+{
+       switch (parse_bool(s))
+       {
+       case 0:
                flush_filter_force = -1;
-       if (!strcmp(s, "on"))
+               break;
+       case 1:
                flush_filter_force = 1;
+               break;
+       }
 }
 custom_param("amd_flush_filter", flush_filter);
 
diff -r ff98da15205f -r 437576a0f202 xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      Fri Nov 19 13:24:00 2010 +0000
+++ b/xen/arch/x86/setup.c      Fri Nov 19 13:25:54 2010 +0000
@@ -113,7 +113,7 @@ static void __init parse_acpi_param(char
     safe_strcpy(acpi_param, s);
 
     /* Interpret the parameter for use within Xen. */
-    if ( !strcmp(s, "off") )
+    if ( !parse_bool(s) )
     {
         disable_acpi();
     }
diff -r ff98da15205f -r 437576a0f202 xen/arch/x86/x86_64/mmconfig-shared.c
--- a/xen/arch/x86/x86_64/mmconfig-shared.c     Fri Nov 19 13:24:00 2010 +0000
+++ b/xen/arch/x86/x86_64/mmconfig-shared.c     Fri Nov 19 13:25:54 2010 +0000
@@ -37,8 +37,7 @@ static void __init parse_mmcfg(char *s)
         if ( ss )
             *ss = '\0';
 
-        if ( !strcmp(s, "off") || !strcmp(s, "no") || !strcmp(s, "false") ||
-             !strcmp(s, "0") || !strcmp(s, "disable") )
+        if ( !parse_bool(s) )
             pci_probe &= ~PCI_PROBE_MMCONF;
         else if ( !strcmp(s, "amd_fam10") || !strcmp(s, "amd-fam10") )
             pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF;
diff -r ff98da15205f -r 437576a0f202 xen/common/kernel.c
--- a/xen/common/kernel.c       Fri Nov 19 13:24:00 2010 +0000
+++ b/xen/common/kernel.c       Fri Nov 19 13:25:54 2010 +0000
@@ -26,7 +26,7 @@ int tainted;
 
 xen_commandline_t saved_cmdline;
 
-void cmdline_parse(char *cmdline)
+void __init cmdline_parse(char *cmdline)
 {
     char opt[100], *optval, *optkey, *q;
     const char *p = cmdline;
@@ -83,10 +83,7 @@ void cmdline_parse(char *cmdline)
                 break;
             case OPT_BOOL:
             case OPT_INVBOOL:
-                if ( !strcmp("no", optval) ||
-                     !strcmp("off", optval) ||
-                     !strcmp("false", optval) ||
-                     !strcmp("0", optval) )
+                if ( !parse_bool(optval) )
                     bool_assert = !bool_assert;
                 if ( param->type == OPT_INVBOOL )
                     bool_assert = !bool_assert;
@@ -113,6 +110,25 @@ void cmdline_parse(char *cmdline)
             }
         }
     }
+}
+
+int __init parse_bool(const char *s)
+{
+    if ( !strcmp("no", s) ||
+         !strcmp("off", s) ||
+         !strcmp("false", s) ||
+         !strcmp("disable", s) ||
+         !strcmp("0", s) )
+        return 0;
+
+    if ( !strcmp("yes", s) ||
+         !strcmp("on", s) ||
+         !strcmp("true", s) ||
+         !strcmp("enable", s) ||
+         !strcmp("1", s) )
+        return 1;
+
+    return -1;
 }
 
 /**
diff -r ff98da15205f -r 437576a0f202 xen/drivers/passthrough/iommu.c
--- a/xen/drivers/passthrough/iommu.c   Fri Nov 19 13:24:00 2010 +0000
+++ b/xen/drivers/passthrough/iommu.c   Fri Nov 19 13:25:54 2010 +0000
@@ -59,8 +59,7 @@ static void __init parse_iommu_param(cha
         if ( ss )
             *ss = '\0';
 
-        if ( !strcmp(s, "off") || !strcmp(s, "no") || !strcmp(s, "false") ||
-             !strcmp(s, "0") || !strcmp(s, "disable") )
+        if ( !parse_bool(s) )
             iommu_enabled = 0;
         else if ( !strcmp(s, "force") || !strcmp(s, "required") )
             force_iommu = 1;
diff -r ff98da15205f -r 437576a0f202 xen/drivers/passthrough/vtd/x86/ats.c
--- a/xen/drivers/passthrough/vtd/x86/ats.c     Fri Nov 19 13:24:00 2010 +0000
+++ b/xen/drivers/passthrough/vtd/x86/ats.c     Fri Nov 19 13:25:54 2010 +0000
@@ -58,13 +58,15 @@ static void __init parse_ats_param(char 
         if ( ss )
             *ss = '\0';
 
-        if ( !strcmp(s, "off") || !strcmp(s, "no") || !strcmp(s, "false") ||
-             !strcmp(s, "0") || !strcmp(s, "disable") )
+        switch ( parse_bool(s) )
+        {
+        case 0:
             ats_enabled = 0;
-
-        if ( !strcmp(s, "on") || !strcmp(s, "yes") || !strcmp(s, "true") ||
-             !strcmp(s, "1") || !strcmp(s, "enable") )
+            break;
+        case 1:
             ats_enabled = 1;
+            break;
+        }
 
         s = ss + 1;
     } while ( ss );
diff -r ff98da15205f -r 437576a0f202 xen/include/xen/lib.h
--- a/xen/include/xen/lib.h     Fri Nov 19 13:24:00 2010 +0000
+++ b/xen/include/xen/lib.h     Fri Nov 19 13:25:54 2010 +0000
@@ -57,6 +57,7 @@ struct domain;
 struct domain;
 
 void cmdline_parse(char *cmdline);
+int parse_bool(const char *s);
 
 /*#define DEBUG_TRACE_DUMP*/
 #ifdef DEBUG_TRACE_DUMP

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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