diff mbox

[33/52] xen/drivers/passthrough/iommu.c: let custom parameter parsing routines return errno

Message ID 20170809070706.13481-34-jgross@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jürgen Groß Aug. 9, 2017, 7:06 a.m. UTC
Modify the custom parameter parsing routines in:

xen/drivers/passthrough/iommu.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 xen/drivers/passthrough/iommu.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 5e81813942..8a333e177e 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -21,7 +21,7 @@ 
 #include <xen/keyhandler.h>
 #include <xsm/xsm.h>
 
-static void parse_iommu_param(char *s);
+static int parse_iommu_param(char *s);
 static void iommu_dump_p2m_table(unsigned char key);
 
 unsigned int __read_mostly iommu_dev_iotlb_timeout = 1000;
@@ -78,10 +78,10 @@  DEFINE_SPINLOCK(iommu_pt_cleanup_lock);
 PAGE_LIST_HEAD(iommu_pt_cleanup_list);
 static struct tasklet iommu_pt_cleanup_tasklet;
 
-static void __init parse_iommu_param(char *s)
+static int __init parse_iommu_param(char *s)
 {
     char *ss;
-    int val;
+    int val, b, rc = 0;
 
     do {
         val = !!strncmp(s, "no-", 3);
@@ -92,8 +92,9 @@  static void __init parse_iommu_param(char *s)
         if ( ss )
             *ss = '\0';
 
-        if ( !parse_bool(s) )
-            iommu_enable = 0;
+        b = parse_bool(s);
+        if ( b >= 0 )
+            iommu_enable = b;
         else if ( !strcmp(s, "force") || !strcmp(s, "required") )
             force_iommu = val;
         else if ( !strcmp(s, "workaround_bios_bug") )
@@ -124,9 +125,13 @@  static void __init parse_iommu_param(char *s)
             iommu_dom0_strict = val;
         else if ( !strcmp(s, "sharept") )
             iommu_hap_pt_share = val;
+        else
+            rc = -EINVAL;
 
         s = ss + 1;
     } while ( ss );
+
+    return rc;
 }
 
 int iommu_domain_init(struct domain *d)