aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/st.c')
-rw-r--r--drivers/scsi/st.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index c4aade8f5345..6e4a36af58c3 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -38,6 +38,7 @@ static const char *verstr = "20050830";
38#include <linux/devfs_fs_kernel.h> 38#include <linux/devfs_fs_kernel.h>
39#include <linux/cdev.h> 39#include <linux/cdev.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/mutex.h>
41 42
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43#include <asm/dma.h> 44#include <asm/dma.h>
@@ -220,7 +221,7 @@ static void scsi_tape_release(struct kref *);
220 221
221#define to_scsi_tape(obj) container_of(obj, struct scsi_tape, kref) 222#define to_scsi_tape(obj) container_of(obj, struct scsi_tape, kref)
222 223
223static DECLARE_MUTEX(st_ref_sem); 224static DEFINE_MUTEX(st_ref_mutex);
224 225
225 226
226#include "osst_detect.h" 227#include "osst_detect.h"
@@ -237,7 +238,7 @@ static struct scsi_tape *scsi_tape_get(int dev)
237{ 238{
238 struct scsi_tape *STp = NULL; 239 struct scsi_tape *STp = NULL;
239 240
240 down(&st_ref_sem); 241 mutex_lock(&st_ref_mutex);
241 write_lock(&st_dev_arr_lock); 242 write_lock(&st_dev_arr_lock);
242 243
243 if (dev < st_dev_max && scsi_tapes != NULL) 244 if (dev < st_dev_max && scsi_tapes != NULL)
@@ -259,7 +260,7 @@ out_put:
259 STp = NULL; 260 STp = NULL;
260out: 261out:
261 write_unlock(&st_dev_arr_lock); 262 write_unlock(&st_dev_arr_lock);
262 up(&st_ref_sem); 263 mutex_unlock(&st_ref_mutex);
263 return STp; 264 return STp;
264} 265}
265 266
@@ -267,10 +268,10 @@ static void scsi_tape_put(struct scsi_tape *STp)
267{ 268{
268 struct scsi_device *sdev = STp->device; 269 struct scsi_device *sdev = STp->device;
269 270
270 down(&st_ref_sem); 271 mutex_lock(&st_ref_mutex);
271 kref_put(&STp->kref, scsi_tape_release); 272 kref_put(&STp->kref, scsi_tape_release);
272 scsi_device_put(sdev); 273 scsi_device_put(sdev);
273 up(&st_ref_sem); 274 mutex_unlock(&st_ref_mutex);
274} 275}
275 276
276struct st_reject_data { 277struct st_reject_data {
@@ -4141,9 +4142,9 @@ static int st_remove(struct device *dev)
4141 } 4142 }
4142 } 4143 }
4143 4144
4144 down(&st_ref_sem); 4145 mutex_lock(&st_ref_mutex);
4145 kref_put(&tpnt->kref, scsi_tape_release); 4146 kref_put(&tpnt->kref, scsi_tape_release);
4146 up(&st_ref_sem); 4147 mutex_unlock(&st_ref_mutex);
4147 return 0; 4148 return 0;
4148 } 4149 }
4149 } 4150 }
@@ -4156,7 +4157,7 @@ static int st_remove(struct device *dev)
4156 * scsi_tape_release - Called to free the Scsi_Tape structure 4157 * scsi_tape_release - Called to free the Scsi_Tape structure
4157 * @kref: pointer to embedded kref 4158 * @kref: pointer to embedded kref
4158 * 4159 *
4159 * st_ref_sem must be held entering this routine. Because it is 4160 * st_ref_mutex must be held entering this routine. Because it is
4160 * called on last put, you should always use the scsi_tape_get() 4161 * called on last put, you should always use the scsi_tape_get()
4161 * scsi_tape_put() helpers which manipulate the semaphore directly 4162 * scsi_tape_put() helpers which manipulate the semaphore directly
4162 * and never do a direct kref_put(). 4163 * and never do a direct kref_put().