scsi: set sc_data_direction in common code
authorChristoph Hellwig <hch@lst.de>
Sat, 28 Jun 2014 14:41:43 +0000 (16:41 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 17 Jul 2014 20:11:41 +0000 (22:11 +0200)
The data direction fiel in the SCSI command is derived only from the block
request structure.  Move setting it up into common code instead of
duplicating it in the ULDs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
drivers/scsi/scsi_lib.c
drivers/scsi/sd.c
drivers/scsi/sr.c

index 2afb96b801cb343b46672733edca7211a5b9d5df..4e15a3a5ad295a107c8ff023e4ef1700d13c7d45 100644 (file)
@@ -1068,13 +1068,6 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
        }
 
        cmd->cmd_len = req->cmd_len;
-       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;
-       
        cmd->transfersize = blk_rq_bytes(req);
        cmd->allowed = req->retries;
        return BLKPREP_OK;
@@ -1203,6 +1196,13 @@ 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);
index 1b166c7ea891dbed292b584378974ec72bd3684a..e2932ea429e28deca729d696b2c8c95b62154fa2 100644 (file)
@@ -994,14 +994,12 @@ static int sd_init_command(struct scsi_cmnd *SCpnt)
                        goto out;
                }
                SCpnt->cmnd[0] = WRITE_6;
-               SCpnt->sc_data_direction = DMA_TO_DEVICE;
 
                if (blk_integrity_rq(rq))
                        sd_dif_prepare(rq, block, sdp->sector_size);
 
        } else if (rq_data_dir(rq) == READ) {
                SCpnt->cmnd[0] = READ_6;
-               SCpnt->sc_data_direction = DMA_FROM_DEVICE;
        } else {
                scmd_printk(KERN_ERR, SCpnt, "Unknown command %llx\n", (unsigned long long) rq->cmd_flags);
                goto out;
index 9feeb3766d7dc2fe24906005e746e4dc5f12bbe7..cce4771281d93514ff73ad05bef7771cfcc69b2f 100644 (file)
@@ -438,11 +438,9 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
                if (!cd->device->writeable)
                        goto out;
                SCpnt->cmnd[0] = WRITE_10;
-               SCpnt->sc_data_direction = DMA_TO_DEVICE;
                cd->cdi.media_written = 1;
        } else if (rq_data_dir(rq) == READ) {
                SCpnt->cmnd[0] = READ_10;
-               SCpnt->sc_data_direction = DMA_FROM_DEVICE;
        } else {
                blk_dump_rq_flags(rq, "Unknown sr command");
                goto out;