aboutsummaryrefslogtreecommitdiffstats
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.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 14ad2a785a34..a7f3f0c84db7 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1259,6 +1259,26 @@ static void scsi_generic_done(struct scsi_cmnd *cmd)
1259 scsi_io_completion(cmd, cmd->bufflen, 0); 1259 scsi_io_completion(cmd, cmd->bufflen, 0);
1260} 1260}
1261 1261
1262void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd)
1263{
1264 struct request *req = cmd->request;
1265
1266 BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd));
1267 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
1268 cmd->cmd_len = req->cmd_len;
1269 if (!req->data_len)
1270 cmd->sc_data_direction = DMA_NONE;
1271 else if (rq_data_dir(req) == WRITE)
1272 cmd->sc_data_direction = DMA_TO_DEVICE;
1273 else
1274 cmd->sc_data_direction = DMA_FROM_DEVICE;
1275
1276 cmd->transfersize = req->data_len;
1277 cmd->allowed = req->retries;
1278 cmd->timeout_per_command = req->timeout;
1279}
1280EXPORT_SYMBOL_GPL(scsi_setup_blk_pc_cmnd);
1281
1262static int scsi_prep_fn(struct request_queue *q, struct request *req) 1282static int scsi_prep_fn(struct request_queue *q, struct request *req)
1263{ 1283{
1264 struct scsi_device *sdev = q->queuedata; 1284 struct scsi_device *sdev = q->queuedata;
@@ -1394,18 +1414,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1394 goto kill; 1414 goto kill;
1395 } 1415 }
1396 } else { 1416 } else {
1397 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); 1417 scsi_setup_blk_pc_cmnd(cmd);
1398 cmd->cmd_len = req->cmd_len;
1399 if (rq_data_dir(req) == WRITE)
1400 cmd->sc_data_direction = DMA_TO_DEVICE;
1401 else if (req->data_len)
1402 cmd->sc_data_direction = DMA_FROM_DEVICE;
1403 else
1404 cmd->sc_data_direction = DMA_NONE;
1405
1406 cmd->transfersize = req->data_len;
1407 cmd->allowed = req->retries;
1408 cmd->timeout_per_command = req->timeout;
1409 cmd->done = scsi_generic_done; 1418 cmd->done = scsi_generic_done;
1410 } 1419 }
1411 } 1420 }