summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sg.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-02-05 06:47:02 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-02-05 06:47:02 +0000
commit99a7e12f34b3661a0d1354eef83a0eef4df5e34c (patch)
tree3560aca9ca86792f9ab7bd87861ea143a1b3c7a3 /drivers/scsi/sg.c
parente73a04659c0b8cdee4dd40e58630e2cf63afb316 (diff)
Merge with Linux 2.3.38.
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r--drivers/scsi/sg.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 97a911ddb..c1db9ffbd 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -65,6 +65,7 @@
#include <scsi/scsi_ioctl.h>
#include <scsi/sg.h>
+static spinlock_t sg_request_lock = SPIN_LOCK_UNLOCKED;
int sg_big_buff = SG_DEF_RESERVED_SIZE; /* sg_big_buff is ro through sysctl */
/* N.B. This global is here to keep existing software happy. It now holds
@@ -100,10 +101,17 @@ static int sg_detect(Scsi_Device *);
static void sg_detach(Scsi_Device *);
-struct Scsi_Device_Template sg_template = {NULL, NULL, "sg", NULL, 0xff,
- SCSI_GENERIC_MAJOR, 0, 0, 0, 0,
- sg_detect, sg_init,
- sg_finish, sg_attach, sg_detach};
+struct Scsi_Device_Template sg_template =
+{
+ tag:"sg",
+ scsi_type:0xff,
+ major:SCSI_GENERIC_MAJOR,
+ detect:sg_detect,
+ init:sg_init,
+ finish:sg_finish,
+ attach:sg_attach,
+ detach:sg_detach
+};
typedef struct sg_scatter_hold /* holding area for scsi scatter gather info */
@@ -432,9 +440,13 @@ static ssize_t sg_write(struct file * filp, const char * buf,
}
/* SCSI_LOG_TIMEOUT(7, printk("sg_write: allocating device\n")); */
if (! (SCpnt = scsi_allocate_device(sdp->device,
- !(filp->f_flags & O_NONBLOCK))))
- {
+ !(filp->f_flags & O_NONBLOCK),
+ TRUE))) {
sg_finish_rem_req(srp, NULL, 0);
+ if( signal_pending(current) )
+ {
+ return -EINTR;
+ }
return -EAGAIN; /* No available command blocks at the moment */
}
/* SCSI_LOG_TIMEOUT(7, printk("sg_write: device allocated\n")); */
@@ -934,8 +946,6 @@ static struct file_operations sg_fops = {
sg_release, /* release, was formerly sg_close */
NULL, /* fsync */
sg_fasync, /* fasync */
- NULL, /* check_media_change */
- NULL, /* revalidate */
NULL, /* lock */
};
@@ -981,8 +991,10 @@ static int sg_init()
SCSI_LOG_TIMEOUT(3, printk("sg_init\n"));
sg_dev_arr = (Sg_device *)
- scsi_init_malloc((sg_template.dev_noticed + SG_EXTRA_DEVS)
- * sizeof(Sg_device), GFP_ATOMIC);
+ kmalloc((sg_template.dev_noticed + SG_EXTRA_DEVS)
+ * sizeof(Sg_device), GFP_ATOMIC);
+ memset(sg_dev_arr, 0, (sg_template.dev_noticed + SG_EXTRA_DEVS)
+ * sizeof(Sg_device));
if (NULL == sg_dev_arr) {
printk("sg_init: no space for sg_dev_arr\n");
return 1;
@@ -1041,7 +1053,7 @@ static void sg_detach(Scsi_Device * scsidp)
continue; /* dirty but lowers nesting */
if (sdp->headfp) {
/* Need to stop sg_command_done() playing with this list during this loop */
- spin_lock_irqsave(&io_request_lock, flags);
+ spin_lock_irqsave(&sg_request_lock, flags);
sfp = sdp->headfp;
while (sfp) {
srp = sfp->headrp;
@@ -1052,7 +1064,7 @@ static void sg_detach(Scsi_Device * scsidp)
}
sfp = sfp->nextfp;
}
- spin_unlock_irqrestore(&io_request_lock, flags);
+ spin_unlock_irqrestore(&sg_request_lock, flags);
SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d, dirty, sleep(3)\n", k));
scsi_sleep(3); /* sleep 3 jiffies, hoping for timeout to go off */
}
@@ -1085,9 +1097,7 @@ void cleanup_module( void)
if(sg_dev_arr != NULL) {
/* Really worrying situation of writes still pending and get here */
/* Strategy: shorten timeout on release + wait on detach ... */
- scsi_init_free((char *) sg_dev_arr,
- (sg_template.dev_noticed + SG_EXTRA_DEVS)
- * sizeof(Sg_device));
+ kfree((char *) sg_dev_arr);
sg_dev_arr = NULL;
}
sg_template.dev_max = 0;
@@ -1114,9 +1124,9 @@ static void sg_shorten_timeout(Scsi_Cmnd * scpnt)
scsi_add_timer(scpnt, scpnt->timeout_per_command,
scsi_old_times_out);
#else
- spin_unlock_irq(&io_request_lock);
+ spin_unlock_irq(&sg_request_lock);
scsi_sleep(HZ); /* just sleep 1 second and hope ... */
- spin_lock_irq(&io_request_lock);
+ spin_lock_irq(&sg_request_lock);
#endif
}