]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/block/amiflop.c
block: push down BKL into .open and .release
[mirror_ubuntu-zesty-kernel.git] / drivers / block / amiflop.c
index 0fa26359304ce76e0212e8b284e1d9f1db0378e3..76f114f0bba32f5d0396ac9b2a1ec2a88963f7c1 100644 (file)
@@ -1555,10 +1555,13 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
        int old_dev;
        unsigned long flags;
 
+       lock_kernel();
        old_dev = fd_device[drive];
 
-       if (fd_ref[drive] && old_dev != system)
+       if (fd_ref[drive] && old_dev != system) {
+               unlock_kernel();
                return -EBUSY;
+       }
 
        if (mode & (FMODE_READ|FMODE_WRITE)) {
                check_disk_change(bdev);
@@ -1571,8 +1574,10 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
                        fd_deselect (drive);
                        rel_fdc();
 
-                       if (wrprot)
+                       if (wrprot) {
+                               unlock_kernel();
                                return -EROFS;
+                       }
                }
        }
 
@@ -1589,6 +1594,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
        printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive,
               unit[drive].type->name, data_types[system].name);
 
+       unlock_kernel();
        return 0;
 }
 
@@ -1597,6 +1603,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
        struct amiga_floppy_struct *p = disk->private_data;
        int drive = p - unit;
 
+       lock_kernel();
        if (unit[drive].dirty == 1) {
                del_timer (flush_track_timer + drive);
                non_int_flush_track (drive);
@@ -1610,6 +1617,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
 /* the mod_use counter is handled this way */
        floppy_off (drive | 0x40000000);
 #endif
+       unlock_kernel();
        return 0;
 }