aboutsummaryrefslogtreecommitdiff
path: root/drivers/scsi/scsi_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r--drivers/scsi/scsi_lib.c76
1 files changed, 13 insertions, 63 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 701a328f7be..9a05076f9cf 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -286,13 +286,12 @@ int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd,
int result;
if (sshdr) {
- sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_NOIO);
+ sense = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_NOIO);
if (!sense)
return DRIVER_ERROR << 24;
- memset(sense, 0, SCSI_SENSE_BUFFERSIZE);
}
result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen,
- sense, timeout, retries, 0);
+ sense, timeout, retries, 0);
if (sshdr)
scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, sshdr);
@@ -1893,8 +1892,16 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
}
if(scsi_status_is_good(result)) {
- data->header_length = header_length;
- if(use_10_for_ms) {
+ if (unlikely(buffer[0] == 0x86 && buffer[1] == 0x0b &&
+ (modepage == 6 || modepage == 8))) {
+ /* Initio breakage? */
+ header_length = 0;
+ data->length = 13;
+ data->medium_type = 0;
+ data->device_specific = 0;
+ data->longlba = 0;
+ data->block_descriptor_length = 0;
+ } else if(use_10_for_ms) {
data->length = buffer[0]*256 + buffer[1] + 2;
data->medium_type = buffer[2];
data->device_specific = buffer[3];
@@ -1907,6 +1914,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
data->device_specific = buffer[2];
data->block_descriptor_length = buffer[3];
}
+ data->header_length = header_length;
}
return result;
@@ -2249,61 +2257,3 @@ scsi_target_unblock(struct device *dev)
device_for_each_child(dev, NULL, target_unblock);
}
EXPORT_SYMBOL_GPL(scsi_target_unblock);
-
-
-struct work_queue_work {
- struct work_struct work;
- void (*fn)(void *);
- void *data;
-};
-
-static void execute_in_process_context_work(void *data)
-{
- void (*fn)(void *data);
- struct work_queue_work *wqw = data;
-
- fn = wqw->fn;
- data = wqw->data;
-
- kfree(wqw);
-
- fn(data);
-}
-
-/**
- * scsi_execute_in_process_context - reliably execute the routine with user context
- * @fn: the function to execute
- * @data: data to pass to the function
- *
- * Executes the function immediately if process context is available,
- * otherwise schedules the function for delayed execution.
- *
- * Returns: 0 - function was executed
- * 1 - function was scheduled for execution
- * <0 - error
- */
-int scsi_execute_in_process_context(void (*fn)(void *data), void *data)
-{
- struct work_queue_work *wqw;
-
- if (!in_interrupt()) {
- fn(data);
- return 0;
- }
-
- wqw = kmalloc(sizeof(struct work_queue_work), GFP_ATOMIC);
-
- if (unlikely(!wqw)) {
- printk(KERN_ERR "Failed to allocate memory\n");
- WARN_ON(1);
- return -ENOMEM;
- }
-
- INIT_WORK(&wqw->work, execute_in_process_context_work, wqw);
- wqw->fn = fn;
- wqw->data = data;
- schedule_work(&wqw->work);
-
- return 1;
-}
-EXPORT_SYMBOL_GPL(scsi_execute_in_process_context);