]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
xen/blkfront: reorder tests in xlblk_init()
authorJuergen Gross <jgross@suse.com>
Mon, 13 Aug 2018 14:01:12 +0000 (16:01 +0200)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 27 Aug 2018 16:12:03 +0000 (12:12 -0400)
In case we don't want pv block devices we should not test parameters
for sanity and eventually print out error messages. So test precluding
conditions before checking parameters.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/block/xen-blkfront.c

index a2a395f85a4156e2107241bea2b97c0f8fc371fa..a71d817e900ddc07ff45d240f0ae290ff408b6cd 100644 (file)
@@ -2708,6 +2708,15 @@ static int __init xlblk_init(void)
        if (!xen_domain())
                return -ENODEV;
 
+       if (!xen_has_pv_disk_devices())
+               return -ENODEV;
+
+       if (register_blkdev(XENVBD_MAJOR, DEV_NAME)) {
+               pr_warn("xen_blk: can't get major %d with name %s\n",
+                       XENVBD_MAJOR, DEV_NAME);
+               return -ENODEV;
+       }
+
        if (xen_blkif_max_segments < BLKIF_MAX_SEGMENTS_PER_REQUEST)
                xen_blkif_max_segments = BLKIF_MAX_SEGMENTS_PER_REQUEST;
 
@@ -2723,15 +2732,6 @@ static int __init xlblk_init(void)
                xen_blkif_max_queues = nr_cpus;
        }
 
-       if (!xen_has_pv_disk_devices())
-               return -ENODEV;
-
-       if (register_blkdev(XENVBD_MAJOR, DEV_NAME)) {
-               printk(KERN_WARNING "xen_blk: can't get major %d with name %s\n",
-                      XENVBD_MAJOR, DEV_NAME);
-               return -ENODEV;
-       }
-
        INIT_DELAYED_WORK(&blkfront_work, blkfront_delay_work);
 
        ret = xenbus_register_frontend(&blkfront_driver);