ide: use ->tf_read in ide_read_error()
[firefly-linux-kernel-4.4.55.git] / drivers / ide / ide-cd.c
index 275d5ba1202718d05539711f887077a48cb9e23b..82879a1a89e550b18eeceb3519e5fcb6cfee2d5a 100644 (file)
@@ -280,11 +280,12 @@ static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st)
  */
 static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
 {
-       struct request *rq = HWGROUP(drive)->rq;
+       ide_hwif_t *hwif = drive->hwif;
+       struct request *rq = hwif->hwgroup->rq;
        int stat, err, sense_key;
 
        /* check for errors */
-       stat = ide_read_status(drive);
+       stat = hwif->read_status(hwif);
 
        if (stat_ret)
                *stat_ret = stat;
@@ -606,6 +607,8 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
 static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
                                int len, int ireason, int rw)
 {
+       ide_hwif_t *hwif = drive->hwif;
+
        /*
         * ireason == 0: the drive wants to receive data from us
         * ireason == 2: the drive is expecting to transfer data to us
@@ -624,7 +627,7 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
                 * Some drives (ASUS) seem to tell us that status info is
                 * available.  Just get it and ignore.
                 */
-               (void)ide_read_status(drive);
+               (void)hwif->read_status(hwif);
                return 0;
        } else {
                /* drive wants a command packet, or invalid ireason... */
@@ -666,16 +669,9 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len)
 
 static ide_startstop_t cdrom_newpc_intr(ide_drive_t *);
 
-/*
- * Routine to send a read/write packet command to the drive. This is usually
- * called directly from cdrom_start_{read,write}(). However, for drq_interrupt
- * devices, it is called from an interrupt when the drive is ready to accept
- * the command.
- */
-static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
+static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive,
+                                                struct request *rq)
 {
-       struct request *rq = HWGROUP(drive)->rq;
-
        if (rq_data_dir(rq) == READ) {
                unsigned short sectors_per_frame =
                        queue_hardsect_size(drive->queue) >> SECTOR_BITS;
@@ -712,6 +708,19 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
        /* set up the command */
        rq->timeout = ATAPI_WAIT_PC;
 
+       return ide_started;
+}
+
+/*
+ * Routine to send a read/write packet command to the drive. This is usually
+ * called directly from cdrom_start_{read,write}(). However, for drq_interrupt
+ * devices, it is called from an interrupt when the drive is ready to accept
+ * the command.
+ */
+static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
+{
+       struct request *rq = drive->hwif->hwgroup->rq;
+
        /* send the command to the drive and return */
        return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
 }
@@ -1137,9 +1146,6 @@ static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive)
 {
        struct request *rq = HWGROUP(drive)->rq;
 
-       if (!rq->timeout)
-               rq->timeout = ATAPI_WAIT_PC;
-
        return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
 }
 
@@ -1196,8 +1202,9 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
 
        if (blk_fs_request(rq)) {
                if (info->cd_flags & IDE_CD_FLAG_SEEKING) {
+                       ide_hwif_t *hwif = drive->hwif;
                        unsigned long elapsed = jiffies - info->start_seek;
-                       int stat = ide_read_status(drive);
+                       int stat = hwif->read_status(hwif);
 
                        if ((stat & SEEK_STAT) != SEEK_STAT) {
                                if (elapsed < IDECD_SEEK_TIMEOUT) {
@@ -1224,14 +1231,22 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
                } else {
                        xferlen = 32768;
                        fn = cdrom_start_rw_cont;
+
                        if (cdrom_start_rw(drive, rq) == ide_stopped)
                                return ide_stopped;
+
+                       if (ide_cd_prepare_rw_request(drive, rq) == ide_stopped)
+                               return ide_stopped;
                }
                info->last_block = block;
        } else if (blk_sense_request(rq) || blk_pc_request(rq) ||
                   rq->cmd_type == REQ_TYPE_ATA_PC) {
                xferlen = rq->data_len;
                fn = cdrom_do_newpc_cont;
+
+               if (!rq->timeout)
+                       rq->timeout = ATAPI_WAIT_PC;
+
                cdrom_do_block_pc(drive, rq);
        } else if (blk_special_request(rq)) {
                /* right now this can only be a reset... */
@@ -1246,8 +1261,6 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
        return cdrom_start_packet_command(drive, xferlen, fn);
 }
 
-
-
 /*
  * Ioctl handling.
  *
@@ -1943,7 +1956,6 @@ static ide_driver_t ide_cdrom_driver = {
        .do_request             = ide_cd_do_request,
        .end_request            = ide_end_request,
        .error                  = __ide_error,
-       .abort                  = __ide_abort,
 #ifdef CONFIG_IDE_PROC_FS
        .proc                   = idecd_proc,
 #endif