aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/scsi_lib.c33
-rw-r--r--drivers/scsi/sd.c2
-rw-r--r--drivers/scsi/sr.c2
-rw-r--r--drivers/scsi/st.c2
4 files changed, 24 insertions, 15 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 }
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 9d893f085015..3d3ad7d1b779 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -245,7 +245,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
245 * SG_IO from block layer already setup, just copy cdb basically 245 * SG_IO from block layer already setup, just copy cdb basically
246 */ 246 */
247 if (blk_pc_request(rq)) { 247 if (blk_pc_request(rq)) {
248 scsi_setup_blk_pc_cmnd(SCpnt, SD_PASSTHROUGH_RETRIES); 248 scsi_setup_blk_pc_cmnd(SCpnt);
249 if (rq->timeout) 249 if (rq->timeout)
250 timeout = rq->timeout; 250 timeout = rq->timeout;
251 251
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 7e7398d563cc..a4d9be7c6874 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -320,7 +320,7 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
320 * these are already setup, just copy cdb basically 320 * these are already setup, just copy cdb basically
321 */ 321 */
322 if (SCpnt->request->flags & REQ_BLOCK_PC) { 322 if (SCpnt->request->flags & REQ_BLOCK_PC) {
323 scsi_setup_blk_pc_cmnd(SCpnt, MAX_RETRIES); 323 scsi_setup_blk_pc_cmnd(SCpnt);
324 324
325 if (SCpnt->timeout_per_command) 325 if (SCpnt->timeout_per_command)
326 timeout = SCpnt->timeout_per_command; 326 timeout = SCpnt->timeout_per_command;
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 894ad53be04b..c4aade8f5345 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4198,7 +4198,7 @@ static int st_init_command(struct scsi_cmnd *SCpnt)
4198 if (!(SCpnt->request->flags & REQ_BLOCK_PC)) 4198 if (!(SCpnt->request->flags & REQ_BLOCK_PC))
4199 return 0; 4199 return 0;
4200 4200
4201 scsi_setup_blk_pc_cmnd(SCpnt, 0); 4201 scsi_setup_blk_pc_cmnd(SCpnt);
4202 SCpnt->done = st_intr; 4202 SCpnt->done = st_intr;
4203 return 1; 4203 return 1;
4204} 4204}