]> err.no Git - linux-2.6/blobdiff - drivers/ide/ide-atapi.c
ide: add ide_host_add() helper
[linux-2.6] / drivers / ide / ide-atapi.c
index 2802031de670a3bfa3f211e9c6a31a184e040948..6789b81ea78d20288bf863301cbd2d878480ee77 100644 (file)
@@ -22,6 +22,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
        void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int))
 {
        ide_hwif_t *hwif = drive->hwif;
+       const struct ide_tp_ops *tp_ops = hwif->tp_ops;
        xfer_func_t *xferfunc;
        unsigned int temp;
        u16 bcount;
@@ -35,7 +36,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
        }
 
        /* Clear the interrupt */
-       stat = ide_read_status(drive);
+       stat = tp_ops->read_status(hwif);
 
        if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
                if (hwif->dma_ops->dma_end(drive) ||
@@ -107,11 +108,9 @@ cmd_finished:
                ide_dma_off(drive);
                return ide_do_reset(drive);
        }
-       /* Get the number of bytes to transfer on this interrupt. */
-       bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) |
-                 hwif->INB(hwif->io_ports.lbam_addr);
 
-       ireason = hwif->INB(hwif->io_ports.nsect_addr);
+       /* Get the number of bytes to transfer on this interrupt. */
+       ide_read_bcount_and_ireason(drive, &bcount, &ireason);
 
        if (ireason & CD) {
                printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__);
@@ -142,7 +141,7 @@ cmd_finished:
                                        if (pc->sg)
                                                io_buffers(drive, pc, temp, 0);
                                        else
-                                               hwif->input_data(drive, NULL,
+                                               tp_ops->input_data(drive, NULL,
                                                        pc->cur_pos, temp);
                                        printk(KERN_ERR "%s: transferred %d of "
                                                        "%d bytes\n",
@@ -159,9 +158,9 @@ cmd_finished:
                        debug_log("The device wants to send us more data than "
                                  "expected - allowing transfer\n");
                }
-               xferfunc = hwif->input_data;
+               xferfunc = tp_ops->input_data;
        } else
-               xferfunc = hwif->output_data;
+               xferfunc = tp_ops->output_data;
 
        if ((drive->media == ide_floppy && !scsi && !pc->buf) ||
            (drive->media == ide_tape && !scsi && pc->bh) ||
@@ -183,16 +182,27 @@ cmd_finished:
 }
 EXPORT_SYMBOL_GPL(ide_pc_intr);
 
+static u8 ide_read_ireason(ide_drive_t *drive)
+{
+       ide_task_t task;
+
+       memset(&task, 0, sizeof(task));
+       task.tf_flags = IDE_TFLAG_IN_NSECT;
+
+       drive->hwif->tp_ops->tf_read(drive, &task);
+
+       return task.tf.nsect & 3;
+}
+
 static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
 {
-       ide_hwif_t *hwif = drive->hwif;
        int retries = 100;
 
        while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) {
                printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
                                "a packet command, retrying\n", drive->name);
                udelay(100);
-               ireason = hwif->INB(hwif->io_ports.nsect_addr);
+               ireason = ide_read_ireason(drive);
                if (retries == 0) {
                        printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
                                        "a packet command, ignoring\n",
@@ -219,7 +229,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
                return startstop;
        }
 
-       ireason = hwif->INB(hwif->io_ports.nsect_addr);
+       ireason = ide_read_ireason(drive);
        if (drive->media == ide_tape && !drive->scsi)
                ireason = ide_wait_ireason(drive, ireason);
 
@@ -240,7 +250,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
 
        /* Send the actual packet */
        if ((pc->flags & PC_FLAG_ZIP_DRIVE) == 0)
-               hwif->output_data(drive, NULL, pc->c, 12);
+               hwif->tp_ops->output_data(drive, NULL, pc->c, 12);
 
        return ide_started;
 }