sem2mutex pktcdvd
PATCH 1/1 sem2mutex pktcdvd
Hi,
Relative to Linus' git tree this morning. I don't have anything to test it with but it seems obviously correct.
Cheers,
Jes
Convert to use mutex from a semaphore
Signed-off-by Jes Sorensen <[email protected]>
----
drivers/block/pktcdvd.c | 27 ++++++++++++++------------- 1 files changed, 14 insertions(+), 13 deletions(-)
drivers/block/pktcdvd.c +14 -13
@@ -58,6 +58,7 @@#include <linux/seq_file.h> #include <linux/miscdevice.h> #include <linux/suspend.h> +#include <linux/mutex.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_ioctl.h>
@@ -82,7 +83,7 @@static struct pktcdvd_device *pkt_devs[MAX_WRITERS ];static struct proc_dir_entry *pkt_proc;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;
@@ -2030,7 +2031,7 @@VPRINTK ("pktcdvd: entering open\n" ); -down (&ctl_mutex); +mutex_lock (&ctl_mutex); pd =pkt_find_dev_from_minor (iminor (inode));if (!pd) { ret = -ENODEV ;
@@ -2057,14 +2058,14 @@set_blocksize (inode->i_bdev,CD_FRAMESIZE ); } -up (&ctl_mutex); +mutex_unlock (&ctl_mutex);return 0 ; out_dec: pd->refcnt--; out:VPRINTK ("pktcdvd: failed open (%d)\n" , ret); -up (&ctl_mutex); +mutex_unlock (&ctl_mutex);return ret; }
@@ -2073,14 +2074,14 @@struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data;int ret =0 ; -down (&ctl_mutex); +mutex_lock (&ctl_mutex); pd->refcnt--;BUG_ON (pd->refcnt <0 );if (pd->refcnt ==0 ) {int flush =test_bit (PACKET_WRITABLE , &pd->flags);pkt_release_dev (pd, flush); } -up (&ctl_mutex); +mutex_unlock (&ctl_mutex);return ret; }
@@ -2614,21 +2615,21 @@case PKT_CTRL_CMD_SETUP :if (!capable (CAP_SYS_ADMIN ))return -EPERM ; -down (&ctl_mutex); +mutex_lock (&ctl_mutex); ret =pkt_setup_dev (&ctrl_cmd); -up (&ctl_mutex); +mutex_unlock (&ctl_mutex);break ;case PKT_CTRL_CMD_TEARDOWN :if (!capable (CAP_SYS_ADMIN ))return -EPERM ; -down (&ctl_mutex); +mutex_lock (&ctl_mutex); ret =pkt_remove_dev (&ctrl_cmd); -up (&ctl_mutex); +mutex_unlock (&ctl_mutex);break ;case PKT_CTRL_CMD_STATUS : -down (&ctl_mutex); +mutex_lock (&ctl_mutex);pkt_get_status (&ctrl_cmd); -up (&ctl_mutex); +mutex_unlock (&ctl_mutex);break ;default :return -ENOTTY ;
@@ -2674,7 +2675,7 @@ goto out; } -init_MUTEX (&ctl_mutex); +mutex_init (&ctl_mutex); pkt_proc =proc_mkdir ("pktcdvd" , proc_root_driver);
Quoted 2 lines · [email protected] (Jes Sorensen) writes:
Relative to Linus' git tree this morning. I don't have anything to test it with but it seems obviously correct.
It worked fine in my tests.
Acked-by Peter Osterlund <[email protected]>
Signature · 2 lines
Peter Osterlund - [email protected] http://web.telia.com/~u89404340