diff options
Diffstat (limited to 'drivers/block/pktcdvd.c')
-rw-r--r-- | drivers/block/pktcdvd.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 8a549db2aa78..b1cbeb59bb76 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -57,6 +57,7 @@ | |||
57 | #include <linux/seq_file.h> | 57 | #include <linux/seq_file.h> |
58 | #include <linux/miscdevice.h> | 58 | #include <linux/miscdevice.h> |
59 | #include <linux/freezer.h> | 59 | #include <linux/freezer.h> |
60 | #include <linux/smp_lock.h> | ||
60 | #include <linux/mutex.h> | 61 | #include <linux/mutex.h> |
61 | #include <linux/slab.h> | 62 | #include <linux/slab.h> |
62 | #include <scsi/scsi_cmnd.h> | 63 | #include <scsi/scsi_cmnd.h> |
@@ -1221,7 +1222,7 @@ static int pkt_start_recovery(struct packet_data *pkt) | |||
1221 | pkt->bio->bi_flags = 1 << BIO_UPTODATE; | 1222 | pkt->bio->bi_flags = 1 << BIO_UPTODATE; |
1222 | pkt->bio->bi_idx = 0; | 1223 | pkt->bio->bi_idx = 0; |
1223 | 1224 | ||
1224 | BUG_ON(pkt->bio->bi_rw != (1 << BIO_RW)); | 1225 | BUG_ON(pkt->bio->bi_rw != REQ_WRITE); |
1225 | BUG_ON(pkt->bio->bi_vcnt != pkt->frames); | 1226 | BUG_ON(pkt->bio->bi_vcnt != pkt->frames); |
1226 | BUG_ON(pkt->bio->bi_size != pkt->frames * CD_FRAMESIZE); | 1227 | BUG_ON(pkt->bio->bi_size != pkt->frames * CD_FRAMESIZE); |
1227 | BUG_ON(pkt->bio->bi_end_io != pkt_end_io_packet_write); | 1228 | BUG_ON(pkt->bio->bi_end_io != pkt_end_io_packet_write); |
@@ -2382,6 +2383,7 @@ static int pkt_open(struct block_device *bdev, fmode_t mode) | |||
2382 | 2383 | ||
2383 | VPRINTK(DRIVER_NAME": entering open\n"); | 2384 | VPRINTK(DRIVER_NAME": entering open\n"); |
2384 | 2385 | ||
2386 | lock_kernel(); | ||
2385 | mutex_lock(&ctl_mutex); | 2387 | mutex_lock(&ctl_mutex); |
2386 | pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev)); | 2388 | pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev)); |
2387 | if (!pd) { | 2389 | if (!pd) { |
@@ -2409,6 +2411,7 @@ static int pkt_open(struct block_device *bdev, fmode_t mode) | |||
2409 | } | 2411 | } |
2410 | 2412 | ||
2411 | mutex_unlock(&ctl_mutex); | 2413 | mutex_unlock(&ctl_mutex); |
2414 | unlock_kernel(); | ||
2412 | return 0; | 2415 | return 0; |
2413 | 2416 | ||
2414 | out_dec: | 2417 | out_dec: |
@@ -2416,6 +2419,7 @@ out_dec: | |||
2416 | out: | 2419 | out: |
2417 | VPRINTK(DRIVER_NAME": failed open (%d)\n", ret); | 2420 | VPRINTK(DRIVER_NAME": failed open (%d)\n", ret); |
2418 | mutex_unlock(&ctl_mutex); | 2421 | mutex_unlock(&ctl_mutex); |
2422 | unlock_kernel(); | ||
2419 | return ret; | 2423 | return ret; |
2420 | } | 2424 | } |
2421 | 2425 | ||
@@ -2424,6 +2428,7 @@ static int pkt_close(struct gendisk *disk, fmode_t mode) | |||
2424 | struct pktcdvd_device *pd = disk->private_data; | 2428 | struct pktcdvd_device *pd = disk->private_data; |
2425 | int ret = 0; | 2429 | int ret = 0; |
2426 | 2430 | ||
2431 | lock_kernel(); | ||
2427 | mutex_lock(&ctl_mutex); | 2432 | mutex_lock(&ctl_mutex); |
2428 | pd->refcnt--; | 2433 | pd->refcnt--; |
2429 | BUG_ON(pd->refcnt < 0); | 2434 | BUG_ON(pd->refcnt < 0); |
@@ -2432,6 +2437,7 @@ static int pkt_close(struct gendisk *disk, fmode_t mode) | |||
2432 | pkt_release_dev(pd, flush); | 2437 | pkt_release_dev(pd, flush); |
2433 | } | 2438 | } |
2434 | mutex_unlock(&ctl_mutex); | 2439 | mutex_unlock(&ctl_mutex); |
2440 | unlock_kernel(); | ||
2435 | return ret; | 2441 | return ret; |
2436 | } | 2442 | } |
2437 | 2443 | ||
@@ -2762,10 +2768,12 @@ out_mem: | |||
2762 | static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) | 2768 | static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) |
2763 | { | 2769 | { |
2764 | struct pktcdvd_device *pd = bdev->bd_disk->private_data; | 2770 | struct pktcdvd_device *pd = bdev->bd_disk->private_data; |
2771 | int ret; | ||
2765 | 2772 | ||
2766 | VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, | 2773 | VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, |
2767 | MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev)); | 2774 | MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev)); |
2768 | 2775 | ||
2776 | lock_kernel(); | ||
2769 | switch (cmd) { | 2777 | switch (cmd) { |
2770 | case CDROMEJECT: | 2778 | case CDROMEJECT: |
2771 | /* | 2779 | /* |
@@ -2783,14 +2791,16 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, | |||
2783 | case CDROM_LAST_WRITTEN: | 2791 | case CDROM_LAST_WRITTEN: |
2784 | case CDROM_SEND_PACKET: | 2792 | case CDROM_SEND_PACKET: |
2785 | case SCSI_IOCTL_SEND_COMMAND: | 2793 | case SCSI_IOCTL_SEND_COMMAND: |
2786 | return __blkdev_driver_ioctl(pd->bdev, mode, cmd, arg); | 2794 | ret = __blkdev_driver_ioctl(pd->bdev, mode, cmd, arg); |
2795 | break; | ||
2787 | 2796 | ||
2788 | default: | 2797 | default: |
2789 | VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); | 2798 | VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); |
2790 | return -ENOTTY; | 2799 | ret = -ENOTTY; |
2791 | } | 2800 | } |
2801 | unlock_kernel(); | ||
2792 | 2802 | ||
2793 | return 0; | 2803 | return ret; |
2794 | } | 2804 | } |
2795 | 2805 | ||
2796 | static int pkt_media_changed(struct gendisk *disk) | 2806 | static int pkt_media_changed(struct gendisk *disk) |
@@ -2812,7 +2822,7 @@ static const struct block_device_operations pktcdvd_ops = { | |||
2812 | .owner = THIS_MODULE, | 2822 | .owner = THIS_MODULE, |
2813 | .open = pkt_open, | 2823 | .open = pkt_open, |
2814 | .release = pkt_close, | 2824 | .release = pkt_close, |
2815 | .locked_ioctl = pkt_ioctl, | 2825 | .ioctl = pkt_ioctl, |
2816 | .media_changed = pkt_media_changed, | 2826 | .media_changed = pkt_media_changed, |
2817 | }; | 2827 | }; |
2818 | 2828 | ||