diff options
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r-- | drivers/scsi/scsi_lib.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ce9d73a292e2..dc249cb970ea 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -1085,6 +1085,26 @@ static void scsi_generic_done(struct scsi_cmnd *cmd) | |||
1085 | scsi_io_completion(cmd, cmd->result == 0 ? cmd->bufflen : 0, 0); | 1085 | scsi_io_completion(cmd, cmd->result == 0 ? cmd->bufflen : 0, 0); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd, int retries) | ||
1089 | { | ||
1090 | struct request *req = cmd->request; | ||
1091 | |||
1092 | BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd)); | ||
1093 | memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); | ||
1094 | cmd->cmd_len = req->cmd_len; | ||
1095 | if (!req->data_len) | ||
1096 | cmd->sc_data_direction = DMA_NONE; | ||
1097 | else if (rq_data_dir(req) == WRITE) | ||
1098 | cmd->sc_data_direction = DMA_TO_DEVICE; | ||
1099 | else | ||
1100 | cmd->sc_data_direction = DMA_FROM_DEVICE; | ||
1101 | |||
1102 | cmd->transfersize = req->data_len; | ||
1103 | cmd->allowed = retries; | ||
1104 | cmd->timeout_per_command = req->timeout; | ||
1105 | } | ||
1106 | EXPORT_SYMBOL_GPL(scsi_setup_blk_pc_cmnd); | ||
1107 | |||
1088 | static int scsi_prep_fn(struct request_queue *q, struct request *req) | 1108 | static int scsi_prep_fn(struct request_queue *q, struct request *req) |
1089 | { | 1109 | { |
1090 | struct scsi_device *sdev = q->queuedata; | 1110 | struct scsi_device *sdev = q->queuedata; |
@@ -1220,18 +1240,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) | |||
1220 | goto kill; | 1240 | goto kill; |
1221 | } | 1241 | } |
1222 | } else { | 1242 | } else { |
1223 | memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); | 1243 | scsi_setup_blk_pc_cmnd(cmd, 3); |
1224 | cmd->cmd_len = req->cmd_len; | ||
1225 | if (rq_data_dir(req) == WRITE) | ||
1226 | cmd->sc_data_direction = DMA_TO_DEVICE; | ||
1227 | else if (req->data_len) | ||
1228 | cmd->sc_data_direction = DMA_FROM_DEVICE; | ||
1229 | else | ||
1230 | cmd->sc_data_direction = DMA_NONE; | ||
1231 | |||
1232 | cmd->transfersize = req->data_len; | ||
1233 | cmd->allowed = 3; | ||
1234 | cmd->timeout_per_command = req->timeout; | ||
1235 | cmd->done = scsi_generic_done; | 1244 | cmd->done = scsi_generic_done; |
1236 | } | 1245 | } |
1237 | } | 1246 | } |