scsi: sr: Use scsi_cmd_to_rq() instead of scsi_cmnd.request
authorBart Van Assche <bvanassche@acm.org>
Mon, 9 Aug 2021 23:03:07 +0000 (16:03 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 12 Aug 2021 02:25:37 +0000 (22:25 -0400)
Prepare for removal of the request pointer by using scsi_cmd_to_rq()
instead. This patch does not change any functionality.

Link: https://lore.kernel.org/r/20210809230355.8186-5-bvanassche@acm.org
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/sr.c

index 6203a8b58d40526e97e6bf7e0aae892f62ec7e14..6a96151d36302e8cc2b3c15b39e0e2b0ffd43986 100644 (file)
@@ -331,7 +331,8 @@ static int sr_done(struct scsi_cmnd *SCpnt)
        int good_bytes = (result == 0 ? this_count : 0);
        int block_sectors = 0;
        long error_sector;
-       struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk);
+       struct request *rq = scsi_cmd_to_rq(SCpnt);
+       struct scsi_cd *cd = scsi_cd(rq->rq_disk);
 
 #ifdef DEBUG
        scmd_printk(KERN_INFO, SCpnt, "done: %x\n", result);
@@ -353,16 +354,14 @@ static int sr_done(struct scsi_cmnd *SCpnt)
                                break;
                        error_sector =
                                get_unaligned_be32(&SCpnt->sense_buffer[3]);
-                       if (SCpnt->request->bio != NULL)
-                               block_sectors =
-                                       bio_sectors(SCpnt->request->bio);
+                       if (rq->bio != NULL)
+                               block_sectors = bio_sectors(rq->bio);
                        if (block_sectors < 4)
                                block_sectors = 4;
                        if (cd->device->sector_size == 2048)
                                error_sector <<= 2;
                        error_sector &= ~(block_sectors - 1);
-                       good_bytes = (error_sector -
-                                     blk_rq_pos(SCpnt->request)) << 9;
+                       good_bytes = (error_sector - blk_rq_pos(rq)) << 9;
                        if (good_bytes < 0 || good_bytes >= this_count)
                                good_bytes = 0;
                        /*
@@ -394,7 +393,7 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt)
 {
        int block = 0, this_count, s_size;
        struct scsi_cd *cd;
-       struct request *rq = SCpnt->request;
+       struct request *rq = scsi_cmd_to_rq(SCpnt);
        blk_status_t ret;
 
        ret = scsi_alloc_sgtables(SCpnt);