aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/amiflop.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index d5da4e3cb2ad..4b1d4ac960f1 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1437,10 +1437,11 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1437 return 0; 1437 return 0;
1438} 1438}
1439 1439
1440static int fd_ioctl(struct inode *inode, struct file *filp, 1440static int fd_ioctl(struct block_device *bdev, fmode_t mode,
1441 unsigned int cmd, unsigned long param) 1441 unsigned int cmd, unsigned long param)
1442{ 1442{
1443 int drive = iminor(inode) & 3; 1443 struct amiga_floppy_struct *p = bdev->bd_disk->private_data;
1444 int drive = p - unit;
1444 static struct floppy_struct getprm; 1445 static struct floppy_struct getprm;
1445 void __user *argp = (void __user *)param; 1446 void __user *argp = (void __user *)param;
1446 1447
@@ -1451,7 +1452,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp,
1451 rel_fdc(); 1452 rel_fdc();
1452 return -EBUSY; 1453 return -EBUSY;
1453 } 1454 }
1454 fsync_bdev(inode->i_bdev); 1455 fsync_bdev(bdev);
1455 if (fd_motor_on(drive) == 0) { 1456 if (fd_motor_on(drive) == 0) {
1456 rel_fdc(); 1457 rel_fdc();
1457 return -ENODEV; 1458 return -ENODEV;
@@ -1464,12 +1465,12 @@ static int fd_ioctl(struct inode *inode, struct file *filp,
1464 rel_fdc(); 1465 rel_fdc();
1465 break; 1466 break;
1466 case FDFMTTRK: 1467 case FDFMTTRK:
1467 if (param < unit[drive].type->tracks * unit[drive].type->heads) 1468 if (param < p->type->tracks * p->type->heads)
1468 { 1469 {
1469 get_fdc(drive); 1470 get_fdc(drive);
1470 if (fd_seek(drive,param) != 0){ 1471 if (fd_seek(drive,param) != 0){
1471 memset(unit[drive].trackbuf, FD_FILL_BYTE, 1472 memset(p->trackbuf, FD_FILL_BYTE,
1472 unit[drive].dtype->sects * unit[drive].type->sect_mult * 512); 1473 p->dtype->sects * p->type->sect_mult * 512);
1473 non_int_flush_track(drive); 1474 non_int_flush_track(drive);
1474 } 1475 }
1475 floppy_off(drive); 1476 floppy_off(drive);
@@ -1480,14 +1481,14 @@ static int fd_ioctl(struct inode *inode, struct file *filp,
1480 break; 1481 break;
1481 case FDFMTEND: 1482 case FDFMTEND:
1482 floppy_off(drive); 1483 floppy_off(drive);
1483 invalidate_bdev(inode->i_bdev); 1484 invalidate_bdev(bdev);
1484 break; 1485 break;
1485 case FDGETPRM: 1486 case FDGETPRM:
1486 memset((void *)&getprm, 0, sizeof (getprm)); 1487 memset((void *)&getprm, 0, sizeof (getprm));
1487 getprm.track=unit[drive].type->tracks; 1488 getprm.track=p->type->tracks;
1488 getprm.head=unit[drive].type->heads; 1489 getprm.head=p->type->heads;
1489 getprm.sect=unit[drive].dtype->sects * unit[drive].type->sect_mult; 1490 getprm.sect=p->dtype->sects * p->type->sect_mult;
1490 getprm.size=unit[drive].blocks; 1491 getprm.size=p->blocks;
1491 if (copy_to_user(argp, &getprm, sizeof(struct floppy_struct))) 1492 if (copy_to_user(argp, &getprm, sizeof(struct floppy_struct)))
1492 return -EFAULT; 1493 return -EFAULT;
1493 break; 1494 break;
@@ -1500,10 +1501,10 @@ static int fd_ioctl(struct inode *inode, struct file *filp,
1500 break; 1501 break;
1501#ifdef RAW_IOCTL 1502#ifdef RAW_IOCTL
1502 case IOCTL_RAW_TRACK: 1503 case IOCTL_RAW_TRACK:
1503 if (copy_to_user(argp, raw_buf, unit[drive].type->read_size)) 1504 if (copy_to_user(argp, raw_buf, p->type->read_size))
1504 return -EFAULT; 1505 return -EFAULT;
1505 else 1506 else
1506 return unit[drive].type->read_size; 1507 return p->type->read_size;
1507#endif 1508#endif
1508 default: 1509 default:
1509 printk(KERN_DEBUG "fd_ioctl: unknown cmd %d for drive %d.", 1510 printk(KERN_DEBUG "fd_ioctl: unknown cmd %d for drive %d.",
@@ -1548,10 +1549,10 @@ static void fd_probe(int dev)
1548 * /dev/PS0 etc), and disallows simultaneous access to the same 1549 * /dev/PS0 etc), and disallows simultaneous access to the same
1549 * drive with different device numbers. 1550 * drive with different device numbers.
1550 */ 1551 */
1551static int floppy_open(struct inode *inode, struct file *filp) 1552static int floppy_open(struct block_device *bdev, fmode_t mode)
1552{ 1553{
1553 int drive = iminor(inode) & 3; 1554 int drive = MINOR(bdev->bd_dev) & 3;
1554 int system = (iminor(inode) & 4) >> 2; 1555 int system = (MINOR(bdev->bd_dev) & 4) >> 2;
1555 int old_dev; 1556 int old_dev;
1556 unsigned long flags; 1557 unsigned long flags;
1557 1558
@@ -1560,9 +1561,9 @@ static int floppy_open(struct inode *inode, struct file *filp)
1560 if (fd_ref[drive] && old_dev != system) 1561 if (fd_ref[drive] && old_dev != system)
1561 return -EBUSY; 1562 return -EBUSY;
1562 1563
1563 if (filp && filp->f_mode & (FMODE_READ|FMODE_WRITE)) { 1564 if (mode & (FMODE_READ|FMODE_WRITE)) {
1564 check_disk_change(inode->i_bdev); 1565 check_disk_change(bdev);
1565 if (filp->f_mode & FMODE_WRITE ) { 1566 if (mode & FMODE_WRITE) {
1566 int wrprot; 1567 int wrprot;
1567 1568
1568 get_fdc(drive); 1569 get_fdc(drive);
@@ -1592,9 +1593,10 @@ static int floppy_open(struct inode *inode, struct file *filp)
1592 return 0; 1593 return 0;
1593} 1594}
1594 1595
1595static int floppy_release(struct inode * inode, struct file * filp) 1596static int floppy_release(struct gendisk *disk, fmode_t mode)
1596{ 1597{
1597 int drive = iminor(inode) & 3; 1598 struct amiga_floppy_struct *p = disk->private_data;
1599 int drive = p - unit;
1598 1600
1599 if (unit[drive].dirty == 1) { 1601 if (unit[drive].dirty == 1) {
1600 del_timer (flush_track_timer + drive); 1602 del_timer (flush_track_timer + drive);
@@ -1648,9 +1650,9 @@ static int amiga_floppy_change(struct gendisk *disk)
1648 1650
1649static struct block_device_operations floppy_fops = { 1651static struct block_device_operations floppy_fops = {
1650 .owner = THIS_MODULE, 1652 .owner = THIS_MODULE,
1651 .__open = floppy_open, 1653 .open = floppy_open,
1652 .__release = floppy_release, 1654 .release = floppy_release,
1653 .__ioctl = fd_ioctl, 1655 .locked_ioctl = fd_ioctl,
1654 .getgeo = fd_getgeo, 1656 .getgeo = fd_getgeo,
1655 .media_changed = amiga_floppy_change, 1657 .media_changed = amiga_floppy_change,
1656}; 1658};