Commit 1657f824 authored by Jes Sorensen's avatar Jes Sorensen Committed by Linus Torvalds

[PATCH] sem2mutex: drivers/block/pktcdvd.c

Convert to use mutex from a semaphore
Signed-off-by: default avatarJes Sorensen <jes@sgi.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Cc: Peter Osterlund <petero2@telia.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 97d1f15b
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/mutex.h>
#include <scsi/scsi_cmnd.h> #include <scsi/scsi_cmnd.h>
#include <scsi/scsi_ioctl.h> #include <scsi/scsi_ioctl.h>
#include <scsi/scsi.h> #include <scsi/scsi.h>
...@@ -81,7 +82,7 @@ ...@@ -81,7 +82,7 @@
static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
static struct proc_dir_entry *pkt_proc; static struct proc_dir_entry *pkt_proc;
static int pkt_major; static int pkt_major;
static struct semaphore ctl_mutex; /* Serialize open/close/setup/teardown */ static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */
static mempool_t *psd_pool; static mempool_t *psd_pool;
...@@ -2018,7 +2019,7 @@ static int pkt_open(struct inode *inode, struct file *file) ...@@ -2018,7 +2019,7 @@ static int pkt_open(struct inode *inode, struct file *file)
VPRINTK("pktcdvd: entering open\n"); VPRINTK("pktcdvd: entering open\n");
down(&ctl_mutex); mutex_lock(&ctl_mutex);
pd = pkt_find_dev_from_minor(iminor(inode)); pd = pkt_find_dev_from_minor(iminor(inode));
if (!pd) { if (!pd) {
ret = -ENODEV; ret = -ENODEV;
...@@ -2044,14 +2045,14 @@ static int pkt_open(struct inode *inode, struct file *file) ...@@ -2044,14 +2045,14 @@ static int pkt_open(struct inode *inode, struct file *file)
set_blocksize(inode->i_bdev, CD_FRAMESIZE); set_blocksize(inode->i_bdev, CD_FRAMESIZE);
} }
up(&ctl_mutex); mutex_unlock(&ctl_mutex);
return 0; return 0;
out_dec: out_dec:
pd->refcnt--; pd->refcnt--;
out: out:
VPRINTK("pktcdvd: failed open (%d)\n", ret); VPRINTK("pktcdvd: failed open (%d)\n", ret);
up(&ctl_mutex); mutex_unlock(&ctl_mutex);
return ret; return ret;
} }
...@@ -2060,14 +2061,14 @@ static int pkt_close(struct inode *inode, struct file *file) ...@@ -2060,14 +2061,14 @@ static int pkt_close(struct inode *inode, struct file *file)
struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data;
int ret = 0; int ret = 0;
down(&ctl_mutex); mutex_lock(&ctl_mutex);
pd->refcnt--; pd->refcnt--;
BUG_ON(pd->refcnt < 0); BUG_ON(pd->refcnt < 0);
if (pd->refcnt == 0) { if (pd->refcnt == 0) {
int flush = test_bit(PACKET_WRITABLE, &pd->flags); int flush = test_bit(PACKET_WRITABLE, &pd->flags);
pkt_release_dev(pd, flush); pkt_release_dev(pd, flush);
} }
up(&ctl_mutex); mutex_unlock(&ctl_mutex);
return ret; return ret;
} }
...@@ -2596,21 +2597,21 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm ...@@ -2596,21 +2597,21 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
case PKT_CTRL_CMD_SETUP: case PKT_CTRL_CMD_SETUP:
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
down(&ctl_mutex); mutex_lock(&ctl_mutex);
ret = pkt_setup_dev(&ctrl_cmd); ret = pkt_setup_dev(&ctrl_cmd);
up(&ctl_mutex); mutex_unlock(&ctl_mutex);
break; break;
case PKT_CTRL_CMD_TEARDOWN: case PKT_CTRL_CMD_TEARDOWN:
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
down(&ctl_mutex); mutex_lock(&ctl_mutex);
ret = pkt_remove_dev(&ctrl_cmd); ret = pkt_remove_dev(&ctrl_cmd);
up(&ctl_mutex); mutex_unlock(&ctl_mutex);
break; break;
case PKT_CTRL_CMD_STATUS: case PKT_CTRL_CMD_STATUS:
down(&ctl_mutex); mutex_lock(&ctl_mutex);
pkt_get_status(&ctrl_cmd); pkt_get_status(&ctrl_cmd);
up(&ctl_mutex); mutex_unlock(&ctl_mutex);
break; break;
default: default:
return -ENOTTY; return -ENOTTY;
...@@ -2656,7 +2657,7 @@ static int __init pkt_init(void) ...@@ -2656,7 +2657,7 @@ static int __init pkt_init(void)
goto out; goto out;
} }
init_MUTEX(&ctl_mutex); mutex_init(&ctl_mutex);
pkt_proc = proc_mkdir("pktcdvd", proc_root_driver); pkt_proc = proc_mkdir("pktcdvd", proc_root_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment