summaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-06-28 12:40:18 +0200
committerChristoph Hellwig <hch@lst.de>2014-07-17 22:16:29 +0200
commit87949eee7e15471a42f06ae534847264a41be647 (patch)
tree767665f8cbc3b8b7785868e02b8938d103630f17 /drivers/scsi
parente4200f8ee35db820680a3caa25d260ef11fc1462 (diff)
downloadblackbird-obmc-linux-87949eee7e15471a42f06ae534847264a41be647.tar.gz
blackbird-obmc-linux-87949eee7e15471a42f06ae534847264a41be647.zip
sd: split sd_init_command
Factor out a function to initialize regular read/write commands and leave sd_init_command as a simple dispatcher to the different prepare routines. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/sd.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index fe0b7dff02b4..3663e38ba4df 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -884,21 +884,7 @@ static int sd_setup_flush_cmnd(struct scsi_cmnd *cmd)
return BLKPREP_OK;
}
-static void sd_uninit_command(struct scsi_cmnd *SCpnt)
-{
- struct request *rq = SCpnt->request;
-
- if (rq->cmd_flags & REQ_DISCARD)
- __free_page(rq->completion_data);
-
- if (SCpnt->cmnd != rq->cmd) {
- mempool_free(SCpnt->cmnd, sd_cdb_pool);
- SCpnt->cmnd = NULL;
- SCpnt->cmd_len = 0;
- }
-}
-
-static int sd_init_command(struct scsi_cmnd *SCpnt)
+static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
{
struct request *rq = SCpnt->request;
struct scsi_device *sdp = SCpnt->device;
@@ -910,20 +896,6 @@ static int sd_init_command(struct scsi_cmnd *SCpnt)
int ret, host_dif;
unsigned char protect;
- /*
- * Discard request come in as REQ_TYPE_FS but we turn them into
- * block PC requests to make life easier.
- */
- if (rq->cmd_flags & REQ_DISCARD) {
- ret = sd_setup_discard_cmnd(SCpnt);
- goto out;
- } else if (rq->cmd_flags & REQ_WRITE_SAME) {
- ret = sd_setup_write_same_cmnd(SCpnt);
- goto out;
- } else if (rq->cmd_flags & REQ_FLUSH) {
- ret = sd_setup_flush_cmnd(SCpnt);
- goto out;
- }
ret = scsi_init_io(SCpnt, GFP_ATOMIC);
if (ret != BLKPREP_OK)
goto out;
@@ -1155,6 +1127,34 @@ static int sd_init_command(struct scsi_cmnd *SCpnt)
return ret;
}
+static int sd_init_command(struct scsi_cmnd *cmd)
+{
+ struct request *rq = cmd->request;
+
+ if (rq->cmd_flags & REQ_DISCARD)
+ return sd_setup_discard_cmnd(cmd);
+ else if (rq->cmd_flags & REQ_WRITE_SAME)
+ return sd_setup_write_same_cmnd(cmd);
+ else if (rq->cmd_flags & REQ_FLUSH)
+ return sd_setup_flush_cmnd(cmd);
+ else
+ return sd_setup_read_write_cmnd(cmd);
+}
+
+static void sd_uninit_command(struct scsi_cmnd *SCpnt)
+{
+ struct request *rq = SCpnt->request;
+
+ if (rq->cmd_flags & REQ_DISCARD)
+ __free_page(rq->completion_data);
+
+ if (SCpnt->cmnd != rq->cmd) {
+ mempool_free(SCpnt->cmnd, sd_cdb_pool);
+ SCpnt->cmnd = NULL;
+ SCpnt->cmd_len = 0;
+ }
+}
+
/**
* sd_open - open a scsi disk device
* @inode: only i_rdev member may be used
OpenPOWER on IntegriCloud