diff options
author | Christoph Hellwig <hch@lst.de> | 2014-07-08 13:16:17 +0200 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-07-25 07:38:08 -0400 |
commit | 6af7a4ffa2775c452c77eccc6bb6a4e2b71c2371 (patch) | |
tree | a02a81dcd071c343d85cb19bcd25657b3edf53c2 | |
parent | 4f1e57657548d7afb4a6b62097765282f3b03c6e (diff) | |
download | linux-6af7a4ffa2775c452c77eccc6bb6a4e2b71c2371.tar.bz2 |
scsi: add scsi_setup_cmnd helper
Factor out command setup code that will be shared with the blk-mq code path.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Webb Scales <webbnh@hp.com>
-rw-r--r-- | drivers/scsi/scsi_lib.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 85cf0ef843f6..04c368470c8a 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1092,6 +1092,27 @@ static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req) return scsi_cmd_to_driver(cmd)->init_command(cmd); } +static int scsi_setup_cmnd(struct scsi_device *sdev, struct request *req) +{ + struct scsi_cmnd *cmd = req->special; + + if (!blk_rq_bytes(req)) + cmd->sc_data_direction = DMA_NONE; + else if (rq_data_dir(req) == WRITE) + cmd->sc_data_direction = DMA_TO_DEVICE; + else + cmd->sc_data_direction = DMA_FROM_DEVICE; + + switch (req->cmd_type) { + case REQ_TYPE_FS: + return scsi_setup_fs_cmnd(sdev, req); + case REQ_TYPE_BLOCK_PC: + return scsi_setup_blk_pc_cmnd(sdev, req); + default: + return BLKPREP_KILL; + } +} + static int scsi_prep_state_check(struct scsi_device *sdev, struct request *req) { @@ -1195,24 +1216,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) goto out; } - if (!blk_rq_bytes(req)) - cmd->sc_data_direction = DMA_NONE; - else if (rq_data_dir(req) == WRITE) - cmd->sc_data_direction = DMA_TO_DEVICE; - else - cmd->sc_data_direction = DMA_FROM_DEVICE; - - switch (req->cmd_type) { - case REQ_TYPE_FS: - ret = scsi_setup_fs_cmnd(sdev, req); - break; - case REQ_TYPE_BLOCK_PC: - ret = scsi_setup_blk_pc_cmnd(sdev, req); - break; - default: - ret = BLKPREP_KILL; - } - + ret = scsi_setup_cmnd(sdev, req); out: return scsi_prep_return(q, req, ret); } |