]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xen: make use of xenbus_read_unsigned() in xen-tpmfront
authorJuergen Gross <jgross@suse.com>
Mon, 31 Oct 2016 13:58:40 +0000 (14:58 +0100)
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>
Fri, 3 Feb 2017 20:55:27 +0000 (15:55 -0500)
Use xenbus_read_unsigned() instead of xenbus_scanf() when possible.
This requires to change the type of one read from int to unsigned,
but this case has been wrong before: negative values are not allowed
for the modified case.

Cc: peterhuewe@gmx.de
Cc: tpmdd@selhorst.net
Cc: jarkko.sakkinen@linux.intel.com
Cc: jgunthorpe@obsidianresearch.com
Cc: tpmdd-devel@lists.sourceforge.net
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Acked-by: David Vrabel <david.vrabel@citrix.com>
OraBug: 25497392

(cherry picked from commit 0240933469ea4cc1aa1c32867349c4aa718fe264)
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
drivers/char/tpm/xen-tpmfront.c

index 3111f2778079dd49c0f8514d7852c06688a6c4f5..d34c85aa92d4f7ea91f80708bc0afc17c102e349 100644 (file)
@@ -335,18 +335,14 @@ static int tpmfront_resume(struct xenbus_device *dev)
 static void backend_changed(struct xenbus_device *dev,
                enum xenbus_state backend_state)
 {
-       int val;
-
        switch (backend_state) {
        case XenbusStateInitialised:
        case XenbusStateConnected:
                if (dev->state == XenbusStateConnected)
                        break;
 
-               if (xenbus_scanf(XBT_NIL, dev->otherend,
-                               "feature-protocol-v2", "%d", &val) < 0)
-                       val = 0;
-               if (!val) {
+               if (!xenbus_read_unsigned(dev->otherend, "feature-protocol-v2",
+                                         0)) {
                        xenbus_dev_fatal(dev, -EINVAL,
                                        "vTPM protocol 2 required");
                        return;