]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/block/viodasd.c
block: push down BKL into .open and .release
[mirror_ubuntu-zesty-kernel.git] / drivers / block / viodasd.c
index 5663d3c284c81939f0e15f7a2c44998fdfbe7fce..f651e51a3319e0311f6a7bcc5e3d7e12d0e7d0e4 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/string.h>
+#include <linux/smp_lock.h>
 #include <linux/dma-mapping.h>
 #include <linux/completion.h>
 #include <linux/device.h>
@@ -175,6 +176,18 @@ static int viodasd_open(struct block_device *bdev, fmode_t mode)
        return 0;
 }
 
+static int viodasd_unlocked_open(struct block_device *bdev, fmode_t mode)
+{
+       int ret;
+
+       lock_kernel();
+       ret = viodasd_open(bdev, mode);
+       unlock_kernel();
+
+       return ret;
+}
+
+
 /*
  * External release entry point.
  */
@@ -183,6 +196,7 @@ static int viodasd_release(struct gendisk *disk, fmode_t mode)
        struct viodasd_device *d = disk->private_data;
        HvLpEvent_Rc hvrc;
 
+       lock_kernel();
        /* Send the event to OS/400.  We DON'T expect a response */
        hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp,
                        HvLpEvent_Type_VirtualIo,
@@ -195,6 +209,9 @@ static int viodasd_release(struct gendisk *disk, fmode_t mode)
                        0, 0, 0);
        if (hvrc != 0)
                pr_warning("HV close call failed %d\n", (int)hvrc);
+
+       unlock_kernel();
+
        return 0;
 }
 
@@ -219,7 +236,7 @@ static int viodasd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
  */
 static const struct block_device_operations viodasd_fops = {
        .owner = THIS_MODULE,
-       .open = viodasd_open,
+       .open = viodasd_unlocked_open,
        .release = viodasd_release,
        .getgeo = viodasd_getgeo,
 };