efi: stub: get rid of efi_get_max_fdt_addr()
[linux-2.6-microblaze.git] / drivers / scsi / sd.c
index 83c4d95..656bcf4 100644 (file)
@@ -902,7 +902,7 @@ static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd)
        cmd->transfersize = data_len;
        rq->timeout = SD_TIMEOUT;
 
-       return scsi_init_io(cmd);
+       return scsi_alloc_sgtables(cmd);
 }
 
 static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd,
@@ -934,7 +934,7 @@ static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd,
        cmd->transfersize = data_len;
        rq->timeout = unmap ? SD_TIMEOUT : SD_WRITE_SAME_TIMEOUT;
 
-       return scsi_init_io(cmd);
+       return scsi_alloc_sgtables(cmd);
 }
 
 static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,
@@ -966,7 +966,7 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,
        cmd->transfersize = data_len;
        rq->timeout = unmap ? SD_TIMEOUT : SD_WRITE_SAME_TIMEOUT;
 
-       return scsi_init_io(cmd);
+       return scsi_alloc_sgtables(cmd);
 }
 
 static blk_status_t sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd)
@@ -1107,7 +1107,7 @@ static blk_status_t sd_setup_write_same_cmnd(struct scsi_cmnd *cmd)
         * knows how much to actually write.
         */
        rq->__data_len = sdp->sector_size;
-       ret = scsi_init_io(cmd);
+       ret = scsi_alloc_sgtables(cmd);
        rq->__data_len = blk_rq_bytes(rq);
 
        return ret;
@@ -1226,23 +1226,24 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
        unsigned int dif;
        bool dix;
 
-       ret = scsi_init_io(cmd);
+       ret = scsi_alloc_sgtables(cmd);
        if (ret != BLK_STS_OK)
                return ret;
 
+       ret = BLK_STS_IOERR;
        if (!scsi_device_online(sdp) || sdp->changed) {
                scmd_printk(KERN_ERR, cmd, "device offline or changed\n");
-               return BLK_STS_IOERR;
+               goto fail;
        }
 
        if (blk_rq_pos(rq) + blk_rq_sectors(rq) > get_capacity(rq->rq_disk)) {
                scmd_printk(KERN_ERR, cmd, "access beyond end of device\n");
-               return BLK_STS_IOERR;
+               goto fail;
        }
 
        if ((blk_rq_pos(rq) & mask) || (blk_rq_sectors(rq) & mask)) {
                scmd_printk(KERN_ERR, cmd, "request not aligned to the logical block size\n");
-               return BLK_STS_IOERR;
+               goto fail;
        }
 
        /*
@@ -1264,7 +1265,7 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
        if (req_op(rq) == REQ_OP_ZONE_APPEND) {
                ret = sd_zbc_prepare_zone_append(cmd, &lba, nr_blocks);
                if (ret)
-                       return ret;
+                       goto fail;
        }
 
        fua = rq->cmd_flags & REQ_FUA ? 0x8 : 0;
@@ -1292,7 +1293,7 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
        }
 
        if (unlikely(ret != BLK_STS_OK))
-               return ret;
+               goto fail;
 
        /*
         * We shouldn't disconnect in the middle of a sector, so with a dumb
@@ -1316,10 +1317,12 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
                                     blk_rq_sectors(rq)));
 
        /*
-        * This indicates that the command is ready from our end to be
-        * queued.
+        * This indicates that the command is ready from our end to be queued.
         */
        return BLK_STS_OK;
+fail:
+       scsi_free_sgtables(cmd);
+       return ret;
 }
 
 static blk_status_t sd_init_command(struct scsi_cmnd *cmd)