aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sr.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-01-11 07:16:10 -0500
committerJames Bottomley <jejb@mulgrave.(none)>2006-01-12 12:53:11 -0500
commit0b9506723826c68b50fa33e345700ddcac1bed36 (patch)
treeda3e432ef4517c47ebdc088c6322d0ac51193127 /drivers/scsi/sr.c
parentdacee84b070c4e705a5b6446f1f0a6a6e2f8d7a4 (diff)
[SCSI] turn most scsi semaphores into mutexes
the scsi layer is using semaphores in a mutex way, this patch converts these into using mutexes instead Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/sr.c')
-rw-r--r--drivers/scsi/sr.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index a4d9be7c6874..ec73223ad2ea 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -44,6 +44,7 @@
44#include <linux/interrupt.h> 44#include <linux/interrupt.h>
45#include <linux/init.h> 45#include <linux/init.h>
46#include <linux/blkdev.h> 46#include <linux/blkdev.h>
47#include <linux/mutex.h>
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48 49
49#include <scsi/scsi.h> 50#include <scsi/scsi.h>
@@ -90,7 +91,7 @@ static DEFINE_SPINLOCK(sr_index_lock);
90/* This semaphore is used to mediate the 0->1 reference get in the 91/* This semaphore is used to mediate the 0->1 reference get in the
91 * face of object destruction (i.e. we can't allow a get on an 92 * face of object destruction (i.e. we can't allow a get on an
92 * object after last put) */ 93 * object after last put) */
93static DECLARE_MUTEX(sr_ref_sem); 94static DEFINE_MUTEX(sr_ref_mutex);
94 95
95static int sr_open(struct cdrom_device_info *, int); 96static int sr_open(struct cdrom_device_info *, int);
96static void sr_release(struct cdrom_device_info *); 97static void sr_release(struct cdrom_device_info *);
@@ -133,7 +134,7 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk)
133{ 134{
134 struct scsi_cd *cd = NULL; 135 struct scsi_cd *cd = NULL;
135 136
136 down(&sr_ref_sem); 137 mutex_lock(&sr_ref_mutex);
137 if (disk->private_data == NULL) 138 if (disk->private_data == NULL)
138 goto out; 139 goto out;
139 cd = scsi_cd(disk); 140 cd = scsi_cd(disk);
@@ -146,7 +147,7 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk)
146 kref_put(&cd->kref, sr_kref_release); 147 kref_put(&cd->kref, sr_kref_release);
147 cd = NULL; 148 cd = NULL;
148 out: 149 out:
149 up(&sr_ref_sem); 150 mutex_unlock(&sr_ref_mutex);
150 return cd; 151 return cd;
151} 152}
152 153
@@ -154,10 +155,10 @@ static inline void scsi_cd_put(struct scsi_cd *cd)
154{ 155{
155 struct scsi_device *sdev = cd->device; 156 struct scsi_device *sdev = cd->device;
156 157
157 down(&sr_ref_sem); 158 mutex_lock(&sr_ref_mutex);
158 kref_put(&cd->kref, sr_kref_release); 159 kref_put(&cd->kref, sr_kref_release);
159 scsi_device_put(sdev); 160 scsi_device_put(sdev);
160 up(&sr_ref_sem); 161 mutex_unlock(&sr_ref_mutex);
161} 162}
162 163
163/* 164/*
@@ -845,7 +846,7 @@ static int sr_packet(struct cdrom_device_info *cdi,
845 * sr_kref_release - Called to free the scsi_cd structure 846 * sr_kref_release - Called to free the scsi_cd structure
846 * @kref: pointer to embedded kref 847 * @kref: pointer to embedded kref
847 * 848 *
848 * sr_ref_sem must be held entering this routine. Because it is 849 * sr_ref_mutex must be held entering this routine. Because it is
849 * called on last put, you should always use the scsi_cd_get() 850 * called on last put, you should always use the scsi_cd_get()
850 * scsi_cd_put() helpers which manipulate the semaphore directly 851 * scsi_cd_put() helpers which manipulate the semaphore directly
851 * and never do a direct kref_put(). 852 * and never do a direct kref_put().
@@ -874,9 +875,9 @@ static int sr_remove(struct device *dev)
874 875
875 del_gendisk(cd->disk); 876 del_gendisk(cd->disk);
876 877
877 down(&sr_ref_sem); 878 mutex_lock(&sr_ref_mutex);
878 kref_put(&cd->kref, sr_kref_release); 879 kref_put(&cd->kref, sr_kref_release);
879 up(&sr_ref_sem); 880 mutex_unlock(&sr_ref_mutex);
880 881
881 return 0; 882 return 0;
882} 883}