diff options
Diffstat (limited to 'drivers/block/pktcdvd.c')
-rw-r--r-- | drivers/block/pktcdvd.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 195ca7c720f5..f20bf359b84f 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -2320,7 +2320,7 @@ static int pkt_open_write(struct pktcdvd_device *pd) | |||
2320 | /* | 2320 | /* |
2321 | * called at open time. | 2321 | * called at open time. |
2322 | */ | 2322 | */ |
2323 | static int pkt_open_dev(struct pktcdvd_device *pd, int write) | 2323 | static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write) |
2324 | { | 2324 | { |
2325 | int ret; | 2325 | int ret; |
2326 | long lba; | 2326 | long lba; |
@@ -2332,7 +2332,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write) | |||
2332 | * so bdget() can't fail. | 2332 | * so bdget() can't fail. |
2333 | */ | 2333 | */ |
2334 | bdget(pd->bdev->bd_dev); | 2334 | bdget(pd->bdev->bd_dev); |
2335 | if ((ret = blkdev_get(pd->bdev, FMODE_READ, O_RDONLY))) | 2335 | if ((ret = blkdev_get(pd->bdev, FMODE_READ))) |
2336 | goto out; | 2336 | goto out; |
2337 | 2337 | ||
2338 | if ((ret = bd_claim(pd->bdev, pd))) | 2338 | if ((ret = bd_claim(pd->bdev, pd))) |
@@ -2381,7 +2381,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write) | |||
2381 | out_unclaim: | 2381 | out_unclaim: |
2382 | bd_release(pd->bdev); | 2382 | bd_release(pd->bdev); |
2383 | out_putdev: | 2383 | out_putdev: |
2384 | blkdev_put(pd->bdev); | 2384 | blkdev_put(pd->bdev, FMODE_READ); |
2385 | out: | 2385 | out: |
2386 | return ret; | 2386 | return ret; |
2387 | } | 2387 | } |
@@ -2399,7 +2399,7 @@ static void pkt_release_dev(struct pktcdvd_device *pd, int flush) | |||
2399 | 2399 | ||
2400 | pkt_set_speed(pd, MAX_SPEED, MAX_SPEED); | 2400 | pkt_set_speed(pd, MAX_SPEED, MAX_SPEED); |
2401 | bd_release(pd->bdev); | 2401 | bd_release(pd->bdev); |
2402 | blkdev_put(pd->bdev); | 2402 | blkdev_put(pd->bdev, FMODE_READ); |
2403 | 2403 | ||
2404 | pkt_shrink_pktlist(pd); | 2404 | pkt_shrink_pktlist(pd); |
2405 | } | 2405 | } |
@@ -2411,7 +2411,7 @@ static struct pktcdvd_device *pkt_find_dev_from_minor(int dev_minor) | |||
2411 | return pkt_devs[dev_minor]; | 2411 | return pkt_devs[dev_minor]; |
2412 | } | 2412 | } |
2413 | 2413 | ||
2414 | static int pkt_open(struct inode *inode, struct file *file) | 2414 | static int pkt_open(struct block_device *bdev, fmode_t mode) |
2415 | { | 2415 | { |
2416 | struct pktcdvd_device *pd = NULL; | 2416 | struct pktcdvd_device *pd = NULL; |
2417 | int ret; | 2417 | int ret; |
@@ -2419,7 +2419,7 @@ static int pkt_open(struct inode *inode, struct file *file) | |||
2419 | VPRINTK(DRIVER_NAME": entering open\n"); | 2419 | VPRINTK(DRIVER_NAME": entering open\n"); |
2420 | 2420 | ||
2421 | mutex_lock(&ctl_mutex); | 2421 | mutex_lock(&ctl_mutex); |
2422 | pd = pkt_find_dev_from_minor(iminor(inode)); | 2422 | pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev)); |
2423 | if (!pd) { | 2423 | if (!pd) { |
2424 | ret = -ENODEV; | 2424 | ret = -ENODEV; |
2425 | goto out; | 2425 | goto out; |
@@ -2428,20 +2428,20 @@ static int pkt_open(struct inode *inode, struct file *file) | |||
2428 | 2428 | ||
2429 | pd->refcnt++; | 2429 | pd->refcnt++; |
2430 | if (pd->refcnt > 1) { | 2430 | if (pd->refcnt > 1) { |
2431 | if ((file->f_mode & FMODE_WRITE) && | 2431 | if ((mode & FMODE_WRITE) && |
2432 | !test_bit(PACKET_WRITABLE, &pd->flags)) { | 2432 | !test_bit(PACKET_WRITABLE, &pd->flags)) { |
2433 | ret = -EBUSY; | 2433 | ret = -EBUSY; |
2434 | goto out_dec; | 2434 | goto out_dec; |
2435 | } | 2435 | } |
2436 | } else { | 2436 | } else { |
2437 | ret = pkt_open_dev(pd, file->f_mode & FMODE_WRITE); | 2437 | ret = pkt_open_dev(pd, mode & FMODE_WRITE); |
2438 | if (ret) | 2438 | if (ret) |
2439 | goto out_dec; | 2439 | goto out_dec; |
2440 | /* | 2440 | /* |
2441 | * needed here as well, since ext2 (among others) may change | 2441 | * needed here as well, since ext2 (among others) may change |
2442 | * the blocksize at mount time | 2442 | * the blocksize at mount time |
2443 | */ | 2443 | */ |
2444 | set_blocksize(inode->i_bdev, CD_FRAMESIZE); | 2444 | set_blocksize(bdev, CD_FRAMESIZE); |
2445 | } | 2445 | } |
2446 | 2446 | ||
2447 | mutex_unlock(&ctl_mutex); | 2447 | mutex_unlock(&ctl_mutex); |
@@ -2455,9 +2455,9 @@ out: | |||
2455 | return ret; | 2455 | return ret; |
2456 | } | 2456 | } |
2457 | 2457 | ||
2458 | static int pkt_close(struct inode *inode, struct file *file) | 2458 | static int pkt_close(struct gendisk *disk, fmode_t mode) |
2459 | { | 2459 | { |
2460 | struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; | 2460 | struct pktcdvd_device *pd = disk->private_data; |
2461 | int ret = 0; | 2461 | int ret = 0; |
2462 | 2462 | ||
2463 | mutex_lock(&ctl_mutex); | 2463 | mutex_lock(&ctl_mutex); |
@@ -2765,7 +2765,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) | |||
2765 | bdev = bdget(dev); | 2765 | bdev = bdget(dev); |
2766 | if (!bdev) | 2766 | if (!bdev) |
2767 | return -ENOMEM; | 2767 | return -ENOMEM; |
2768 | ret = blkdev_get(bdev, FMODE_READ, O_RDONLY | O_NONBLOCK); | 2768 | ret = blkdev_get(bdev, FMODE_READ | FMODE_NDELAY); |
2769 | if (ret) | 2769 | if (ret) |
2770 | return ret; | 2770 | return ret; |
2771 | 2771 | ||
@@ -2790,19 +2790,28 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) | |||
2790 | return 0; | 2790 | return 0; |
2791 | 2791 | ||
2792 | out_mem: | 2792 | out_mem: |
2793 | blkdev_put(bdev); | 2793 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE); |
2794 | /* This is safe: open() is still holding a reference. */ | 2794 | /* This is safe: open() is still holding a reference. */ |
2795 | module_put(THIS_MODULE); | 2795 | module_put(THIS_MODULE); |
2796 | return ret; | 2796 | return ret; |
2797 | } | 2797 | } |
2798 | 2798 | ||
2799 | static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 2799 | static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) |
2800 | { | 2800 | { |
2801 | struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; | 2801 | struct pktcdvd_device *pd = bdev->bd_disk->private_data; |
2802 | 2802 | ||
2803 | VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode)); | 2803 | VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, |
2804 | MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev)); | ||
2804 | 2805 | ||
2805 | switch (cmd) { | 2806 | switch (cmd) { |
2807 | case CDROMEJECT: | ||
2808 | /* | ||
2809 | * The door gets locked when the device is opened, so we | ||
2810 | * have to unlock it or else the eject command fails. | ||
2811 | */ | ||
2812 | if (pd->refcnt == 1) | ||
2813 | pkt_lock_door(pd, 0); | ||
2814 | /* fallthru */ | ||
2806 | /* | 2815 | /* |
2807 | * forward selected CDROM ioctls to CD-ROM, for UDF | 2816 | * forward selected CDROM ioctls to CD-ROM, for UDF |
2808 | */ | 2817 | */ |
@@ -2811,16 +2820,7 @@ static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u | |||
2811 | case CDROM_LAST_WRITTEN: | 2820 | case CDROM_LAST_WRITTEN: |
2812 | case CDROM_SEND_PACKET: | 2821 | case CDROM_SEND_PACKET: |
2813 | case SCSI_IOCTL_SEND_COMMAND: | 2822 | case SCSI_IOCTL_SEND_COMMAND: |
2814 | return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); | 2823 | return __blkdev_driver_ioctl(pd->bdev, mode, cmd, arg); |
2815 | |||
2816 | case CDROMEJECT: | ||
2817 | /* | ||
2818 | * The door gets locked when the device is opened, so we | ||
2819 | * have to unlock it or else the eject command fails. | ||
2820 | */ | ||
2821 | if (pd->refcnt == 1) | ||
2822 | pkt_lock_door(pd, 0); | ||
2823 | return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); | ||
2824 | 2824 | ||
2825 | default: | 2825 | default: |
2826 | VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); | 2826 | VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); |
@@ -2849,7 +2849,7 @@ static struct block_device_operations pktcdvd_ops = { | |||
2849 | .owner = THIS_MODULE, | 2849 | .owner = THIS_MODULE, |
2850 | .open = pkt_open, | 2850 | .open = pkt_open, |
2851 | .release = pkt_close, | 2851 | .release = pkt_close, |
2852 | .ioctl = pkt_ioctl, | 2852 | .locked_ioctl = pkt_ioctl, |
2853 | .media_changed = pkt_media_changed, | 2853 | .media_changed = pkt_media_changed, |
2854 | }; | 2854 | }; |
2855 | 2855 | ||
@@ -2975,7 +2975,7 @@ static int pkt_remove_dev(dev_t pkt_dev) | |||
2975 | pkt_debugfs_dev_remove(pd); | 2975 | pkt_debugfs_dev_remove(pd); |
2976 | pkt_sysfs_dev_remove(pd); | 2976 | pkt_sysfs_dev_remove(pd); |
2977 | 2977 | ||
2978 | blkdev_put(pd->bdev); | 2978 | blkdev_put(pd->bdev, FMODE_READ|FMODE_WRITE); |
2979 | 2979 | ||
2980 | remove_proc_entry(pd->name, pkt_proc); | 2980 | remove_proc_entry(pd->name, pkt_proc); |
2981 | DPRINTK(DRIVER_NAME": writer %s unmapped\n", pd->name); | 2981 | DPRINTK(DRIVER_NAME": writer %s unmapped\n", pd->name); |