]> git.karo-electronics.de Git - linux-beck.git/commitdiff
xen: make use of xenbus_read_unsigned() in xenbus
authorJuergen Gross <jgross@suse.com>
Mon, 31 Oct 2016 13:58:42 +0000 (14:58 +0100)
committerJuergen Gross <jgross@suse.com>
Mon, 7 Nov 2016 12:55:36 +0000 (13:55 +0100)
Use xenbus_read_unsigned() instead of xenbus_scanf() when possible.
This requires to change the type of the reads from int to unsigned,
but these cases have been wrong before: negative values are not allowed
for the modified cases.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: David Vrabel <david.vrabel@citrix.com>
drivers/xen/xenbus/xenbus_probe_backend.c
drivers/xen/xenbus/xenbus_xs.c

index 04f7f85a5edf88ae21a01c6acae092b3a17c5a83..37929df829a31898fcf786398e71127b2e25d2bf 100644 (file)
@@ -224,13 +224,7 @@ static int read_frontend_details(struct xenbus_device *xendev)
 
 int xenbus_dev_is_online(struct xenbus_device *dev)
 {
-       int rc, val;
-
-       rc = xenbus_scanf(XBT_NIL, dev->nodename, "online", "%d", &val);
-       if (rc != 1)
-               val = 0; /* no online node present */
-
-       return val;
+       return !!xenbus_read_unsigned(dev->nodename, "online", 0);
 }
 EXPORT_SYMBOL_GPL(xenbus_dev_is_online);
 
index 99dfdfae42c6d1605a2d3276363a8251ad30876e..6afb993c58094448b1a2783845bd49028154cbfe 100644 (file)
@@ -687,7 +687,7 @@ static bool xen_strict_xenbus_quirk(void)
 }
 static void xs_reset_watches(void)
 {
-       int err, supported = 0;
+       int err;
 
        if (!xen_hvm_domain() || xen_initial_domain())
                return;
@@ -695,9 +695,8 @@ static void xs_reset_watches(void)
        if (xen_strict_xenbus_quirk())
                return;
 
-       err = xenbus_scanf(XBT_NIL, "control",
-                       "platform-feature-xs_reset_watches", "%d", &supported);
-       if (err != 1 || !supported)
+       if (!xenbus_read_unsigned("control",
+                                 "platform-feature-xs_reset_watches", 0))
                return;
 
        err = xs_error(xs_single(XBT_NIL, XS_RESET_WATCHES, "", NULL));