aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/swim.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/swim.c')
-rw-r--r--drivers/block/swim.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index e463657569ff..2e46815876df 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -20,6 +20,7 @@
20#include <linux/fd.h> 20#include <linux/fd.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/blkdev.h> 22#include <linux/blkdev.h>
23#include <linux/smp_lock.h>
23#include <linux/hdreg.h> 24#include <linux/hdreg.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
@@ -661,11 +662,23 @@ out:
661 return err; 662 return err;
662} 663}
663 664
665static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode)
666{
667 int ret;
668
669 lock_kernel();
670 ret = floppy_open(bdev, mode);
671 unlock_kernel();
672
673 return ret;
674}
675
664static int floppy_release(struct gendisk *disk, fmode_t mode) 676static int floppy_release(struct gendisk *disk, fmode_t mode)
665{ 677{
666 struct floppy_state *fs = disk->private_data; 678 struct floppy_state *fs = disk->private_data;
667 struct swim __iomem *base = fs->swd->base; 679 struct swim __iomem *base = fs->swd->base;
668 680
681 lock_kernel();
669 if (fs->ref_count < 0) 682 if (fs->ref_count < 0)
670 fs->ref_count = 0; 683 fs->ref_count = 0;
671 else if (fs->ref_count > 0) 684 else if (fs->ref_count > 0)
@@ -673,6 +686,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
673 686
674 if (fs->ref_count == 0) 687 if (fs->ref_count == 0)
675 swim_motor(base, OFF); 688 swim_motor(base, OFF);
689 unlock_kernel();
676 690
677 return 0; 691 return 0;
678} 692}
@@ -690,7 +704,9 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode,
690 case FDEJECT: 704 case FDEJECT:
691 if (fs->ref_count != 1) 705 if (fs->ref_count != 1)
692 return -EBUSY; 706 return -EBUSY;
707 lock_kernel();
693 err = floppy_eject(fs); 708 err = floppy_eject(fs);
709 unlock_kernel();
694 return err; 710 return err;
695 711
696 case FDGETPRM: 712 case FDGETPRM:
@@ -751,9 +767,9 @@ static int floppy_revalidate(struct gendisk *disk)
751 767
752static const struct block_device_operations floppy_fops = { 768static const struct block_device_operations floppy_fops = {
753 .owner = THIS_MODULE, 769 .owner = THIS_MODULE,
754 .open = floppy_open, 770 .open = floppy_unlocked_open,
755 .release = floppy_release, 771 .release = floppy_release,
756 .locked_ioctl = floppy_ioctl, 772 .ioctl = floppy_ioctl,
757 .getgeo = floppy_getgeo, 773 .getgeo = floppy_getgeo,
758 .media_changed = floppy_check_change, 774 .media_changed = floppy_check_change,
759 .revalidate_disk = floppy_revalidate, 775 .revalidate_disk = floppy_revalidate,