aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/amiflop.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/amiflop.c')
-rw-r--r--drivers/block/amiflop.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 832798aa14f6..76f114f0bba3 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -60,6 +60,7 @@
60#include <linux/hdreg.h> 60#include <linux/hdreg.h>
61#include <linux/delay.h> 61#include <linux/delay.h>
62#include <linux/init.h> 62#include <linux/init.h>
63#include <linux/smp_lock.h>
63#include <linux/amifdreg.h> 64#include <linux/amifdreg.h>
64#include <linux/amifd.h> 65#include <linux/amifd.h>
65#include <linux/buffer_head.h> 66#include <linux/buffer_head.h>
@@ -1423,7 +1424,7 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1423 return 0; 1424 return 0;
1424} 1425}
1425 1426
1426static int fd_ioctl(struct block_device *bdev, fmode_t mode, 1427static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,
1427 unsigned int cmd, unsigned long param) 1428 unsigned int cmd, unsigned long param)
1428{ 1429{
1429 struct amiga_floppy_struct *p = bdev->bd_disk->private_data; 1430 struct amiga_floppy_struct *p = bdev->bd_disk->private_data;
@@ -1500,6 +1501,18 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode,
1500 return 0; 1501 return 0;
1501} 1502}
1502 1503
1504static int fd_ioctl(struct block_device *bdev, fmode_t mode,
1505 unsigned int cmd, unsigned long param)
1506{
1507 int ret;
1508
1509 lock_kernel();
1510 ret = fd_locked_ioctl(bdev, mode, cmd, param);
1511 unlock_kernel();
1512
1513 return ret;
1514}
1515
1503static void fd_probe(int dev) 1516static void fd_probe(int dev)
1504{ 1517{
1505 unsigned long code; 1518 unsigned long code;
@@ -1542,10 +1555,13 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
1542 int old_dev; 1555 int old_dev;
1543 unsigned long flags; 1556 unsigned long flags;
1544 1557
1558 lock_kernel();
1545 old_dev = fd_device[drive]; 1559 old_dev = fd_device[drive];
1546 1560
1547 if (fd_ref[drive] && old_dev != system) 1561 if (fd_ref[drive] && old_dev != system) {
1562 unlock_kernel();
1548 return -EBUSY; 1563 return -EBUSY;
1564 }
1549 1565
1550 if (mode & (FMODE_READ|FMODE_WRITE)) { 1566 if (mode & (FMODE_READ|FMODE_WRITE)) {
1551 check_disk_change(bdev); 1567 check_disk_change(bdev);
@@ -1558,8 +1574,10 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
1558 fd_deselect (drive); 1574 fd_deselect (drive);
1559 rel_fdc(); 1575 rel_fdc();
1560 1576
1561 if (wrprot) 1577 if (wrprot) {
1578 unlock_kernel();
1562 return -EROFS; 1579 return -EROFS;
1580 }
1563 } 1581 }
1564 } 1582 }
1565 1583
@@ -1576,6 +1594,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
1576 printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive, 1594 printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive,
1577 unit[drive].type->name, data_types[system].name); 1595 unit[drive].type->name, data_types[system].name);
1578 1596
1597 unlock_kernel();
1579 return 0; 1598 return 0;
1580} 1599}
1581 1600
@@ -1584,6 +1603,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
1584 struct amiga_floppy_struct *p = disk->private_data; 1603 struct amiga_floppy_struct *p = disk->private_data;
1585 int drive = p - unit; 1604 int drive = p - unit;
1586 1605
1606 lock_kernel();
1587 if (unit[drive].dirty == 1) { 1607 if (unit[drive].dirty == 1) {
1588 del_timer (flush_track_timer + drive); 1608 del_timer (flush_track_timer + drive);
1589 non_int_flush_track (drive); 1609 non_int_flush_track (drive);
@@ -1597,6 +1617,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
1597/* the mod_use counter is handled this way */ 1617/* the mod_use counter is handled this way */
1598 floppy_off (drive | 0x40000000); 1618 floppy_off (drive | 0x40000000);
1599#endif 1619#endif
1620 unlock_kernel();
1600 return 0; 1621 return 0;
1601} 1622}
1602 1623
@@ -1638,7 +1659,7 @@ static const struct block_device_operations floppy_fops = {
1638 .owner = THIS_MODULE, 1659 .owner = THIS_MODULE,
1639 .open = floppy_open, 1660 .open = floppy_open,
1640 .release = floppy_release, 1661 .release = floppy_release,
1641 .locked_ioctl = fd_ioctl, 1662 .ioctl = fd_ioctl,
1642 .getgeo = fd_getgeo, 1663 .getgeo = fd_getgeo,
1643 .media_changed = amiga_floppy_change, 1664 .media_changed = amiga_floppy_change,
1644}; 1665};