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.c42
1 files changed, 9 insertions, 33 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index c4aade8f5345..13b1d3aac265 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>
@@ -193,7 +194,6 @@ static int sgl_unmap_user_pages(struct scatterlist *, const unsigned int, int);
193 194
194static int st_probe(struct device *); 195static int st_probe(struct device *);
195static int st_remove(struct device *); 196static int st_remove(struct device *);
196static int st_init_command(struct scsi_cmnd *);
197 197
198static void do_create_driverfs_files(void); 198static void do_create_driverfs_files(void);
199static void do_remove_driverfs_files(void); 199static void do_remove_driverfs_files(void);
@@ -206,7 +206,6 @@ static struct scsi_driver st_template = {
206 .probe = st_probe, 206 .probe = st_probe,
207 .remove = st_remove, 207 .remove = st_remove,
208 }, 208 },
209 .init_command = st_init_command,
210}; 209};
211 210
212static int st_compression(struct scsi_tape *, int); 211static int st_compression(struct scsi_tape *, int);
@@ -220,7 +219,7 @@ static void scsi_tape_release(struct kref *);
220 219
221#define to_scsi_tape(obj) container_of(obj, struct scsi_tape, kref) 220#define to_scsi_tape(obj) container_of(obj, struct scsi_tape, kref)
222 221
223static DECLARE_MUTEX(st_ref_sem); 222static DEFINE_MUTEX(st_ref_mutex);
224 223
225 224
226#include "osst_detect.h" 225#include "osst_detect.h"
@@ -237,7 +236,7 @@ static struct scsi_tape *scsi_tape_get(int dev)
237{ 236{
238 struct scsi_tape *STp = NULL; 237 struct scsi_tape *STp = NULL;
239 238
240 down(&st_ref_sem); 239 mutex_lock(&st_ref_mutex);
241 write_lock(&st_dev_arr_lock); 240 write_lock(&st_dev_arr_lock);
242 241
243 if (dev < st_dev_max && scsi_tapes != NULL) 242 if (dev < st_dev_max && scsi_tapes != NULL)
@@ -259,7 +258,7 @@ out_put:
259 STp = NULL; 258 STp = NULL;
260out: 259out:
261 write_unlock(&st_dev_arr_lock); 260 write_unlock(&st_dev_arr_lock);
262 up(&st_ref_sem); 261 mutex_unlock(&st_ref_mutex);
263 return STp; 262 return STp;
264} 263}
265 264
@@ -267,10 +266,10 @@ static void scsi_tape_put(struct scsi_tape *STp)
267{ 266{
268 struct scsi_device *sdev = STp->device; 267 struct scsi_device *sdev = STp->device;
269 268
270 down(&st_ref_sem); 269 mutex_lock(&st_ref_mutex);
271 kref_put(&STp->kref, scsi_tape_release); 270 kref_put(&STp->kref, scsi_tape_release);
272 scsi_device_put(sdev); 271 scsi_device_put(sdev);
273 up(&st_ref_sem); 272 mutex_unlock(&st_ref_mutex);
274} 273}
275 274
276struct st_reject_data { 275struct st_reject_data {
@@ -4141,9 +4140,9 @@ static int st_remove(struct device *dev)
4141 } 4140 }
4142 } 4141 }
4143 4142
4144 down(&st_ref_sem); 4143 mutex_lock(&st_ref_mutex);
4145 kref_put(&tpnt->kref, scsi_tape_release); 4144 kref_put(&tpnt->kref, scsi_tape_release);
4146 up(&st_ref_sem); 4145 mutex_unlock(&st_ref_mutex);
4147 return 0; 4146 return 0;
4148 } 4147 }
4149 } 4148 }
@@ -4156,7 +4155,7 @@ static int st_remove(struct device *dev)
4156 * scsi_tape_release - Called to free the Scsi_Tape structure 4155 * scsi_tape_release - Called to free the Scsi_Tape structure
4157 * @kref: pointer to embedded kref 4156 * @kref: pointer to embedded kref
4158 * 4157 *
4159 * st_ref_sem must be held entering this routine. Because it is 4158 * 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() 4159 * called on last put, you should always use the scsi_tape_get()
4161 * scsi_tape_put() helpers which manipulate the semaphore directly 4160 * scsi_tape_put() helpers which manipulate the semaphore directly
4162 * and never do a direct kref_put(). 4161 * and never do a direct kref_put().
@@ -4180,29 +4179,6 @@ static void scsi_tape_release(struct kref *kref)
4180 return; 4179 return;
4181} 4180}
4182 4181
4183static void st_intr(struct scsi_cmnd *SCpnt)
4184{
4185 /*
4186 * The caller should be checking the request's errors
4187 * value.
4188 */
4189 scsi_io_completion(SCpnt, SCpnt->bufflen, 0);
4190}
4191
4192/*
4193 * st_init_command: only called via the scsi_cmd_ioctl (block SG_IO)
4194 * interface for REQ_BLOCK_PC commands.
4195 */
4196static int st_init_command(struct scsi_cmnd *SCpnt)
4197{
4198 if (!(SCpnt->request->flags & REQ_BLOCK_PC))
4199 return 0;
4200
4201 scsi_setup_blk_pc_cmnd(SCpnt);
4202 SCpnt->done = st_intr;
4203 return 1;
4204}
4205
4206static int __init init_st(void) 4182static int __init init_st(void)
4207{ 4183{
4208 validate_options(); 4184 validate_options();