summaryrefslogtreecommitdiff
path: root/drivers/scsi
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-10-05 11:41:29 +0300
committerMartin K. Petersen <martin.petersen@oracle.com>2020-10-08 04:48:28 +0300
commit74e5e6c1b18ca0ed1c8499cbaf2e3b758f67dbc6 (patch)
tree8cf4b8e3fa6070ff580fe688d17343ee1bf115e8 /drivers/scsi
parent7007e9dd56767a95de0947b3f7599bcc2f21687f (diff)
downloadlinux-74e5e6c1b18ca0ed1c8499cbaf2e3b758f67dbc6.tar.xz
scsi: core: Remove scsi_setup_cmnd() and scsi_setup_fs_cmnd()
Move this trivial functionality into scsi_prepare_cmd() instead of splitting it over multiple small functions, and update the comments to better document passthrough commands as the special case. Link: https://lore.kernel.org/r/20201005084130.143273-10-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/scsi_lib.c51
1 files changed, 18 insertions, 33 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 55a1a060cd11..6bf043dbae83 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1190,38 +1190,6 @@ static blk_status_t scsi_setup_scsi_cmnd(struct scsi_device *sdev,
return BLK_STS_OK;
}
-/*
- * Setup a normal block command. These are simple request from filesystems
- * that still need to be translated to SCSI CDBs from the ULD.
- */
-static blk_status_t scsi_setup_fs_cmnd(struct scsi_device *sdev,
- struct request *req)
-{
- struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
-
- if (unlikely(sdev->handler && sdev->handler->prep_fn)) {
- blk_status_t ret = sdev->handler->prep_fn(sdev, req);
- if (ret != BLK_STS_OK)
- return ret;
- }
-
- cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
- memset(cmd->cmnd, 0, BLK_MAX_CDB);
- return scsi_cmd_to_driver(cmd)->init_command(cmd);
-}
-
-static blk_status_t scsi_setup_cmnd(struct scsi_device *sdev,
- struct request *req)
-{
- struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
-
- cmd->sc_data_direction = rq_dma_dir(req);
-
- if (blk_rq_is_scsi(req))
- return scsi_setup_scsi_cmnd(sdev, req);
- return scsi_setup_fs_cmnd(sdev, req);
-}
-
static blk_status_t
scsi_device_state_check(struct scsi_device *sdev, struct request *req)
{
@@ -1577,6 +1545,7 @@ static blk_status_t scsi_prepare_cmd(struct request *req)
cmd->request = req;
cmd->tag = req->tag;
cmd->prot_op = SCSI_PROT_NORMAL;
+ cmd->sc_data_direction = rq_dma_dir(req);
sg = (void *)cmd + sizeof(struct scsi_cmnd) + shost->hostt->cmd_size;
cmd->sdb.table.sgl = sg;
@@ -1590,7 +1559,23 @@ static blk_status_t scsi_prepare_cmd(struct request *req)
blk_mq_start_request(req);
- return scsi_setup_cmnd(sdev, req);
+ /*
+ * Special handling for passthrough commands, which don't go to the ULP
+ * at all:
+ */
+ if (blk_rq_is_scsi(req))
+ return scsi_setup_scsi_cmnd(sdev, req);
+
+ if (sdev->handler && sdev->handler->prep_fn) {
+ blk_status_t ret = sdev->handler->prep_fn(sdev, req);
+
+ if (ret != BLK_STS_OK)
+ return ret;
+ }
+
+ cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
+ memset(cmd->cmnd, 0, BLK_MAX_CDB);
+ return scsi_cmd_to_driver(cmd)->init_command(cmd);
}
static void scsi_mq_done(struct scsi_cmnd *cmd)