aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2008-03-02 09:27:55 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2008-10-21 07:47:49 -0400
commita4af9b48cb480f5016947bbd3f396c265c7cb368 (patch)
treec387f4af76dfc90156bb3760c6d554964f5e3d90
parent47844fadb5050a6fb90924e73eb2dea1afd7fe33 (diff)
[PATCH] switch floppy
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/block/floppy.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 72363df58953..14db747a636e 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3450,14 +3450,14 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
3450 return 0; 3450 return 0;
3451} 3451}
3452 3452
3453static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 3453static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
3454 unsigned long param) 3454 unsigned long param)
3455{ 3455{
3456#define FD_IOCTL_ALLOWED ((filp) && (filp)->f_mode & (FMODE_WRITE|FMODE_WRITE_IOCTL)) 3456#define FD_IOCTL_ALLOWED (mode & (FMODE_WRITE|FMODE_WRITE_IOCTL))
3457#define OUT(c,x) case c: outparam = (const char *) (x); break 3457#define OUT(c,x) case c: outparam = (const char *) (x); break
3458#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0 3458#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
3459 3459
3460 int drive = (long)inode->i_bdev->bd_disk->private_data; 3460 int drive = (long)bdev->bd_disk->private_data;
3461 int type = ITYPE(UDRS->fd_device); 3461 int type = ITYPE(UDRS->fd_device);
3462 int i; 3462 int i;
3463 int ret; 3463 int ret;
@@ -3516,11 +3516,11 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
3516 current_type[drive] = NULL; 3516 current_type[drive] = NULL;
3517 floppy_sizes[drive] = MAX_DISK_SIZE << 1; 3517 floppy_sizes[drive] = MAX_DISK_SIZE << 1;
3518 UDRS->keep_data = 0; 3518 UDRS->keep_data = 0;
3519 return invalidate_drive(inode->i_bdev); 3519 return invalidate_drive(bdev);
3520 case FDSETPRM: 3520 case FDSETPRM:
3521 case FDDEFPRM: 3521 case FDDEFPRM:
3522 return set_geometry(cmd, &inparam.g, 3522 return set_geometry(cmd, &inparam.g,
3523 drive, type, inode->i_bdev); 3523 drive, type, bdev);
3524 case FDGETPRM: 3524 case FDGETPRM:
3525 ECALL(get_floppy_geometry(drive, type, 3525 ECALL(get_floppy_geometry(drive, type,
3526 (struct floppy_struct **) 3526 (struct floppy_struct **)
@@ -3551,7 +3551,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
3551 case FDFMTEND: 3551 case FDFMTEND:
3552 case FDFLUSH: 3552 case FDFLUSH:
3553 LOCK_FDC(drive, 1); 3553 LOCK_FDC(drive, 1);
3554 return invalidate_drive(inode->i_bdev); 3554 return invalidate_drive(bdev);
3555 3555
3556 case FDSETEMSGTRESH: 3556 case FDSETEMSGTRESH:
3557 UDP->max_errors.reporting = 3557 UDP->max_errors.reporting =
@@ -3659,9 +3659,9 @@ static void __init config_types(void)
3659 printk("\n"); 3659 printk("\n");
3660} 3660}
3661 3661
3662static int floppy_release(struct inode *inode, struct file *filp) 3662static int floppy_release(struct gendisk *disk, fmode_t mode)
3663{ 3663{
3664 int drive = (long)inode->i_bdev->bd_disk->private_data; 3664 int drive = (long)disk->private_data;
3665 3665
3666 mutex_lock(&open_lock); 3666 mutex_lock(&open_lock);
3667 if (UDRS->fd_ref < 0) 3667 if (UDRS->fd_ref < 0)
@@ -3682,17 +3682,17 @@ static int floppy_release(struct inode *inode, struct file *filp)
3682 * /dev/PS0 etc), and disallows simultaneous access to the same 3682 * /dev/PS0 etc), and disallows simultaneous access to the same
3683 * drive with different device numbers. 3683 * drive with different device numbers.
3684 */ 3684 */
3685static int floppy_open(struct inode *inode, struct file *filp) 3685static int floppy_open(struct block_device *bdev, fmode_t mode)
3686{ 3686{
3687 int drive = (long)inode->i_bdev->bd_disk->private_data; 3687 int drive = (long)bdev->bd_disk->private_data;
3688 int old_dev; 3688 int old_dev, new_dev;
3689 int try; 3689 int try;
3690 int res = -EBUSY; 3690 int res = -EBUSY;
3691 char *tmp; 3691 char *tmp;
3692 3692
3693 mutex_lock(&open_lock); 3693 mutex_lock(&open_lock);
3694 old_dev = UDRS->fd_device; 3694 old_dev = UDRS->fd_device;
3695 if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) 3695 if (opened_bdev[drive] && opened_bdev[drive] != bdev)
3696 goto out2; 3696 goto out2;
3697 3697
3698 if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)) { 3698 if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)) {
@@ -3700,15 +3700,15 @@ static int floppy_open(struct inode *inode, struct file *filp)
3700 USETF(FD_VERIFY); 3700 USETF(FD_VERIFY);
3701 } 3701 }
3702 3702
3703 if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_mode & FMODE_EXCL))) 3703 if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (mode & FMODE_EXCL)))
3704 goto out2; 3704 goto out2;
3705 3705
3706 if (filp->f_mode & FMODE_EXCL) 3706 if (mode & FMODE_EXCL)
3707 UDRS->fd_ref = -1; 3707 UDRS->fd_ref = -1;
3708 else 3708 else
3709 UDRS->fd_ref++; 3709 UDRS->fd_ref++;
3710 3710
3711 opened_bdev[drive] = inode->i_bdev; 3711 opened_bdev[drive] = bdev;
3712 3712
3713 res = -ENXIO; 3713 res = -ENXIO;
3714 3714
@@ -3743,9 +3743,10 @@ static int floppy_open(struct inode *inode, struct file *filp)
3743 } 3743 }
3744 } 3744 }
3745 3745
3746 UDRS->fd_device = iminor(inode); 3746 new_dev = MINOR(bdev->bd_dev);
3747 set_capacity(disks[drive], floppy_sizes[iminor(inode)]); 3747 UDRS->fd_device = new_dev;
3748 if (old_dev != -1 && old_dev != iminor(inode)) { 3748 set_capacity(disks[drive], floppy_sizes[new_dev]);
3749 if (old_dev != -1 && old_dev != new_dev) {
3749 if (buffer_drive == drive) 3750 if (buffer_drive == drive)
3750 buffer_track = -1; 3751 buffer_track = -1;
3751 } 3752 }
@@ -3753,15 +3754,15 @@ static int floppy_open(struct inode *inode, struct file *filp)
3753 if (UFDCS->rawcmd == 1) 3754 if (UFDCS->rawcmd == 1)
3754 UFDCS->rawcmd = 2; 3755 UFDCS->rawcmd = 2;
3755 3756
3756 if (!(filp->f_mode & FMODE_NDELAY)) { 3757 if (!(mode & FMODE_NDELAY)) {
3757 if (filp->f_mode & (FMODE_READ|FMODE_WRITE)) { 3758 if (mode & (FMODE_READ|FMODE_WRITE)) {
3758 UDRS->last_checked = 0; 3759 UDRS->last_checked = 0;
3759 check_disk_change(inode->i_bdev); 3760 check_disk_change(bdev);
3760 if (UTESTF(FD_DISK_CHANGED)) 3761 if (UTESTF(FD_DISK_CHANGED))
3761 goto out; 3762 goto out;
3762 } 3763 }
3763 res = -EROFS; 3764 res = -EROFS;
3764 if ((filp->f_mode & FMODE_WRITE) && !(UTESTF(FD_DISK_WRITABLE))) 3765 if ((mode & FMODE_WRITE) && !(UTESTF(FD_DISK_WRITABLE)))
3765 goto out; 3766 goto out;
3766 } 3767 }
3767 mutex_unlock(&open_lock); 3768 mutex_unlock(&open_lock);
@@ -3902,9 +3903,9 @@ static int floppy_revalidate(struct gendisk *disk)
3902 3903
3903static struct block_device_operations floppy_fops = { 3904static struct block_device_operations floppy_fops = {
3904 .owner = THIS_MODULE, 3905 .owner = THIS_MODULE,
3905 .__open = floppy_open, 3906 .open = floppy_open,
3906 .__release = floppy_release, 3907 .release = floppy_release,
3907 .__ioctl = fd_ioctl, 3908 .locked_ioctl = fd_ioctl,
3908 .getgeo = fd_getgeo, 3909 .getgeo = fd_getgeo,
3909 .media_changed = check_floppy_change, 3910 .media_changed = check_floppy_change,
3910 .revalidate_disk = floppy_revalidate, 3911 .revalidate_disk = floppy_revalidate,