]> err.no Git - linux-2.6/blobdiff - drivers/ide/ide-cd.c
ide: add ide_read_bcount_and_ireason() helper
[linux-2.6] / drivers / ide / ide-cd.c
index 6e29dd5320901c65cfe9f9b985cf28c8997832ac..563a380d0e7a7c4e8585b5e1cc9ea6e1282705c7 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... */
@@ -892,10 +895,11 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
        struct request *rq = HWGROUP(drive)->rq;
        xfer_func_t *xferfunc;
        ide_expiry_t *expiry = NULL;
-       int dma_error = 0, dma, stat, ireason, len, thislen, uptodate = 0;
+       int dma_error = 0, dma, stat, thislen, uptodate = 0;
        int write = (rq_data_dir(rq) == WRITE) ? 1 : 0;
        unsigned int timeout;
-       u8 lowcyl, highcyl;
+       u16 len;
+       u8 ireason;
 
        /* check for errors */
        dma = info->dma;
@@ -923,12 +927,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
                goto end_request;
        }
 
-       /* ok we fall to pio :/ */
-       ireason = hwif->INB(hwif->io_ports.nsect_addr) & 0x3;
-       lowcyl  = hwif->INB(hwif->io_ports.lbam_addr);
-       highcyl = hwif->INB(hwif->io_ports.lbah_addr);
-
-       len = lowcyl + (256 * highcyl);
+       ide_read_bcount_and_ireason(drive, &len, &ireason);
 
        thislen = blk_fs_request(rq) ? len : rq->data_len;
        if (thislen > len)
@@ -1199,8 +1198,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) {