diff options
Diffstat (limited to 'drivers/block/pktcdvd.c')
-rw-r--r-- | drivers/block/pktcdvd.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 476a5b553f34..1d261f985f31 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/seq_file.h> | 56 | #include <linux/seq_file.h> |
57 | #include <linux/miscdevice.h> | 57 | #include <linux/miscdevice.h> |
58 | #include <linux/suspend.h> | 58 | #include <linux/suspend.h> |
59 | #include <linux/mutex.h> | ||
59 | #include <scsi/scsi_cmnd.h> | 60 | #include <scsi/scsi_cmnd.h> |
60 | #include <scsi/scsi_ioctl.h> | 61 | #include <scsi/scsi_ioctl.h> |
61 | #include <scsi/scsi.h> | 62 | #include <scsi/scsi.h> |
@@ -81,7 +82,7 @@ | |||
81 | static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; | 82 | static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; |
82 | static struct proc_dir_entry *pkt_proc; | 83 | static struct proc_dir_entry *pkt_proc; |
83 | static int pkt_major; | 84 | static int pkt_major; |
84 | static struct semaphore ctl_mutex; /* Serialize open/close/setup/teardown */ | 85 | static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */ |
85 | static mempool_t *psd_pool; | 86 | static mempool_t *psd_pool; |
86 | 87 | ||
87 | 88 | ||
@@ -2018,7 +2019,7 @@ static int pkt_open(struct inode *inode, struct file *file) | |||
2018 | 2019 | ||
2019 | VPRINTK("pktcdvd: entering open\n"); | 2020 | VPRINTK("pktcdvd: entering open\n"); |
2020 | 2021 | ||
2021 | down(&ctl_mutex); | 2022 | mutex_lock(&ctl_mutex); |
2022 | pd = pkt_find_dev_from_minor(iminor(inode)); | 2023 | pd = pkt_find_dev_from_minor(iminor(inode)); |
2023 | if (!pd) { | 2024 | if (!pd) { |
2024 | ret = -ENODEV; | 2025 | ret = -ENODEV; |
@@ -2044,14 +2045,14 @@ static int pkt_open(struct inode *inode, struct file *file) | |||
2044 | set_blocksize(inode->i_bdev, CD_FRAMESIZE); | 2045 | set_blocksize(inode->i_bdev, CD_FRAMESIZE); |
2045 | } | 2046 | } |
2046 | 2047 | ||
2047 | up(&ctl_mutex); | 2048 | mutex_unlock(&ctl_mutex); |
2048 | return 0; | 2049 | return 0; |
2049 | 2050 | ||
2050 | out_dec: | 2051 | out_dec: |
2051 | pd->refcnt--; | 2052 | pd->refcnt--; |
2052 | out: | 2053 | out: |
2053 | VPRINTK("pktcdvd: failed open (%d)\n", ret); | 2054 | VPRINTK("pktcdvd: failed open (%d)\n", ret); |
2054 | up(&ctl_mutex); | 2055 | mutex_unlock(&ctl_mutex); |
2055 | return ret; | 2056 | return ret; |
2056 | } | 2057 | } |
2057 | 2058 | ||
@@ -2060,14 +2061,14 @@ static int pkt_close(struct inode *inode, struct file *file) | |||
2060 | struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; | 2061 | struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; |
2061 | int ret = 0; | 2062 | int ret = 0; |
2062 | 2063 | ||
2063 | down(&ctl_mutex); | 2064 | mutex_lock(&ctl_mutex); |
2064 | pd->refcnt--; | 2065 | pd->refcnt--; |
2065 | BUG_ON(pd->refcnt < 0); | 2066 | BUG_ON(pd->refcnt < 0); |
2066 | if (pd->refcnt == 0) { | 2067 | if (pd->refcnt == 0) { |
2067 | int flush = test_bit(PACKET_WRITABLE, &pd->flags); | 2068 | int flush = test_bit(PACKET_WRITABLE, &pd->flags); |
2068 | pkt_release_dev(pd, flush); | 2069 | pkt_release_dev(pd, flush); |
2069 | } | 2070 | } |
2070 | up(&ctl_mutex); | 2071 | mutex_unlock(&ctl_mutex); |
2071 | return ret; | 2072 | return ret; |
2072 | } | 2073 | } |
2073 | 2074 | ||
@@ -2596,21 +2597,21 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm | |||
2596 | case PKT_CTRL_CMD_SETUP: | 2597 | case PKT_CTRL_CMD_SETUP: |
2597 | if (!capable(CAP_SYS_ADMIN)) | 2598 | if (!capable(CAP_SYS_ADMIN)) |
2598 | return -EPERM; | 2599 | return -EPERM; |
2599 | down(&ctl_mutex); | 2600 | mutex_lock(&ctl_mutex); |
2600 | ret = pkt_setup_dev(&ctrl_cmd); | 2601 | ret = pkt_setup_dev(&ctrl_cmd); |
2601 | up(&ctl_mutex); | 2602 | mutex_unlock(&ctl_mutex); |
2602 | break; | 2603 | break; |
2603 | case PKT_CTRL_CMD_TEARDOWN: | 2604 | case PKT_CTRL_CMD_TEARDOWN: |
2604 | if (!capable(CAP_SYS_ADMIN)) | 2605 | if (!capable(CAP_SYS_ADMIN)) |
2605 | return -EPERM; | 2606 | return -EPERM; |
2606 | down(&ctl_mutex); | 2607 | mutex_lock(&ctl_mutex); |
2607 | ret = pkt_remove_dev(&ctrl_cmd); | 2608 | ret = pkt_remove_dev(&ctrl_cmd); |
2608 | up(&ctl_mutex); | 2609 | mutex_unlock(&ctl_mutex); |
2609 | break; | 2610 | break; |
2610 | case PKT_CTRL_CMD_STATUS: | 2611 | case PKT_CTRL_CMD_STATUS: |
2611 | down(&ctl_mutex); | 2612 | mutex_lock(&ctl_mutex); |
2612 | pkt_get_status(&ctrl_cmd); | 2613 | pkt_get_status(&ctrl_cmd); |
2613 | up(&ctl_mutex); | 2614 | mutex_unlock(&ctl_mutex); |
2614 | break; | 2615 | break; |
2615 | default: | 2616 | default: |
2616 | return -ENOTTY; | 2617 | return -ENOTTY; |
@@ -2656,7 +2657,7 @@ static int __init pkt_init(void) | |||
2656 | goto out; | 2657 | goto out; |
2657 | } | 2658 | } |
2658 | 2659 | ||
2659 | init_MUTEX(&ctl_mutex); | 2660 | mutex_init(&ctl_mutex); |
2660 | 2661 | ||
2661 | pkt_proc = proc_mkdir("pktcdvd", proc_root_driver); | 2662 | pkt_proc = proc_mkdir("pktcdvd", proc_root_driver); |
2662 | 2663 | ||