aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/arm/icside.c2
-rw-r--r--drivers/ide/h8300/ide-h8300.c26
-rw-r--r--drivers/ide/ide-atapi.c13
-rw-r--r--drivers/ide/ide-cd.c12
-rw-r--r--drivers/ide/ide-dma.c12
-rw-r--r--drivers/ide/ide-floppy.c8
-rw-r--r--drivers/ide/ide-io.c32
-rw-r--r--drivers/ide/ide-iops.c122
-rw-r--r--drivers/ide/ide-lib.c2
-rw-r--r--drivers/ide/ide-probe.c53
-rw-r--r--drivers/ide/ide-tape.c8
-rw-r--r--drivers/ide/ide-taskfile.c29
-rw-r--r--drivers/ide/ide.c2
-rw-r--r--drivers/ide/legacy/falconide.c27
-rw-r--r--drivers/ide/legacy/q40ide.c27
-rw-r--r--drivers/ide/mips/au1xxx-ide.c29
-rw-r--r--drivers/ide/pci/ns87415.c50
-rw-r--r--drivers/ide/pci/scc_pata.c29
-rw-r--r--drivers/ide/pci/sgiioc4.c18
-rw-r--r--drivers/ide/ppc/pmac.c21
-rw-r--r--drivers/ide/setup-pci.c2
-rw-r--r--drivers/scsi/ide-scsi.c7
-rw-r--r--include/linux/ide.h52
23 files changed, 358 insertions, 225 deletions
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c
index 0fd01d630f12..0283d162f7f7 100644
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -382,7 +382,7 @@ static void icside_dma_timeout(ide_drive_t *drive)
382 if (icside_dma_test_irq(drive)) 382 if (icside_dma_test_irq(drive))
383 return; 383 return;
384 384
385 ide_dump_status(drive, "DMA timeout", hwif->read_status(hwif)); 385 ide_dump_status(drive, "DMA timeout", hwif->tp_ops->read_status(hwif));
386 386
387 icside_dma_end(drive); 387 icside_dma_end(drive);
388} 388}
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c
index 0795d6554913..84644e150531 100644
--- a/drivers/ide/h8300/ide-h8300.c
+++ b/drivers/ide/h8300/ide-h8300.c
@@ -155,6 +155,21 @@ static void h8300_output_data(ide_drive_t *drive, struct request *rq,
155 mm_outsw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2); 155 mm_outsw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
156} 156}
157 157
158static const struct ide_tp_ops h8300_tp_ops = {
159 .exec_command = ide_exec_command,
160 .read_status = ide_read_status,
161 .read_altstatus = ide_read_altstatus,
162 .read_sff_dma_status = ide_read_sff_dma_status,
163
164 .set_irq = ide_set_irq,
165
166 .tf_load = h8300_tf_load,
167 .tf_read = h8300_tf_read,
168
169 .input_data = h8300_input_data,
170 .output_data = h8300_output_data,
171};
172
158#define H8300_IDE_GAP (2) 173#define H8300_IDE_GAP (2)
159 174
160static inline void hw_setup(hw_regs_t *hw) 175static inline void hw_setup(hw_regs_t *hw)
@@ -169,16 +184,8 @@ static inline void hw_setup(hw_regs_t *hw)
169 hw->chipset = ide_generic; 184 hw->chipset = ide_generic;
170} 185}
171 186
172static inline void hwif_setup(ide_hwif_t *hwif)
173{
174 hwif->tf_load = h8300_tf_load;
175 hwif->tf_read = h8300_tf_read;
176
177 hwif->input_data = h8300_input_data;
178 hwif->output_data = h8300_output_data;
179}
180
181static const struct ide_port_info h8300_port_info = { 187static const struct ide_port_info h8300_port_info = {
188 .tp_ops = &h8300_tp_ops,
182 .host_flags = IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA, 189 .host_flags = IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA,
183}; 190};
184 191
@@ -205,7 +212,6 @@ static int __init h8300_ide_init(void)
205 return -ENOENT; 212 return -ENOENT;
206 213
207 index = hwif->index; 214 index = hwif->index;
208 hwif_setup(hwif);
209 215
210 idx[0] = index; 216 idx[0] = index;
211 217
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index f17a00ccbe96..6789b81ea78d 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -22,6 +22,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
22 void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) 22 void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int))
23{ 23{
24 ide_hwif_t *hwif = drive->hwif; 24 ide_hwif_t *hwif = drive->hwif;
25 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
25 xfer_func_t *xferfunc; 26 xfer_func_t *xferfunc;
26 unsigned int temp; 27 unsigned int temp;
27 u16 bcount; 28 u16 bcount;
@@ -35,7 +36,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
35 } 36 }
36 37
37 /* Clear the interrupt */ 38 /* Clear the interrupt */
38 stat = hwif->read_status(hwif); 39 stat = tp_ops->read_status(hwif);
39 40
40 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { 41 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
41 if (hwif->dma_ops->dma_end(drive) || 42 if (hwif->dma_ops->dma_end(drive) ||
@@ -140,7 +141,7 @@ cmd_finished:
140 if (pc->sg) 141 if (pc->sg)
141 io_buffers(drive, pc, temp, 0); 142 io_buffers(drive, pc, temp, 0);
142 else 143 else
143 hwif->input_data(drive, NULL, 144 tp_ops->input_data(drive, NULL,
144 pc->cur_pos, temp); 145 pc->cur_pos, temp);
145 printk(KERN_ERR "%s: transferred %d of " 146 printk(KERN_ERR "%s: transferred %d of "
146 "%d bytes\n", 147 "%d bytes\n",
@@ -157,9 +158,9 @@ cmd_finished:
157 debug_log("The device wants to send us more data than " 158 debug_log("The device wants to send us more data than "
158 "expected - allowing transfer\n"); 159 "expected - allowing transfer\n");
159 } 160 }
160 xferfunc = hwif->input_data; 161 xferfunc = tp_ops->input_data;
161 } else 162 } else
162 xferfunc = hwif->output_data; 163 xferfunc = tp_ops->output_data;
163 164
164 if ((drive->media == ide_floppy && !scsi && !pc->buf) || 165 if ((drive->media == ide_floppy && !scsi && !pc->buf) ||
165 (drive->media == ide_tape && !scsi && pc->bh) || 166 (drive->media == ide_tape && !scsi && pc->bh) ||
@@ -188,7 +189,7 @@ static u8 ide_read_ireason(ide_drive_t *drive)
188 memset(&task, 0, sizeof(task)); 189 memset(&task, 0, sizeof(task));
189 task.tf_flags = IDE_TFLAG_IN_NSECT; 190 task.tf_flags = IDE_TFLAG_IN_NSECT;
190 191
191 drive->hwif->tf_read(drive, &task); 192 drive->hwif->tp_ops->tf_read(drive, &task);
192 193
193 return task.tf.nsect & 3; 194 return task.tf.nsect & 3;
194} 195}
@@ -249,7 +250,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
249 250
250 /* Send the actual packet */ 251 /* Send the actual packet */
251 if ((pc->flags & PC_FLAG_ZIP_DRIVE) == 0) 252 if ((pc->flags & PC_FLAG_ZIP_DRIVE) == 0)
252 hwif->output_data(drive, NULL, pc->c, 12); 253 hwif->tp_ops->output_data(drive, NULL, pc->c, 12);
253 254
254 return ide_started; 255 return ide_started;
255} 256}
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 563a380d0e7a..d9798ca433ba 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -285,7 +285,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
285 int stat, err, sense_key; 285 int stat, err, sense_key;
286 286
287 /* check for errors */ 287 /* check for errors */
288 stat = hwif->read_status(hwif); 288 stat = hwif->tp_ops->read_status(hwif);
289 289
290 if (stat_ret) 290 if (stat_ret)
291 *stat_ret = stat; 291 *stat_ret = stat;
@@ -590,7 +590,7 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
590 cmd_len = ATAPI_MIN_CDB_BYTES; 590 cmd_len = ATAPI_MIN_CDB_BYTES;
591 591
592 /* send the command to the device */ 592 /* send the command to the device */
593 hwif->output_data(drive, NULL, rq->cmd, cmd_len); 593 hwif->tp_ops->output_data(drive, NULL, rq->cmd, cmd_len);
594 594
595 /* start the DMA if need be */ 595 /* start the DMA if need be */
596 if (info->dma) 596 if (info->dma)
@@ -627,7 +627,7 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
627 * Some drives (ASUS) seem to tell us that status info is 627 * Some drives (ASUS) seem to tell us that status info is
628 * available. Just get it and ignore. 628 * available. Just get it and ignore.
629 */ 629 */
630 (void)hwif->read_status(hwif); 630 (void)hwif->tp_ops->read_status(hwif);
631 return 0; 631 return 0;
632 } else { 632 } else {
633 /* drive wants a command packet, or invalid ireason... */ 633 /* drive wants a command packet, or invalid ireason... */
@@ -990,10 +990,10 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
990 990
991 if (ireason == 0) { 991 if (ireason == 0) {
992 write = 1; 992 write = 1;
993 xferfunc = hwif->output_data; 993 xferfunc = hwif->tp_ops->output_data;
994 } else { 994 } else {
995 write = 0; 995 write = 0;
996 xferfunc = hwif->input_data; 996 xferfunc = hwif->tp_ops->input_data;
997 } 997 }
998 998
999 /* transfer data */ 999 /* transfer data */
@@ -1200,7 +1200,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1200 if (info->cd_flags & IDE_CD_FLAG_SEEKING) { 1200 if (info->cd_flags & IDE_CD_FLAG_SEEKING) {
1201 ide_hwif_t *hwif = drive->hwif; 1201 ide_hwif_t *hwif = drive->hwif;
1202 unsigned long elapsed = jiffies - info->start_seek; 1202 unsigned long elapsed = jiffies - info->start_seek;
1203 int stat = hwif->read_status(hwif); 1203 int stat = hwif->tp_ops->read_status(hwif);
1204 1204
1205 if ((stat & SEEK_STAT) != SEEK_STAT) { 1205 if ((stat & SEEK_STAT) != SEEK_STAT) {
1206 if (elapsed < IDECD_SEEK_TIMEOUT) { 1206 if (elapsed < IDECD_SEEK_TIMEOUT) {
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index e72112efab9a..be99d463dcc7 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -104,7 +104,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive)
104 u8 stat = 0, dma_stat = 0; 104 u8 stat = 0, dma_stat = 0;
105 105
106 dma_stat = hwif->dma_ops->dma_end(drive); 106 dma_stat = hwif->dma_ops->dma_end(drive);
107 stat = hwif->read_status(hwif); 107 stat = hwif->tp_ops->read_status(hwif);
108 108
109 if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { 109 if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
110 if (!dma_stat) { 110 if (!dma_stat) {
@@ -335,7 +335,7 @@ static int config_drive_for_dma (ide_drive_t *drive)
335static int dma_timer_expiry (ide_drive_t *drive) 335static int dma_timer_expiry (ide_drive_t *drive)
336{ 336{
337 ide_hwif_t *hwif = HWIF(drive); 337 ide_hwif_t *hwif = HWIF(drive);
338 u8 dma_stat = hwif->read_sff_dma_status(hwif); 338 u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
339 339
340 printk(KERN_WARNING "%s: dma_timer_expiry: dma status == 0x%02x\n", 340 printk(KERN_WARNING "%s: dma_timer_expiry: dma status == 0x%02x\n",
341 drive->name, dma_stat); 341 drive->name, dma_stat);
@@ -370,7 +370,7 @@ void ide_dma_host_set(ide_drive_t *drive, int on)
370{ 370{
371 ide_hwif_t *hwif = HWIF(drive); 371 ide_hwif_t *hwif = HWIF(drive);
372 u8 unit = (drive->select.b.unit & 0x01); 372 u8 unit = (drive->select.b.unit & 0x01);
373 u8 dma_stat = hwif->read_sff_dma_status(hwif); 373 u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
374 374
375 if (on) 375 if (on)
376 dma_stat |= (1 << (5 + unit)); 376 dma_stat |= (1 << (5 + unit));
@@ -482,7 +482,7 @@ int ide_dma_setup(ide_drive_t *drive)
482 outb(reading, hwif->dma_base + ATA_DMA_CMD); 482 outb(reading, hwif->dma_base + ATA_DMA_CMD);
483 483
484 /* read DMA status for INTR & ERROR flags */ 484 /* read DMA status for INTR & ERROR flags */
485 dma_stat = hwif->read_sff_dma_status(hwif); 485 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
486 486
487 /* clear INTR & ERROR flags */ 487 /* clear INTR & ERROR flags */
488 if (mmio) 488 if (mmio)
@@ -551,7 +551,7 @@ int __ide_dma_end (ide_drive_t *drive)
551 } 551 }
552 552
553 /* get DMA status */ 553 /* get DMA status */
554 dma_stat = hwif->read_sff_dma_status(hwif); 554 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
555 555
556 if (mmio) 556 if (mmio)
557 /* clear the INTR & ERROR bits */ 557 /* clear the INTR & ERROR bits */
@@ -574,7 +574,7 @@ EXPORT_SYMBOL(__ide_dma_end);
574int ide_dma_test_irq(ide_drive_t *drive) 574int ide_dma_test_irq(ide_drive_t *drive)
575{ 575{
576 ide_hwif_t *hwif = HWIF(drive); 576 ide_hwif_t *hwif = HWIF(drive);
577 u8 dma_stat = hwif->read_sff_dma_status(hwif); 577 u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
578 578
579 /* return 1 if INTR asserted */ 579 /* return 1 if INTR asserted */
580 if ((dma_stat & 4) == 4) 580 if ((dma_stat & 4) == 4)
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 6f5294cfff23..62be2b27f236 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -247,9 +247,9 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
247 247
248 data = bvec_kmap_irq(bvec, &flags); 248 data = bvec_kmap_irq(bvec, &flags);
249 if (direction) 249 if (direction)
250 hwif->output_data(drive, NULL, data, count); 250 hwif->tp_ops->output_data(drive, NULL, data, count);
251 else 251 else
252 hwif->input_data(drive, NULL, data, count); 252 hwif->tp_ops->input_data(drive, NULL, data, count);
253 bvec_kunmap_irq(data, &flags); 253 bvec_kunmap_irq(data, &flags);
254 254
255 bcount -= count; 255 bcount -= count;
@@ -402,7 +402,7 @@ static int idefloppy_transfer_pc(ide_drive_t *drive)
402 idefloppy_floppy_t *floppy = drive->driver_data; 402 idefloppy_floppy_t *floppy = drive->driver_data;
403 403
404 /* Send the actual packet */ 404 /* Send the actual packet */
405 drive->hwif->output_data(drive, NULL, floppy->pc->c, 12); 405 drive->hwif->tp_ops->output_data(drive, NULL, floppy->pc->c, 12);
406 406
407 /* Timeout for the packet command */ 407 /* Timeout for the packet command */
408 return IDEFLOPPY_WAIT_CMD; 408 return IDEFLOPPY_WAIT_CMD;
@@ -954,7 +954,7 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
954 u8 stat; 954 u8 stat;
955 955
956 local_irq_save(flags); 956 local_irq_save(flags);
957 stat = hwif->read_status(hwif); 957 stat = hwif->tp_ops->read_status(hwif);
958 local_irq_restore(flags); 958 local_irq_restore(flags);
959 959
960 progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000; 960 progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000;
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index bbd7bd4c48ee..a896a283f27f 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -330,7 +330,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
330 tf->error = err; 330 tf->error = err;
331 tf->status = stat; 331 tf->status = stat;
332 332
333 drive->hwif->tf_read(drive, task); 333 drive->hwif->tp_ops->tf_read(drive, task);
334 334
335 if (task->tf_flags & IDE_TFLAG_DYN) 335 if (task->tf_flags & IDE_TFLAG_DYN)
336 kfree(task); 336 kfree(task);
@@ -381,7 +381,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
381 if (err == ABRT_ERR) { 381 if (err == ABRT_ERR) {
382 if (drive->select.b.lba && 382 if (drive->select.b.lba &&
383 /* some newer drives don't support WIN_SPECIFY */ 383 /* some newer drives don't support WIN_SPECIFY */
384 hwif->read_status(hwif) == WIN_SPECIFY) 384 hwif->tp_ops->read_status(hwif) == WIN_SPECIFY)
385 return ide_stopped; 385 return ide_stopped;
386 } else if ((err & BAD_CRC) == BAD_CRC) { 386 } else if ((err & BAD_CRC) == BAD_CRC) {
387 /* UDMA crc error, just retry the operation */ 387 /* UDMA crc error, just retry the operation */
@@ -407,7 +407,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
407 return ide_stopped; 407 return ide_stopped;
408 } 408 }
409 409
410 if (hwif->read_status(hwif) & (BUSY_STAT | DRQ_STAT)) 410 if (hwif->tp_ops->read_status(hwif) & (BUSY_STAT | DRQ_STAT))
411 rq->errors |= ERROR_RESET; 411 rq->errors |= ERROR_RESET;
412 412
413 if ((rq->errors & ERROR_RESET) == ERROR_RESET) { 413 if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
@@ -434,9 +434,9 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u
434 /* add decoding error stuff */ 434 /* add decoding error stuff */
435 } 435 }
436 436
437 if (hwif->read_status(hwif) & (BUSY_STAT | DRQ_STAT)) 437 if (hwif->tp_ops->read_status(hwif) & (BUSY_STAT | DRQ_STAT))
438 /* force an abort */ 438 /* force an abort */
439 hwif->exec_command(hwif, WIN_IDLEIMMEDIATE); 439 hwif->tp_ops->exec_command(hwif, WIN_IDLEIMMEDIATE);
440 440
441 if (rq->errors >= ERROR_MAX) { 441 if (rq->errors >= ERROR_MAX) {
442 ide_kill_rq(drive, rq); 442 ide_kill_rq(drive, rq);
@@ -710,7 +710,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
710#ifdef DEBUG 710#ifdef DEBUG
711 printk("%s: DRIVE_CMD (null)\n", drive->name); 711 printk("%s: DRIVE_CMD (null)\n", drive->name);
712#endif 712#endif
713 ide_end_drive_cmd(drive, hwif->read_status(hwif), 713 ide_end_drive_cmd(drive, hwif->tp_ops->read_status(hwif),
714 ide_read_error(drive)); 714 ide_read_error(drive));
715 715
716 return ide_stopped; 716 return ide_stopped;
@@ -755,7 +755,7 @@ static void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
755 if (rc) 755 if (rc)
756 printk(KERN_WARNING "%s: bus not ready on wakeup\n", drive->name); 756 printk(KERN_WARNING "%s: bus not ready on wakeup\n", drive->name);
757 SELECT_DRIVE(drive); 757 SELECT_DRIVE(drive);
758 hwif->set_irq(hwif, 1); 758 hwif->tp_ops->set_irq(hwif, 1);
759 rc = ide_wait_not_busy(hwif, 100000); 759 rc = ide_wait_not_busy(hwif, 100000);
760 if (rc) 760 if (rc)
761 printk(KERN_WARNING "%s: drive not ready on wakeup\n", drive->name); 761 printk(KERN_WARNING "%s: drive not ready on wakeup\n", drive->name);
@@ -1042,7 +1042,7 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
1042 * quirk_list may not like intr setups/cleanups 1042 * quirk_list may not like intr setups/cleanups
1043 */ 1043 */
1044 if (drive->quirk_list != 1) 1044 if (drive->quirk_list != 1)
1045 hwif->set_irq(hwif, 0); 1045 hwif->tp_ops->set_irq(hwif, 0);
1046 } 1046 }
1047 hwgroup->hwif = hwif; 1047 hwgroup->hwif = hwif;
1048 hwgroup->drive = drive; 1048 hwgroup->drive = drive;
@@ -1142,7 +1142,7 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
1142 printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); 1142 printk(KERN_WARNING "%s: DMA timeout error\n", drive->name);
1143 (void)hwif->dma_ops->dma_end(drive); 1143 (void)hwif->dma_ops->dma_end(drive);
1144 ret = ide_error(drive, "dma timeout error", 1144 ret = ide_error(drive, "dma timeout error",
1145 hwif->read_status(hwif)); 1145 hwif->tp_ops->read_status(hwif));
1146 } else { 1146 } else {
1147 printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); 1147 printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name);
1148 hwif->dma_ops->dma_timeout(drive); 1148 hwif->dma_ops->dma_timeout(drive);
@@ -1267,7 +1267,7 @@ void ide_timer_expiry (unsigned long data)
1267 } else 1267 } else
1268 startstop = 1268 startstop =
1269 ide_error(drive, "irq timeout", 1269 ide_error(drive, "irq timeout",
1270 hwif->read_status(hwif)); 1270 hwif->tp_ops->read_status(hwif));
1271 } 1271 }
1272 drive->service_time = jiffies - drive->service_start; 1272 drive->service_time = jiffies - drive->service_start;
1273 spin_lock_irq(&ide_lock); 1273 spin_lock_irq(&ide_lock);
@@ -1323,7 +1323,7 @@ static void unexpected_intr (int irq, ide_hwgroup_t *hwgroup)
1323 */ 1323 */
1324 do { 1324 do {
1325 if (hwif->irq == irq) { 1325 if (hwif->irq == irq) {
1326 stat = hwif->read_status(hwif); 1326 stat = hwif->tp_ops->read_status(hwif);
1327 1327
1328 if (!OK_STAT(stat, READY_STAT, BAD_STAT)) { 1328 if (!OK_STAT(stat, READY_STAT, BAD_STAT)) {
1329 /* Try to not flood the console with msgs */ 1329 /* Try to not flood the console with msgs */
@@ -1414,7 +1414,7 @@ irqreturn_t ide_intr (int irq, void *dev_id)
1414 * Whack the status register, just in case 1414 * Whack the status register, just in case
1415 * we have a leftover pending IRQ. 1415 * we have a leftover pending IRQ.
1416 */ 1416 */
1417 (void)hwif->read_status(hwif); 1417 (void)hwif->tp_ops->read_status(hwif);
1418#endif /* CONFIG_BLK_DEV_IDEPCI */ 1418#endif /* CONFIG_BLK_DEV_IDEPCI */
1419 } 1419 }
1420 spin_unlock_irqrestore(&ide_lock, flags); 1420 spin_unlock_irqrestore(&ide_lock, flags);
@@ -1531,9 +1531,9 @@ void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount, u8 dma)
1531 task.tf.lbah = (bcount >> 8) & 0xff; 1531 task.tf.lbah = (bcount >> 8) & 0xff;
1532 1532
1533 ide_tf_dump(drive->name, &task.tf); 1533 ide_tf_dump(drive->name, &task.tf);
1534 hwif->set_irq(hwif, 1); 1534 hwif->tp_ops->set_irq(hwif, 1);
1535 SELECT_MASK(drive, 0); 1535 SELECT_MASK(drive, 0);
1536 hwif->tf_load(drive, &task); 1536 hwif->tp_ops->tf_load(drive, &task);
1537} 1537}
1538 1538
1539EXPORT_SYMBOL_GPL(ide_pktcmd_tf_load); 1539EXPORT_SYMBOL_GPL(ide_pktcmd_tf_load);
@@ -1545,9 +1545,9 @@ void ide_pad_transfer(ide_drive_t *drive, int write, int len)
1545 1545
1546 while (len > 0) { 1546 while (len > 0) {
1547 if (write) 1547 if (write)
1548 hwif->output_data(drive, NULL, buf, min(4, len)); 1548 hwif->tp_ops->output_data(drive, NULL, buf, min(4, len));
1549 else 1549 else
1550 hwif->input_data(drive, NULL, buf, min(4, len)); 1550 hwif->tp_ops->input_data(drive, NULL, buf, min(4, len));
1551 len -= 4; 1551 len -= 4;
1552 } 1552 }
1553} 1553}
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index c9d15be4c48d..07da5fb9eaff 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -68,7 +68,7 @@ void SELECT_DRIVE (ide_drive_t *drive)
68 memset(&task, 0, sizeof(task)); 68 memset(&task, 0, sizeof(task));
69 task.tf_flags = IDE_TFLAG_OUT_DEVICE; 69 task.tf_flags = IDE_TFLAG_OUT_DEVICE;
70 70
71 drive->hwif->tf_load(drive, &task); 71 drive->hwif->tp_ops->tf_load(drive, &task);
72} 72}
73 73
74void SELECT_MASK(ide_drive_t *drive, int mask) 74void SELECT_MASK(ide_drive_t *drive, int mask)
@@ -79,39 +79,43 @@ void SELECT_MASK(ide_drive_t *drive, int mask)
79 port_ops->maskproc(drive, mask); 79 port_ops->maskproc(drive, mask);
80} 80}
81 81
82static void ide_exec_command(ide_hwif_t *hwif, u8 cmd) 82void ide_exec_command(ide_hwif_t *hwif, u8 cmd)
83{ 83{
84 if (hwif->host_flags & IDE_HFLAG_MMIO) 84 if (hwif->host_flags & IDE_HFLAG_MMIO)
85 writeb(cmd, (void __iomem *)hwif->io_ports.command_addr); 85 writeb(cmd, (void __iomem *)hwif->io_ports.command_addr);
86 else 86 else
87 outb(cmd, hwif->io_ports.command_addr); 87 outb(cmd, hwif->io_ports.command_addr);
88} 88}
89EXPORT_SYMBOL_GPL(ide_exec_command);
89 90
90static u8 ide_read_status(ide_hwif_t *hwif) 91u8 ide_read_status(ide_hwif_t *hwif)
91{ 92{
92 if (hwif->host_flags & IDE_HFLAG_MMIO) 93 if (hwif->host_flags & IDE_HFLAG_MMIO)
93 return readb((void __iomem *)hwif->io_ports.status_addr); 94 return readb((void __iomem *)hwif->io_ports.status_addr);
94 else 95 else
95 return inb(hwif->io_ports.status_addr); 96 return inb(hwif->io_ports.status_addr);
96} 97}
98EXPORT_SYMBOL_GPL(ide_read_status);
97 99
98static u8 ide_read_altstatus(ide_hwif_t *hwif) 100u8 ide_read_altstatus(ide_hwif_t *hwif)
99{ 101{
100 if (hwif->host_flags & IDE_HFLAG_MMIO) 102 if (hwif->host_flags & IDE_HFLAG_MMIO)
101 return readb((void __iomem *)hwif->io_ports.ctl_addr); 103 return readb((void __iomem *)hwif->io_ports.ctl_addr);
102 else 104 else
103 return inb(hwif->io_ports.ctl_addr); 105 return inb(hwif->io_ports.ctl_addr);
104} 106}
107EXPORT_SYMBOL_GPL(ide_read_altstatus);
105 108
106static u8 ide_read_sff_dma_status(ide_hwif_t *hwif) 109u8 ide_read_sff_dma_status(ide_hwif_t *hwif)
107{ 110{
108 if (hwif->host_flags & IDE_HFLAG_MMIO) 111 if (hwif->host_flags & IDE_HFLAG_MMIO)
109 return readb((void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); 112 return readb((void __iomem *)(hwif->dma_base + ATA_DMA_STATUS));
110 else 113 else
111 return inb(hwif->dma_base + ATA_DMA_STATUS); 114 return inb(hwif->dma_base + ATA_DMA_STATUS);
112} 115}
116EXPORT_SYMBOL_GPL(ide_read_sff_dma_status);
113 117
114static void ide_set_irq(ide_hwif_t *hwif, int on) 118void ide_set_irq(ide_hwif_t *hwif, int on)
115{ 119{
116 u8 ctl = ATA_DEVCTL_OBS; 120 u8 ctl = ATA_DEVCTL_OBS;
117 121
@@ -127,8 +131,9 @@ static void ide_set_irq(ide_hwif_t *hwif, int on)
127 else 131 else
128 outb(ctl, hwif->io_ports.ctl_addr); 132 outb(ctl, hwif->io_ports.ctl_addr);
129} 133}
134EXPORT_SYMBOL_GPL(ide_set_irq);
130 135
131static void ide_tf_load(ide_drive_t *drive, ide_task_t *task) 136void ide_tf_load(ide_drive_t *drive, ide_task_t *task)
132{ 137{
133 ide_hwif_t *hwif = drive->hwif; 138 ide_hwif_t *hwif = drive->hwif;
134 struct ide_io_ports *io_ports = &hwif->io_ports; 139 struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -180,8 +185,9 @@ static void ide_tf_load(ide_drive_t *drive, ide_task_t *task)
180 tf_outb((tf->device & HIHI) | drive->select.all, 185 tf_outb((tf->device & HIHI) | drive->select.all,
181 io_ports->device_addr); 186 io_ports->device_addr);
182} 187}
188EXPORT_SYMBOL_GPL(ide_tf_load);
183 189
184static void ide_tf_read(ide_drive_t *drive, ide_task_t *task) 190void ide_tf_read(ide_drive_t *drive, ide_task_t *task)
185{ 191{
186 ide_hwif_t *hwif = drive->hwif; 192 ide_hwif_t *hwif = drive->hwif;
187 struct ide_io_ports *io_ports = &hwif->io_ports; 193 struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -241,6 +247,7 @@ static void ide_tf_read(ide_drive_t *drive, ide_task_t *task)
241 tf->hob_lbah = tf_inb(io_ports->lbah_addr); 247 tf->hob_lbah = tf_inb(io_ports->lbah_addr);
242 } 248 }
243} 249}
250EXPORT_SYMBOL_GPL(ide_tf_read);
244 251
245/* 252/*
246 * Some localbus EIDE interfaces require a special access sequence 253 * Some localbus EIDE interfaces require a special access sequence
@@ -263,8 +270,8 @@ static void ata_vlb_sync(unsigned long port)
263 * so if an odd len is specified, be sure that there's at least one 270 * so if an odd len is specified, be sure that there's at least one
264 * extra byte allocated for the buffer. 271 * extra byte allocated for the buffer.
265 */ 272 */
266static void ata_input_data(ide_drive_t *drive, struct request *rq, 273void ide_input_data(ide_drive_t *drive, struct request *rq, void *buf,
267 void *buf, unsigned int len) 274 unsigned int len)
268{ 275{
269 ide_hwif_t *hwif = drive->hwif; 276 ide_hwif_t *hwif = drive->hwif;
270 struct ide_io_ports *io_ports = &hwif->io_ports; 277 struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -304,12 +311,13 @@ static void ata_input_data(ide_drive_t *drive, struct request *rq,
304 insw(data_addr, buf, len / 2); 311 insw(data_addr, buf, len / 2);
305 } 312 }
306} 313}
314EXPORT_SYMBOL_GPL(ide_input_data);
307 315
308/* 316/*
309 * This is used for most PIO data transfers *to* the IDE interface 317 * This is used for most PIO data transfers *to* the IDE interface
310 */ 318 */
311static void ata_output_data(ide_drive_t *drive, struct request *rq, 319void ide_output_data(ide_drive_t *drive, struct request *rq, void *buf,
312 void *buf, unsigned int len) 320 unsigned int len)
313{ 321{
314 ide_hwif_t *hwif = drive->hwif; 322 ide_hwif_t *hwif = drive->hwif;
315 struct ide_io_ports *io_ports = &hwif->io_ports; 323 struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -347,22 +355,7 @@ static void ata_output_data(ide_drive_t *drive, struct request *rq,
347 outsw(data_addr, buf, len / 2); 355 outsw(data_addr, buf, len / 2);
348 } 356 }
349} 357}
350 358EXPORT_SYMBOL_GPL(ide_output_data);
351void default_hwif_transport(ide_hwif_t *hwif)
352{
353 hwif->exec_command = ide_exec_command;
354 hwif->read_status = ide_read_status;
355 hwif->read_altstatus = ide_read_altstatus;
356 hwif->read_sff_dma_status = ide_read_sff_dma_status;
357
358 hwif->set_irq = ide_set_irq;
359
360 hwif->tf_load = ide_tf_load;
361 hwif->tf_read = ide_tf_read;
362
363 hwif->input_data = ata_input_data;
364 hwif->output_data = ata_output_data;
365}
366 359
367u8 ide_read_error(ide_drive_t *drive) 360u8 ide_read_error(ide_drive_t *drive)
368{ 361{
@@ -371,7 +364,7 @@ u8 ide_read_error(ide_drive_t *drive)
371 memset(&task, 0, sizeof(task)); 364 memset(&task, 0, sizeof(task));
372 task.tf_flags = IDE_TFLAG_IN_FEATURE; 365 task.tf_flags = IDE_TFLAG_IN_FEATURE;
373 366
374 drive->hwif->tf_read(drive, &task); 367 drive->hwif->tp_ops->tf_read(drive, &task);
375 368
376 return task.tf.error; 369 return task.tf.error;
377} 370}
@@ -385,13 +378,28 @@ void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason)
385 task.tf_flags = IDE_TFLAG_IN_LBAH | IDE_TFLAG_IN_LBAM | 378 task.tf_flags = IDE_TFLAG_IN_LBAH | IDE_TFLAG_IN_LBAM |
386 IDE_TFLAG_IN_NSECT; 379 IDE_TFLAG_IN_NSECT;
387 380
388 drive->hwif->tf_read(drive, &task); 381 drive->hwif->tp_ops->tf_read(drive, &task);
389 382
390 *bcount = (task.tf.lbah << 8) | task.tf.lbam; 383 *bcount = (task.tf.lbah << 8) | task.tf.lbam;
391 *ireason = task.tf.nsect & 3; 384 *ireason = task.tf.nsect & 3;
392} 385}
393EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason); 386EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason);
394 387
388const struct ide_tp_ops default_tp_ops = {
389 .exec_command = ide_exec_command,
390 .read_status = ide_read_status,
391 .read_altstatus = ide_read_altstatus,
392 .read_sff_dma_status = ide_read_sff_dma_status,
393
394 .set_irq = ide_set_irq,
395
396 .tf_load = ide_tf_load,
397 .tf_read = ide_tf_read,
398
399 .input_data = ide_input_data,
400 .output_data = ide_output_data,
401};
402
395void ide_fix_driveid (struct hd_driveid *id) 403void ide_fix_driveid (struct hd_driveid *id)
396{ 404{
397#ifndef __LITTLE_ENDIAN 405#ifndef __LITTLE_ENDIAN
@@ -545,10 +553,10 @@ int drive_is_ready (ide_drive_t *drive)
545 * about possible isa-pnp and pci-pnp issues yet. 553 * about possible isa-pnp and pci-pnp issues yet.
546 */ 554 */
547 if (hwif->io_ports.ctl_addr) 555 if (hwif->io_ports.ctl_addr)
548 stat = hwif->read_altstatus(hwif); 556 stat = hwif->tp_ops->read_altstatus(hwif);
549 else 557 else
550 /* Note: this may clear a pending IRQ!! */ 558 /* Note: this may clear a pending IRQ!! */
551 stat = hwif->read_status(hwif); 559 stat = hwif->tp_ops->read_status(hwif);
552 560
553 if (stat & BUSY_STAT) 561 if (stat & BUSY_STAT)
554 /* drive busy: definitely not interrupting */ 562 /* drive busy: definitely not interrupting */
@@ -574,24 +582,25 @@ EXPORT_SYMBOL(drive_is_ready);
574static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat) 582static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat)
575{ 583{
576 ide_hwif_t *hwif = drive->hwif; 584 ide_hwif_t *hwif = drive->hwif;
585 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
577 unsigned long flags; 586 unsigned long flags;
578 int i; 587 int i;
579 u8 stat; 588 u8 stat;
580 589
581 udelay(1); /* spec allows drive 400ns to assert "BUSY" */ 590 udelay(1); /* spec allows drive 400ns to assert "BUSY" */
582 stat = hwif->read_status(hwif); 591 stat = tp_ops->read_status(hwif);
583 592
584 if (stat & BUSY_STAT) { 593 if (stat & BUSY_STAT) {
585 local_irq_set(flags); 594 local_irq_set(flags);
586 timeout += jiffies; 595 timeout += jiffies;
587 while ((stat = hwif->read_status(hwif)) & BUSY_STAT) { 596 while ((stat = tp_ops->read_status(hwif)) & BUSY_STAT) {
588 if (time_after(jiffies, timeout)) { 597 if (time_after(jiffies, timeout)) {
589 /* 598 /*
590 * One last read after the timeout in case 599 * One last read after the timeout in case
591 * heavy interrupt load made us not make any 600 * heavy interrupt load made us not make any
592 * progress during the timeout.. 601 * progress during the timeout..
593 */ 602 */
594 stat = hwif->read_status(hwif); 603 stat = tp_ops->read_status(hwif);
595 if (!(stat & BUSY_STAT)) 604 if (!(stat & BUSY_STAT))
596 break; 605 break;
597 606
@@ -611,7 +620,7 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
611 */ 620 */
612 for (i = 0; i < 10; i++) { 621 for (i = 0; i < 10; i++) {
613 udelay(1); 622 udelay(1);
614 stat = hwif->read_status(hwif); 623 stat = tp_ops->read_status(hwif);
615 624
616 if (OK_STAT(stat, good, bad)) { 625 if (OK_STAT(stat, good, bad)) {
617 *rstat = stat; 626 *rstat = stat;
@@ -737,6 +746,7 @@ no_80w:
737int ide_driveid_update(ide_drive_t *drive) 746int ide_driveid_update(ide_drive_t *drive)
738{ 747{
739 ide_hwif_t *hwif = drive->hwif; 748 ide_hwif_t *hwif = drive->hwif;
749 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
740 struct hd_driveid *id; 750 struct hd_driveid *id;
741 unsigned long timeout, flags; 751 unsigned long timeout, flags;
742 u8 stat; 752 u8 stat;
@@ -747,9 +757,9 @@ int ide_driveid_update(ide_drive_t *drive)
747 */ 757 */
748 758
749 SELECT_MASK(drive, 1); 759 SELECT_MASK(drive, 1);
750 hwif->set_irq(hwif, 0); 760 tp_ops->set_irq(hwif, 0);
751 msleep(50); 761 msleep(50);
752 hwif->exec_command(hwif, WIN_IDENTIFY); 762 tp_ops->exec_command(hwif, WIN_IDENTIFY);
753 timeout = jiffies + WAIT_WORSTCASE; 763 timeout = jiffies + WAIT_WORSTCASE;
754 do { 764 do {
755 if (time_after(jiffies, timeout)) { 765 if (time_after(jiffies, timeout)) {
@@ -758,11 +768,11 @@ int ide_driveid_update(ide_drive_t *drive)
758 } 768 }
759 769
760 msleep(50); /* give drive a breather */ 770 msleep(50); /* give drive a breather */
761 stat = hwif->read_altstatus(hwif); 771 stat = tp_ops->read_altstatus(hwif);
762 } while (stat & BUSY_STAT); 772 } while (stat & BUSY_STAT);
763 773
764 msleep(50); /* wait for IRQ and DRQ_STAT */ 774 msleep(50); /* wait for IRQ and DRQ_STAT */
765 stat = hwif->read_status(hwif); 775 stat = tp_ops->read_status(hwif);
766 776
767 if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) { 777 if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) {
768 SELECT_MASK(drive, 0); 778 SELECT_MASK(drive, 0);
@@ -776,8 +786,8 @@ int ide_driveid_update(ide_drive_t *drive)
776 local_irq_restore(flags); 786 local_irq_restore(flags);
777 return 0; 787 return 0;
778 } 788 }
779 hwif->input_data(drive, NULL, id, SECTOR_SIZE); 789 tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
780 (void)hwif->read_status(hwif); /* clear drive IRQ */ 790 (void)tp_ops->read_status(hwif); /* clear drive IRQ */
781 local_irq_enable(); 791 local_irq_enable();
782 local_irq_restore(flags); 792 local_irq_restore(flags);
783 ide_fix_driveid(id); 793 ide_fix_driveid(id);
@@ -798,6 +808,7 @@ int ide_driveid_update(ide_drive_t *drive)
798int ide_config_drive_speed(ide_drive_t *drive, u8 speed) 808int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
799{ 809{
800 ide_hwif_t *hwif = drive->hwif; 810 ide_hwif_t *hwif = drive->hwif;
811 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
801 int error = 0; 812 int error = 0;
802 u8 stat; 813 u8 stat;
803 ide_task_t task; 814 ide_task_t task;
@@ -833,19 +844,19 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
833 SELECT_DRIVE(drive); 844 SELECT_DRIVE(drive);
834 SELECT_MASK(drive, 0); 845 SELECT_MASK(drive, 0);
835 udelay(1); 846 udelay(1);
836 hwif->set_irq(hwif, 0); 847 tp_ops->set_irq(hwif, 0);
837 848
838 memset(&task, 0, sizeof(task)); 849 memset(&task, 0, sizeof(task));
839 task.tf_flags = IDE_TFLAG_OUT_FEATURE | IDE_TFLAG_OUT_NSECT; 850 task.tf_flags = IDE_TFLAG_OUT_FEATURE | IDE_TFLAG_OUT_NSECT;
840 task.tf.feature = SETFEATURES_XFER; 851 task.tf.feature = SETFEATURES_XFER;
841 task.tf.nsect = speed; 852 task.tf.nsect = speed;
842 853
843 hwif->tf_load(drive, &task); 854 tp_ops->tf_load(drive, &task);
844 855
845 hwif->exec_command(hwif, WIN_SETFEATURES); 856 tp_ops->exec_command(hwif, WIN_SETFEATURES);
846 857
847 if (drive->quirk_list == 2) 858 if (drive->quirk_list == 2)
848 hwif->set_irq(hwif, 1); 859 tp_ops->set_irq(hwif, 1);
849 860
850 error = __ide_wait_stat(drive, drive->ready_stat, 861 error = __ide_wait_stat(drive, drive->ready_stat,
851 BUSY_STAT|DRQ_STAT|ERR_STAT, 862 BUSY_STAT|DRQ_STAT|ERR_STAT,
@@ -950,7 +961,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
950 961
951 spin_lock_irqsave(&ide_lock, flags); 962 spin_lock_irqsave(&ide_lock, flags);
952 __ide_set_handler(drive, handler, timeout, expiry); 963 __ide_set_handler(drive, handler, timeout, expiry);
953 hwif->exec_command(hwif, cmd); 964 hwif->tp_ops->exec_command(hwif, cmd);
954 /* 965 /*
955 * Drive takes 400nS to respond, we must avoid the IRQ being 966 * Drive takes 400nS to respond, we must avoid the IRQ being
956 * serviced before that. 967 * serviced before that.
@@ -968,7 +979,7 @@ void ide_execute_pkt_cmd(ide_drive_t *drive)
968 unsigned long flags; 979 unsigned long flags;
969 980
970 spin_lock_irqsave(&ide_lock, flags); 981 spin_lock_irqsave(&ide_lock, flags);
971 hwif->exec_command(hwif, WIN_PACKETCMD); 982 hwif->tp_ops->exec_command(hwif, WIN_PACKETCMD);
972 ndelay(400); 983 ndelay(400);
973 spin_unlock_irqrestore(&ide_lock, flags); 984 spin_unlock_irqrestore(&ide_lock, flags);
974} 985}
@@ -999,7 +1010,7 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
999 1010
1000 SELECT_DRIVE(drive); 1011 SELECT_DRIVE(drive);
1001 udelay (10); 1012 udelay (10);
1002 stat = hwif->read_status(hwif); 1013 stat = hwif->tp_ops->read_status(hwif);
1003 1014
1004 if (OK_STAT(stat, 0, BUSY_STAT)) 1015 if (OK_STAT(stat, 0, BUSY_STAT))
1005 printk("%s: ATAPI reset complete\n", drive->name); 1016 printk("%s: ATAPI reset complete\n", drive->name);
@@ -1045,7 +1056,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
1045 } 1056 }
1046 } 1057 }
1047 1058
1048 tmp = hwif->read_status(hwif); 1059 tmp = hwif->tp_ops->read_status(hwif);
1049 1060
1050 if (!OK_STAT(tmp, 0, BUSY_STAT)) { 1061 if (!OK_STAT(tmp, 0, BUSY_STAT)) {
1051 if (time_before(jiffies, hwgroup->poll_timeout)) { 1062 if (time_before(jiffies, hwgroup->poll_timeout)) {
@@ -1159,6 +1170,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1159 ide_hwif_t *hwif; 1170 ide_hwif_t *hwif;
1160 ide_hwgroup_t *hwgroup; 1171 ide_hwgroup_t *hwgroup;
1161 struct ide_io_ports *io_ports; 1172 struct ide_io_ports *io_ports;
1173 const struct ide_tp_ops *tp_ops;
1162 const struct ide_port_ops *port_ops; 1174 const struct ide_port_ops *port_ops;
1163 1175
1164 spin_lock_irqsave(&ide_lock, flags); 1176 spin_lock_irqsave(&ide_lock, flags);
@@ -1167,6 +1179,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1167 1179
1168 io_ports = &hwif->io_ports; 1180 io_ports = &hwif->io_ports;
1169 1181
1182 tp_ops = hwif->tp_ops;
1183
1170 /* We must not reset with running handlers */ 1184 /* We must not reset with running handlers */
1171 BUG_ON(hwgroup->handler != NULL); 1185 BUG_ON(hwgroup->handler != NULL);
1172 1186
@@ -1175,7 +1189,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1175 pre_reset(drive); 1189 pre_reset(drive);
1176 SELECT_DRIVE(drive); 1190 SELECT_DRIVE(drive);
1177 udelay (20); 1191 udelay (20);
1178 hwif->exec_command(hwif, WIN_SRST); 1192 tp_ops->exec_command(hwif, WIN_SRST);
1179 ndelay(400); 1193 ndelay(400);
1180 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1194 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
1181 hwgroup->polling = 1; 1195 hwgroup->polling = 1;
@@ -1208,11 +1222,11 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1208 * TODO: add ->softreset method and stop abusing ->set_irq 1222 * TODO: add ->softreset method and stop abusing ->set_irq
1209 */ 1223 */
1210 /* set SRST and nIEN */ 1224 /* set SRST and nIEN */
1211 hwif->set_irq(hwif, 4); 1225 tp_ops->set_irq(hwif, 4);
1212 /* more than enough time */ 1226 /* more than enough time */
1213 udelay(10); 1227 udelay(10);
1214 /* clear SRST, leave nIEN (unless device is on the quirk list) */ 1228 /* clear SRST, leave nIEN (unless device is on the quirk list) */
1215 hwif->set_irq(hwif, drive->quirk_list == 2); 1229 tp_ops->set_irq(hwif, drive->quirk_list == 2);
1216 /* more than enough time */ 1230 /* more than enough time */
1217 udelay(10); 1231 udelay(10);
1218 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1232 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
@@ -1257,7 +1271,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
1257 * about locking issues (2.5 work ?). 1271 * about locking issues (2.5 work ?).
1258 */ 1272 */
1259 mdelay(1); 1273 mdelay(1);
1260 stat = hwif->read_status(hwif); 1274 stat = hwif->tp_ops->read_status(hwif);
1261 if ((stat & BUSY_STAT) == 0) 1275 if ((stat & BUSY_STAT) == 0)
1262 return 0; 1276 return 0;
1263 /* 1277 /*
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 7ac44d515470..97fefabea8b8 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -325,7 +325,7 @@ static void ide_dump_sector(ide_drive_t *drive)
325 else 325 else
326 task.tf_flags = IDE_TFLAG_IN_LBA | IDE_TFLAG_IN_DEVICE; 326 task.tf_flags = IDE_TFLAG_IN_LBA | IDE_TFLAG_IN_DEVICE;
327 327
328 drive->hwif->tf_read(drive, &task); 328 drive->hwif->tp_ops->tf_read(drive, &task);
329 329
330 if (lba48 || (tf->device & ATA_LBA)) 330 if (lba48 || (tf->device & ATA_LBA))
331 printk(", LBAsect=%llu", 331 printk(", LBAsect=%llu",
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 3cc8ade2cc4f..c588066295db 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -126,7 +126,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
126 126
127 id = drive->id; 127 id = drive->id;
128 /* read 512 bytes of id info */ 128 /* read 512 bytes of id info */
129 hwif->input_data(drive, NULL, id, SECTOR_SIZE); 129 hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
130 130
131 drive->id_read = 1; 131 drive->id_read = 1;
132 local_irq_enable(); 132 local_irq_enable();
@@ -267,6 +267,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
267{ 267{
268 ide_hwif_t *hwif = HWIF(drive); 268 ide_hwif_t *hwif = HWIF(drive);
269 struct ide_io_ports *io_ports = &hwif->io_ports; 269 struct ide_io_ports *io_ports = &hwif->io_ports;
270 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
270 int use_altstatus = 0, rc; 271 int use_altstatus = 0, rc;
271 unsigned long timeout; 272 unsigned long timeout;
272 u8 s = 0, a = 0; 273 u8 s = 0, a = 0;
@@ -275,8 +276,8 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
275 msleep(50); 276 msleep(50);
276 277
277 if (io_ports->ctl_addr) { 278 if (io_ports->ctl_addr) {
278 a = hwif->read_altstatus(hwif); 279 a = tp_ops->read_altstatus(hwif);
279 s = hwif->read_status(hwif); 280 s = tp_ops->read_status(hwif);
280 if ((a ^ s) & ~INDEX_STAT) 281 if ((a ^ s) & ~INDEX_STAT)
281 /* ancient Seagate drives, broken interfaces */ 282 /* ancient Seagate drives, broken interfaces */
282 printk(KERN_INFO "%s: probing with STATUS(0x%02x) " 283 printk(KERN_INFO "%s: probing with STATUS(0x%02x) "
@@ -297,11 +298,11 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
297 /* disable DMA & overlap */ 298 /* disable DMA & overlap */
298 task.tf_flags = IDE_TFLAG_OUT_FEATURE; 299 task.tf_flags = IDE_TFLAG_OUT_FEATURE;
299 300
300 drive->hwif->tf_load(drive, &task); 301 tp_ops->tf_load(drive, &task);
301 } 302 }
302 303
303 /* ask drive for ID */ 304 /* ask drive for ID */
304 hwif->exec_command(hwif, cmd); 305 tp_ops->exec_command(hwif, cmd);
305 306
306 timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; 307 timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
307 timeout += jiffies; 308 timeout += jiffies;
@@ -312,13 +313,13 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
312 } 313 }
313 /* give drive a breather */ 314 /* give drive a breather */
314 msleep(50); 315 msleep(50);
315 s = use_altstatus ? hwif->read_altstatus(hwif) 316 s = use_altstatus ? tp_ops->read_altstatus(hwif)
316 : hwif->read_status(hwif); 317 : tp_ops->read_status(hwif);
317 } while (s & BUSY_STAT); 318 } while (s & BUSY_STAT);
318 319
319 /* wait for IRQ and DRQ_STAT */ 320 /* wait for IRQ and DRQ_STAT */
320 msleep(50); 321 msleep(50);
321 s = hwif->read_status(hwif); 322 s = tp_ops->read_status(hwif);
322 323
323 if (OK_STAT(s, DRQ_STAT, BAD_R_STAT)) { 324 if (OK_STAT(s, DRQ_STAT, BAD_R_STAT)) {
324 unsigned long flags; 325 unsigned long flags;
@@ -330,7 +331,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
330 /* drive responded with ID */ 331 /* drive responded with ID */
331 rc = 0; 332 rc = 0;
332 /* clear drive IRQ */ 333 /* clear drive IRQ */
333 (void)hwif->read_status(hwif); 334 (void)tp_ops->read_status(hwif);
334 local_irq_restore(flags); 335 local_irq_restore(flags);
335 } else { 336 } else {
336 /* drive refused ID */ 337 /* drive refused ID */
@@ -352,6 +353,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
352static int try_to_identify (ide_drive_t *drive, u8 cmd) 353static int try_to_identify (ide_drive_t *drive, u8 cmd)
353{ 354{
354 ide_hwif_t *hwif = HWIF(drive); 355 ide_hwif_t *hwif = HWIF(drive);
356 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
355 int retval; 357 int retval;
356 int autoprobe = 0; 358 int autoprobe = 0;
357 unsigned long cookie = 0; 359 unsigned long cookie = 0;
@@ -367,7 +369,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd)
367 autoprobe = 1; 369 autoprobe = 1;
368 cookie = probe_irq_on(); 370 cookie = probe_irq_on();
369 } 371 }
370 hwif->set_irq(hwif, autoprobe); 372 tp_ops->set_irq(hwif, autoprobe);
371 } 373 }
372 374
373 retval = actual_try_to_identify(drive, cmd); 375 retval = actual_try_to_identify(drive, cmd);
@@ -375,9 +377,9 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd)
375 if (autoprobe) { 377 if (autoprobe) {
376 int irq; 378 int irq;
377 379
378 hwif->set_irq(hwif, 0); 380 tp_ops->set_irq(hwif, 0);
379 /* clear drive IRQ */ 381 /* clear drive IRQ */
380 (void)hwif->read_status(hwif); 382 (void)tp_ops->read_status(hwif);
381 udelay(5); 383 udelay(5);
382 irq = probe_irq_off(cookie); 384 irq = probe_irq_off(cookie);
383 if (!hwif->irq) { 385 if (!hwif->irq) {
@@ -402,7 +404,7 @@ static int ide_busy_sleep(ide_hwif_t *hwif)
402 404
403 do { 405 do {
404 msleep(50); 406 msleep(50);
405 stat = hwif->read_status(hwif); 407 stat = hwif->tp_ops->read_status(hwif);
406 if ((stat & BUSY_STAT) == 0) 408 if ((stat & BUSY_STAT) == 0)
407 return 0; 409 return 0;
408 } while (time_before(jiffies, timeout)); 410 } while (time_before(jiffies, timeout));
@@ -417,7 +419,7 @@ static u8 ide_read_device(ide_drive_t *drive)
417 memset(&task, 0, sizeof(task)); 419 memset(&task, 0, sizeof(task));
418 task.tf_flags = IDE_TFLAG_IN_DEVICE; 420 task.tf_flags = IDE_TFLAG_IN_DEVICE;
419 421
420 drive->hwif->tf_read(drive, &task); 422 drive->hwif->tp_ops->tf_read(drive, &task);
421 423
422 return task.tf.device; 424 return task.tf.device;
423} 425}
@@ -446,6 +448,7 @@ static u8 ide_read_device(ide_drive_t *drive)
446static int do_probe (ide_drive_t *drive, u8 cmd) 448static int do_probe (ide_drive_t *drive, u8 cmd)
447{ 449{
448 ide_hwif_t *hwif = HWIF(drive); 450 ide_hwif_t *hwif = HWIF(drive);
451 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
449 int rc; 452 int rc;
450 u8 stat; 453 u8 stat;
451 454
@@ -478,7 +481,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
478 return 3; 481 return 3;
479 } 482 }
480 483
481 stat = hwif->read_status(hwif); 484 stat = tp_ops->read_status(hwif);
482 485
483 if (OK_STAT(stat, READY_STAT, BUSY_STAT) || 486 if (OK_STAT(stat, READY_STAT, BUSY_STAT) ||
484 drive->present || cmd == WIN_PIDENTIFY) { 487 drive->present || cmd == WIN_PIDENTIFY) {
@@ -488,7 +491,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
488 rc = try_to_identify(drive,cmd); 491 rc = try_to_identify(drive,cmd);
489 } 492 }
490 493
491 stat = hwif->read_status(hwif); 494 stat = tp_ops->read_status(hwif);
492 495
493 if (stat == (BUSY_STAT | READY_STAT)) 496 if (stat == (BUSY_STAT | READY_STAT))
494 return 4; 497 return 4;
@@ -499,13 +502,13 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
499 msleep(50); 502 msleep(50);
500 SELECT_DRIVE(drive); 503 SELECT_DRIVE(drive);
501 msleep(50); 504 msleep(50);
502 hwif->exec_command(hwif, WIN_SRST); 505 tp_ops->exec_command(hwif, WIN_SRST);
503 (void)ide_busy_sleep(hwif); 506 (void)ide_busy_sleep(hwif);
504 rc = try_to_identify(drive, cmd); 507 rc = try_to_identify(drive, cmd);
505 } 508 }
506 509
507 /* ensure drive IRQ is clear */ 510 /* ensure drive IRQ is clear */
508 stat = hwif->read_status(hwif); 511 stat = tp_ops->read_status(hwif);
509 512
510 if (rc == 1) 513 if (rc == 1)
511 printk(KERN_ERR "%s: no response (status = 0x%02x)\n", 514 printk(KERN_ERR "%s: no response (status = 0x%02x)\n",
@@ -519,7 +522,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
519 SELECT_DRIVE(&hwif->drives[0]); 522 SELECT_DRIVE(&hwif->drives[0]);
520 msleep(50); 523 msleep(50);
521 /* ensure drive irq is clear */ 524 /* ensure drive irq is clear */
522 (void)hwif->read_status(hwif); 525 (void)tp_ops->read_status(hwif);
523 } 526 }
524 return rc; 527 return rc;
525} 528}
@@ -530,12 +533,13 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
530static void enable_nest (ide_drive_t *drive) 533static void enable_nest (ide_drive_t *drive)
531{ 534{
532 ide_hwif_t *hwif = HWIF(drive); 535 ide_hwif_t *hwif = HWIF(drive);
536 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
533 u8 stat; 537 u8 stat;
534 538
535 printk("%s: enabling %s -- ", hwif->name, drive->id->model); 539 printk("%s: enabling %s -- ", hwif->name, drive->id->model);
536 SELECT_DRIVE(drive); 540 SELECT_DRIVE(drive);
537 msleep(50); 541 msleep(50);
538 hwif->exec_command(hwif, EXABYTE_ENABLE_NEST); 542 tp_ops->exec_command(hwif, EXABYTE_ENABLE_NEST);
539 543
540 if (ide_busy_sleep(hwif)) { 544 if (ide_busy_sleep(hwif)) {
541 printk(KERN_CONT "failed (timeout)\n"); 545 printk(KERN_CONT "failed (timeout)\n");
@@ -544,7 +548,7 @@ static void enable_nest (ide_drive_t *drive)
544 548
545 msleep(50); 549 msleep(50);
546 550
547 stat = hwif->read_status(hwif); 551 stat = tp_ops->read_status(hwif);
548 552
549 if (!OK_STAT(stat, 0, BAD_STAT)) 553 if (!OK_STAT(stat, 0, BAD_STAT))
550 printk(KERN_CONT "failed (status = 0x%02x)\n", stat); 554 printk(KERN_CONT "failed (status = 0x%02x)\n", stat);
@@ -726,7 +730,7 @@ static int ide_port_wait_ready(ide_hwif_t *hwif)
726 /* Ignore disks that we will not probe for later. */ 730 /* Ignore disks that we will not probe for later. */
727 if (!drive->noprobe || drive->present) { 731 if (!drive->noprobe || drive->present) {
728 SELECT_DRIVE(drive); 732 SELECT_DRIVE(drive);
729 hwif->set_irq(hwif, 1); 733 hwif->tp_ops->set_irq(hwif, 1);
730 mdelay(2); 734 mdelay(2);
731 rc = ide_wait_not_busy(hwif, 35000); 735 rc = ide_wait_not_busy(hwif, 35000);
732 if (rc) 736 if (rc)
@@ -1083,7 +1087,7 @@ static int init_irq (ide_hwif_t *hwif)
1083 sa = IRQF_SHARED; 1087 sa = IRQF_SHARED;
1084 1088
1085 if (io_ports->ctl_addr) 1089 if (io_ports->ctl_addr)
1086 hwif->set_irq(hwif, 1); 1090 hwif->tp_ops->set_irq(hwif, 1);
1087 1091
1088 if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) 1092 if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup))
1089 goto out_unlink; 1093 goto out_unlink;
@@ -1361,6 +1365,9 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
1361 hwif->host_flags |= d->host_flags; 1365 hwif->host_flags |= d->host_flags;
1362 hwif->pio_mask = d->pio_mask; 1366 hwif->pio_mask = d->pio_mask;
1363 1367
1368 if (d->tp_ops)
1369 hwif->tp_ops = d->tp_ops;
1370
1364 /* ->set_pio_mode for DTC2278 is currently limited to port 0 */ 1371 /* ->set_pio_mode for DTC2278 is currently limited to port 0 */
1365 if (hwif->chipset != ide_dtc2278 || hwif->channel == 0) 1372 if (hwif->chipset != ide_dtc2278 || hwif->channel == 0)
1366 hwif->port_ops = d->port_ops; 1373 hwif->port_ops = d->port_ops;
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index ef54728a74b0..0af128826f1e 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -398,7 +398,7 @@ static void idetape_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
398 count = min( 398 count = min(
399 (unsigned int)(bh->b_size - atomic_read(&bh->b_count)), 399 (unsigned int)(bh->b_size - atomic_read(&bh->b_count)),
400 bcount); 400 bcount);
401 drive->hwif->input_data(drive, NULL, bh->b_data + 401 drive->hwif->tp_ops->input_data(drive, NULL, bh->b_data +
402 atomic_read(&bh->b_count), count); 402 atomic_read(&bh->b_count), count);
403 bcount -= count; 403 bcount -= count;
404 atomic_add(count, &bh->b_count); 404 atomic_add(count, &bh->b_count);
@@ -424,7 +424,7 @@ static void idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
424 return; 424 return;
425 } 425 }
426 count = min((unsigned int)pc->b_count, (unsigned int)bcount); 426 count = min((unsigned int)pc->b_count, (unsigned int)bcount);
427 drive->hwif->output_data(drive, NULL, pc->b_data, count); 427 drive->hwif->tp_ops->output_data(drive, NULL, pc->b_data, count);
428 bcount -= count; 428 bcount -= count;
429 pc->b_data += count; 429 pc->b_data += count;
430 pc->b_count -= count; 430 pc->b_count -= count;
@@ -932,7 +932,7 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive)
932 struct ide_atapi_pc *pc = tape->pc; 932 struct ide_atapi_pc *pc = tape->pc;
933 u8 stat; 933 u8 stat;
934 934
935 stat = hwif->read_status(hwif); 935 stat = hwif->tp_ops->read_status(hwif);
936 936
937 if (stat & SEEK_STAT) { 937 if (stat & SEEK_STAT) {
938 if (stat & ERR_STAT) { 938 if (stat & ERR_STAT) {
@@ -1019,7 +1019,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
1019 * If the tape is still busy, postpone our request and service 1019 * If the tape is still busy, postpone our request and service
1020 * the other device meanwhile. 1020 * the other device meanwhile.
1021 */ 1021 */
1022 stat = hwif->read_status(hwif); 1022 stat = hwif->tp_ops->read_status(hwif);
1023 1023
1024 if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2)) 1024 if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2))
1025 set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); 1025 set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags);
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index ea345369553e..aeddbbd69e86 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -64,6 +64,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
64 ide_hwif_t *hwif = HWIF(drive); 64 ide_hwif_t *hwif = HWIF(drive);
65 struct ide_taskfile *tf = &task->tf; 65 struct ide_taskfile *tf = &task->tf;
66 ide_handler_t *handler = NULL; 66 ide_handler_t *handler = NULL;
67 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
67 const struct ide_dma_ops *dma_ops = hwif->dma_ops; 68 const struct ide_dma_ops *dma_ops = hwif->dma_ops;
68 69
69 if (task->data_phase == TASKFILE_MULTI_IN || 70 if (task->data_phase == TASKFILE_MULTI_IN ||
@@ -80,15 +81,15 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
80 81
81 if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { 82 if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) {
82 ide_tf_dump(drive->name, tf); 83 ide_tf_dump(drive->name, tf);
83 hwif->set_irq(hwif, 1); 84 tp_ops->set_irq(hwif, 1);
84 SELECT_MASK(drive, 0); 85 SELECT_MASK(drive, 0);
85 hwif->tf_load(drive, task); 86 tp_ops->tf_load(drive, task);
86 } 87 }
87 88
88 switch (task->data_phase) { 89 switch (task->data_phase) {
89 case TASKFILE_MULTI_OUT: 90 case TASKFILE_MULTI_OUT:
90 case TASKFILE_OUT: 91 case TASKFILE_OUT:
91 hwif->exec_command(hwif, tf->command); 92 tp_ops->exec_command(hwif, tf->command);
92 ndelay(400); /* FIXME */ 93 ndelay(400); /* FIXME */
93 return pre_task_out_intr(drive, task->rq); 94 return pre_task_out_intr(drive, task->rq);
94 case TASKFILE_MULTI_IN: 95 case TASKFILE_MULTI_IN:
@@ -125,7 +126,7 @@ EXPORT_SYMBOL_GPL(do_rw_taskfile);
125static ide_startstop_t set_multmode_intr(ide_drive_t *drive) 126static ide_startstop_t set_multmode_intr(ide_drive_t *drive)
126{ 127{
127 ide_hwif_t *hwif = drive->hwif; 128 ide_hwif_t *hwif = drive->hwif;
128 u8 stat = hwif->read_status(hwif); 129 u8 stat = hwif->tp_ops->read_status(hwif);
129 130
130 if (OK_STAT(stat, READY_STAT, BAD_STAT)) 131 if (OK_STAT(stat, READY_STAT, BAD_STAT))
131 drive->mult_count = drive->mult_req; 132 drive->mult_count = drive->mult_req;
@@ -146,8 +147,12 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive)
146 int retries = 5; 147 int retries = 5;
147 u8 stat; 148 u8 stat;
148 149
149 while (((stat = hwif->read_status(hwif)) & BUSY_STAT) && retries--) 150 while (1) {
151 stat = hwif->tp_ops->read_status(hwif);
152 if ((stat & BUSY_STAT) == 0 || retries-- == 0)
153 break;
150 udelay(10); 154 udelay(10);
155 };
151 156
152 if (OK_STAT(stat, READY_STAT, BAD_STAT)) 157 if (OK_STAT(stat, READY_STAT, BAD_STAT))
153 return ide_stopped; 158 return ide_stopped;
@@ -165,7 +170,7 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive)
165static ide_startstop_t recal_intr(ide_drive_t *drive) 170static ide_startstop_t recal_intr(ide_drive_t *drive)
166{ 171{
167 ide_hwif_t *hwif = drive->hwif; 172 ide_hwif_t *hwif = drive->hwif;
168 u8 stat = hwif->read_status(hwif); 173 u8 stat = hwif->tp_ops->read_status(hwif);
169 174
170 if (!OK_STAT(stat, READY_STAT, BAD_STAT)) 175 if (!OK_STAT(stat, READY_STAT, BAD_STAT))
171 return ide_error(drive, "recal_intr", stat); 176 return ide_error(drive, "recal_intr", stat);
@@ -182,7 +187,7 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive)
182 u8 stat; 187 u8 stat;
183 188
184 local_irq_enable_in_hardirq(); 189 local_irq_enable_in_hardirq();
185 stat = hwif->read_status(hwif); 190 stat = hwif->tp_ops->read_status(hwif);
186 191
187 if (!OK_STAT(stat, READY_STAT, BAD_STAT)) 192 if (!OK_STAT(stat, READY_STAT, BAD_STAT))
188 return ide_error(drive, "task_no_data_intr", stat); 193 return ide_error(drive, "task_no_data_intr", stat);
@@ -205,7 +210,7 @@ static u8 wait_drive_not_busy(ide_drive_t *drive)
205 * take up to 6 ms on some ATAPI devices, so we will wait max 10 ms. 210 * take up to 6 ms on some ATAPI devices, so we will wait max 10 ms.
206 */ 211 */
207 for (retries = 0; retries < 1000; retries++) { 212 for (retries = 0; retries < 1000; retries++) {
208 stat = hwif->read_status(hwif); 213 stat = hwif->tp_ops->read_status(hwif);
209 214
210 if (stat & BUSY_STAT) 215 if (stat & BUSY_STAT)
211 udelay(10); 216 udelay(10);
@@ -260,9 +265,9 @@ static void ide_pio_sector(ide_drive_t *drive, struct request *rq,
260 265
261 /* do the actual data transfer */ 266 /* do the actual data transfer */
262 if (write) 267 if (write)
263 hwif->output_data(drive, rq, buf, SECTOR_SIZE); 268 hwif->tp_ops->output_data(drive, rq, buf, SECTOR_SIZE);
264 else 269 else
265 hwif->input_data(drive, rq, buf, SECTOR_SIZE); 270 hwif->tp_ops->input_data(drive, rq, buf, SECTOR_SIZE);
266 271
267 kunmap_atomic(buf, KM_BIO_SRC_IRQ); 272 kunmap_atomic(buf, KM_BIO_SRC_IRQ);
268#ifdef CONFIG_HIGHMEM 273#ifdef CONFIG_HIGHMEM
@@ -389,7 +394,7 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive)
389{ 394{
390 ide_hwif_t *hwif = drive->hwif; 395 ide_hwif_t *hwif = drive->hwif;
391 struct request *rq = hwif->hwgroup->rq; 396 struct request *rq = hwif->hwgroup->rq;
392 u8 stat = hwif->read_status(hwif); 397 u8 stat = hwif->tp_ops->read_status(hwif);
393 398
394 /* Error? */ 399 /* Error? */
395 if (stat & ERR_STAT) 400 if (stat & ERR_STAT)
@@ -423,7 +428,7 @@ static ide_startstop_t task_out_intr (ide_drive_t *drive)
423{ 428{
424 ide_hwif_t *hwif = drive->hwif; 429 ide_hwif_t *hwif = drive->hwif;
425 struct request *rq = HWGROUP(drive)->rq; 430 struct request *rq = HWGROUP(drive)->rq;
426 u8 stat = hwif->read_status(hwif); 431 u8 stat = hwif->tp_ops->read_status(hwif);
427 432
428 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) 433 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat))
429 return task_error(drive, rq, __func__, stat); 434 return task_error(drive, rq, __func__, stat);
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 961f31c648c9..132b504168e9 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -101,7 +101,7 @@ void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
101 101
102 init_completion(&hwif->gendev_rel_comp); 102 init_completion(&hwif->gendev_rel_comp);
103 103
104 default_hwif_transport(hwif); 104 hwif->tp_ops = &default_tp_ops;
105 105
106 ide_port_init_devices_data(hwif); 106 ide_port_init_devices_data(hwif);
107} 107}
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c
index 1bb2aa72cc7f..3e2c6125f031 100644
--- a/drivers/ide/legacy/falconide.c
+++ b/drivers/ide/legacy/falconide.c
@@ -66,6 +66,27 @@ static void falconide_output_data(ide_drive_t *drive, struct request *rq,
66 outsw_swapw(data_addr, buf, (len + 1) / 2); 66 outsw_swapw(data_addr, buf, (len + 1) / 2);
67} 67}
68 68
69/* Atari has a byte-swapped IDE interface */
70static const struct ide_tp_ops falconide_tp_ops = {
71 .exec_command = ide_exec_command,
72 .read_status = ide_read_status,
73 .read_altstatus = ide_read_altstatus,
74 .read_sff_dma_status = ide_read_sff_dma_status,
75
76 .set_irq = ide_set_irq,
77
78 .tf_load = ide_tf_load,
79 .tf_read = ide_tf_read,
80
81 .input_data = falconide_input_data,
82 .output_data = falconide_output_data,
83};
84
85static const struct ide_port_info falconide_port_info = {
86 .tp_ops = &falconide_tp_ops,
87 .host_flags = IDE_HFLAG_NO_DMA,
88};
89
69static void __init falconide_setup_ports(hw_regs_t *hw) 90static void __init falconide_setup_ports(hw_regs_t *hw)
70{ 91{
71 int i; 92 int i;
@@ -111,12 +132,8 @@ static int __init falconide_init(void)
111 u8 index = hwif->index; 132 u8 index = hwif->index;
112 u8 idx[4] = { index, 0xff, 0xff, 0xff }; 133 u8 idx[4] = { index, 0xff, 0xff, 0xff };
113 134
114 /* Atari has a byte-swapped IDE interface */
115 hwif->input_data = falconide_input_data;
116 hwif->output_data = falconide_output_data;
117
118 ide_get_lock(NULL, NULL); 135 ide_get_lock(NULL, NULL);
119 ide_device_add(idx, NULL, hws); 136 ide_device_add(idx, &falconide_port_info, hws);
120 ide_release_lock(); 137 ide_release_lock();
121 } 138 }
122 139
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c
index fcb04b8b0238..2dc306f852a6 100644
--- a/drivers/ide/legacy/q40ide.c
+++ b/drivers/ide/legacy/q40ide.c
@@ -96,6 +96,27 @@ static void q40ide_output_data(ide_drive_t *drive, struct request *rq,
96 outsw_swapw(data_addr, buf, (len + 1) / 2); 96 outsw_swapw(data_addr, buf, (len + 1) / 2);
97} 97}
98 98
99/* Q40 has a byte-swapped IDE interface */
100static const struct ide_tp_ops q40ide_tp_ops = {
101 .exec_command = ide_exec_command,
102 .read_status = ide_read_status,
103 .read_altstatus = ide_read_altstatus,
104 .read_sff_dma_status = ide_read_sff_dma_status,
105
106 .set_irq = ide_set_irq,
107
108 .tf_load = ide_tf_load,
109 .tf_read = ide_tf_read,
110
111 .input_data = q40ide_input_data,
112 .output_data = q40ide_output_data,
113};
114
115static const struct ide_port_info q40ide_port_info = {
116 .tp_ops = &q40ide_tp_ops,
117 .host_flags = IDE_HFLAG_NO_DMA,
118};
119
99/* 120/*
100 * the static array is needed to have the name reported in /proc/ioports, 121 * the static array is needed to have the name reported in /proc/ioports,
101 * hwif->name unfortunately isn't available yet 122 * hwif->name unfortunately isn't available yet
@@ -141,16 +162,12 @@ static int __init q40ide_init(void)
141 if (hwif) { 162 if (hwif) {
142 hwif->chipset = ide_generic; 163 hwif->chipset = ide_generic;
143 164
144 /* Q40 has a byte-swapped IDE interface */
145 hwif->input_data = q40ide_input_data;
146 hwif->output_data = q40ide_output_data;
147
148 hws[i] = &hw[i]; 165 hws[i] = &hw[i];
149 idx[i] = hwif->index; 166 idx[i] = hwif->index;
150 } 167 }
151 } 168 }
152 169
153 ide_device_add(idx, NULL, hws); 170 ide_device_add(idx, &q40ide_port_info, hws);
154 171
155 return 0; 172 return 0;
156} 173}
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c
index 475da582fd89..ed1c9a134079 100644
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -519,6 +519,23 @@ static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif)
519 *ata_regs = ahwif->regbase + (14 << IDE_REG_SHIFT); 519 *ata_regs = ahwif->regbase + (14 << IDE_REG_SHIFT);
520} 520}
521 521
522#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
523static const struct ide_tp_ops au1xxx_tp_ops = {
524 .exec_command = ide_exec_command,
525 .read_status = ide_read_status,
526 .read_altstatus = ide_read_altstatus,
527 .read_sff_dma_status = ide_read_sff_dma_status,
528
529 .set_irq = ide_set_irq,
530
531 .tf_load = ide_tf_load,
532 .tf_read = ide_tf_read,
533
534 .input_data = au1xxx_input_data,
535 .output_data = au1xxx_output_data,
536};
537#endif
538
522static const struct ide_port_ops au1xxx_port_ops = { 539static const struct ide_port_ops au1xxx_port_ops = {
523 .set_pio_mode = au1xxx_set_pio_mode, 540 .set_pio_mode = au1xxx_set_pio_mode,
524 .set_dma_mode = auide_set_dma_mode, 541 .set_dma_mode = auide_set_dma_mode,
@@ -526,6 +543,9 @@ static const struct ide_port_ops au1xxx_port_ops = {
526 543
527static const struct ide_port_info au1xxx_port_info = { 544static const struct ide_port_info au1xxx_port_info = {
528 .init_dma = auide_ddma_init, 545 .init_dma = auide_ddma_init,
546#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
547 .tp_ops = &au1xxx_tp_ops,
548#endif
529 .port_ops = &au1xxx_port_ops, 549 .port_ops = &au1xxx_port_ops,
530#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 550#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
531 .dma_ops = &au1xxx_dma_ops, 551 .dma_ops = &au1xxx_dma_ops,
@@ -596,15 +616,6 @@ static int au_ide_probe(struct device *dev)
596 hw.dev = dev; 616 hw.dev = dev;
597 hw.chipset = ide_au1xxx; 617 hw.chipset = ide_au1xxx;
598 618
599 /* If the user has selected DDMA assisted copies,
600 then set up a few local I/O function entry points
601 */
602
603#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
604 hwif->input_data = au1xxx_input_data;
605 hwif->output_data = au1xxx_output_data;
606#endif
607
608 auide_hwif.hwif = hwif; 619 auide_hwif.hwif = hwif;
609 620
610 idx[0] = hwif->index; 621 idx[0] = hwif->index;
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index 02fd3a877afa..5cd2b32ff0ef 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -104,7 +104,22 @@ static void superio_tf_read(ide_drive_t *drive, ide_task_t *task)
104 } 104 }
105} 105}
106 106
107static void __devinit superio_ide_init_iops (struct hwif_s *hwif) 107static const struct ide_tp_ops superio_tp_ops = {
108 .exec_command = ide_exec_command,
109 .read_status = superio_read_status,
110 .read_altstatus = ide_read_altstatus,
111 .read_sff_dma_status = superio_read_sff_dma_status,
112
113 .set_irq = ide_set_irq,
114
115 .tf_load = ide_tf_load,
116 .tf_read = superio_tf_read,
117
118 .input_data = ide_input_data,
119 .output_data = ide_output_data,
120};
121
122static void __devinit superio_init_iops(struct hwif_s *hwif)
108{ 123{
109 struct pci_dev *pdev = to_pci_dev(hwif->dev); 124 struct pci_dev *pdev = to_pci_dev(hwif->dev);
110 u32 dma_stat; 125 u32 dma_stat;
@@ -115,21 +130,6 @@ static void __devinit superio_ide_init_iops (struct hwif_s *hwif)
115 /* Clear error/interrupt, enable dma */ 130 /* Clear error/interrupt, enable dma */
116 tmp = superio_ide_inb(dma_stat); 131 tmp = superio_ide_inb(dma_stat);
117 outb(tmp | 0x66, dma_stat); 132 outb(tmp | 0x66, dma_stat);
118
119 hwif->read_status = superio_read_status;
120 hwif->read_sff_dma_status = superio_read_sff_dma_status;
121
122 hwif->tf_read = superio_tf_read;
123
124}
125
126static void __devinit init_iops_ns87415(ide_hwif_t *hwif)
127{
128 struct pci_dev *dev = to_pci_dev(hwif->dev);
129
130 if (PCI_SLOT(dev->devfn) == 0xE)
131 /* Built-in - assume it's under superio. */
132 superio_ide_init_iops(hwif);
133} 133}
134#endif 134#endif
135 135
@@ -195,7 +195,7 @@ static int ns87415_dma_end(ide_drive_t *drive)
195 u8 dma_stat = 0, dma_cmd = 0; 195 u8 dma_stat = 0, dma_cmd = 0;
196 196
197 drive->waiting_for_dma = 0; 197 drive->waiting_for_dma = 0;
198 dma_stat = hwif->read_sff_dma_status(hwif); 198 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
199 /* get DMA command mode */ 199 /* get DMA command mode */
200 dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); 200 dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD);
201 /* stop DMA */ 201 /* stop DMA */
@@ -271,7 +271,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
271 outb(8, hwif->io_ports.ctl_addr); 271 outb(8, hwif->io_ports.ctl_addr);
272 do { 272 do {
273 udelay(50); 273 udelay(50);
274 stat = hwif->read_status(hwif); 274 stat = hwif->tp_ops->read_status(hwif);
275 if (stat == 0xff) 275 if (stat == 0xff)
276 break; 276 break;
277 } while ((stat & BUSY_STAT) && --timeout); 277 } while ((stat & BUSY_STAT) && --timeout);
@@ -306,9 +306,6 @@ static const struct ide_dma_ops ns87415_dma_ops = {
306 306
307static const struct ide_port_info ns87415_chipset __devinitdata = { 307static const struct ide_port_info ns87415_chipset __devinitdata = {
308 .name = "NS87415", 308 .name = "NS87415",
309#ifdef CONFIG_SUPERIO
310 .init_iops = init_iops_ns87415,
311#endif
312 .init_hwif = init_hwif_ns87415, 309 .init_hwif = init_hwif_ns87415,
313 .port_ops = &ns87415_port_ops, 310 .port_ops = &ns87415_port_ops,
314 .dma_ops = &ns87415_dma_ops, 311 .dma_ops = &ns87415_dma_ops,
@@ -318,7 +315,16 @@ static const struct ide_port_info ns87415_chipset __devinitdata = {
318 315
319static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id) 316static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id)
320{ 317{
321 return ide_setup_pci_device(dev, &ns87415_chipset); 318 struct ide_port_info d = ns87415_chipset;
319
320#ifdef CONFIG_SUPERIO
321 if (PCI_SLOT(dev->devfn) == 0xE) {
322 /* Built-in - assume it's under superio. */
323 d.init_iops = superio_init_iops;
324 d.tp_ops = &superio_tp_ops;
325 }
326#endif
327 return ide_setup_pci_device(dev, &d);
322} 328}
323 329
324static const struct pci_device_id ns87415_pci_tbl[] = { 330static const struct pci_device_id ns87415_pci_tbl[] = {
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 38765d9b0314..5b1a0e950dfd 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -808,19 +808,6 @@ static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif)
808 808
809 ide_set_hwifdata(hwif, ports); 809 ide_set_hwifdata(hwif, ports);
810 810
811 hwif->exec_command = scc_exec_command;
812 hwif->read_status = scc_read_status;
813 hwif->read_altstatus = scc_read_altstatus;
814 hwif->read_sff_dma_status = scc_read_sff_dma_status;
815
816 hwif->set_irq = scc_set_irq;
817
818 hwif->tf_load = scc_tf_load;
819 hwif->tf_read = scc_tf_read;
820
821 hwif->input_data = scc_input_data;
822 hwif->output_data = scc_output_data;
823
824 hwif->dma_base = dma_base; 811 hwif->dma_base = dma_base;
825 hwif->config_data = ports->ctl; 812 hwif->config_data = ports->ctl;
826} 813}
@@ -872,6 +859,21 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif)
872 hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ 859 hwif->ultra_mask = ATA_UDMA5; /* 100MHz */
873} 860}
874 861
862static const struct ide_tp_ops scc_tp_ops = {
863 .exec_command = scc_exec_command,
864 .read_status = scc_read_status,
865 .read_altstatus = scc_read_altstatus,
866 .read_sff_dma_status = scc_read_sff_dma_status,
867
868 .set_irq = scc_set_irq,
869
870 .tf_load = scc_tf_load,
871 .tf_read = scc_tf_read,
872
873 .input_data = scc_input_data,
874 .output_data = scc_output_data,
875};
876
875static const struct ide_port_ops scc_port_ops = { 877static const struct ide_port_ops scc_port_ops = {
876 .set_pio_mode = scc_set_pio_mode, 878 .set_pio_mode = scc_set_pio_mode,
877 .set_dma_mode = scc_set_dma_mode, 879 .set_dma_mode = scc_set_dma_mode,
@@ -895,6 +897,7 @@ static const struct ide_dma_ops scc_dma_ops = {
895 .name = name_str, \ 897 .name = name_str, \
896 .init_iops = init_iops_scc, \ 898 .init_iops = init_iops_scc, \
897 .init_hwif = init_hwif_scc, \ 899 .init_hwif = init_hwif_scc, \
900 .tp_ops = &scc_tp_ops, \
898 .port_ops = &scc_port_ops, \ 901 .port_ops = &scc_port_ops, \
899 .dma_ops = &scc_dma_ops, \ 902 .dma_ops = &scc_dma_ops, \
900 .host_flags = IDE_HFLAG_SINGLE, \ 903 .host_flags = IDE_HFLAG_SINGLE, \
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 86f7c4901837..5598bd5936d9 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -550,6 +550,21 @@ static int sgiioc4_dma_setup(ide_drive_t *drive)
550 return 0; 550 return 0;
551} 551}
552 552
553static const struct ide_tp_ops sgiioc4_tp_ops = {
554 .exec_command = ide_exec_command,
555 .read_status = sgiioc4_read_status,
556 .read_altstatus = ide_read_altstatus,
557 .read_sff_dma_status = ide_read_sff_dma_status,
558
559 .set_irq = ide_set_irq,
560
561 .tf_load = ide_tf_load,
562 .tf_read = ide_tf_read,
563
564 .input_data = ide_input_data,
565 .output_data = ide_output_data,
566};
567
553static const struct ide_port_ops sgiioc4_port_ops = { 568static const struct ide_port_ops sgiioc4_port_ops = {
554 .set_dma_mode = sgiioc4_set_dma_mode, 569 .set_dma_mode = sgiioc4_set_dma_mode,
555 /* reset DMA engine, clear IRQs */ 570 /* reset DMA engine, clear IRQs */
@@ -572,6 +587,7 @@ static const struct ide_port_info sgiioc4_port_info __devinitdata = {
572 .name = DRV_NAME, 587 .name = DRV_NAME,
573 .chipset = ide_pci, 588 .chipset = ide_pci,
574 .init_dma = ide_dma_sgiioc4, 589 .init_dma = ide_dma_sgiioc4,
590 .tp_ops = &sgiioc4_tp_ops,
575 .port_ops = &sgiioc4_port_ops, 591 .port_ops = &sgiioc4_port_ops,
576 .dma_ops = &sgiioc4_dma_ops, 592 .dma_ops = &sgiioc4_dma_ops,
577 .host_flags = IDE_HFLAG_MMIO, 593 .host_flags = IDE_HFLAG_MMIO,
@@ -626,8 +642,6 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
626 /* Initializing chipset IRQ Registers */ 642 /* Initializing chipset IRQ Registers */
627 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); 643 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4));
628 644
629 hwif->read_status = sgiioc4_read_status;
630
631 idx[0] = hwif->index; 645 idx[0] = hwif->index;
632 646
633 if (ide_device_add(idx, &d, hws)) 647 if (ide_device_add(idx, &d, hws))
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index ed073c6635a8..ee557d10a764 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -974,6 +974,21 @@ static void pmac_ide_init_dev(ide_drive_t *drive)
974 } 974 }
975} 975}
976 976
977static const struct ide_tp_ops pmac_tp_ops = {
978 .exec_command = pmac_exec_command,
979 .read_status = ide_read_status,
980 .read_altstatus = ide_read_altstatus,
981 .read_sff_dma_status = ide_read_sff_dma_status,
982
983 .set_irq = pmac_set_irq,
984
985 .tf_load = ide_tf_load,
986 .tf_read = ide_tf_read,
987
988 .input_data = ide_input_data,
989 .output_data = ide_output_data,
990};
991
977static const struct ide_port_ops pmac_ide_ata6_port_ops = { 992static const struct ide_port_ops pmac_ide_ata6_port_ops = {
978 .init_dev = pmac_ide_init_dev, 993 .init_dev = pmac_ide_init_dev,
979 .set_pio_mode = pmac_ide_set_pio_mode, 994 .set_pio_mode = pmac_ide_set_pio_mode,
@@ -1003,10 +1018,11 @@ static const struct ide_port_info pmac_port_info = {
1003 .name = DRV_NAME, 1018 .name = DRV_NAME,
1004 .init_dma = pmac_ide_init_dma, 1019 .init_dma = pmac_ide_init_dma,
1005 .chipset = ide_pmac, 1020 .chipset = ide_pmac,
1021 .tp_ops = &pmac_tp_ops,
1022 .port_ops = &pmac_ide_port_ops,
1006#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC 1023#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
1007 .dma_ops = &pmac_dma_ops, 1024 .dma_ops = &pmac_dma_ops,
1008#endif 1025#endif
1009 .port_ops = &pmac_ide_port_ops,
1010 .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | 1026 .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA |
1011 IDE_HFLAG_POST_SET_MODE | 1027 IDE_HFLAG_POST_SET_MODE |
1012 IDE_HFLAG_MMIO | 1028 IDE_HFLAG_MMIO |
@@ -1106,9 +1122,6 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
1106 if (hwif == NULL) 1122 if (hwif == NULL)
1107 return -ENOENT; 1123 return -ENOENT;
1108 1124
1109 hwif->exec_command = pmac_exec_command;
1110 hwif->set_irq = pmac_set_irq;
1111
1112 idx[0] = hwif->index; 1125 idx[0] = hwif->index;
1113 1126
1114 ide_device_add(idx, &d, hws); 1127 ide_device_add(idx, &d, hws);
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index c1b609d9cb28..804c3ef245f9 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -125,7 +125,7 @@ int ide_pci_check_simplex(ide_hwif_t *hwif, const struct ide_port_info *d)
125 * we tune the drive then try to grab DMA ownership if we want to be 125 * we tune the drive then try to grab DMA ownership if we want to be
126 * the DMA end. This has to be become dynamic to handle hot-plug. 126 * the DMA end. This has to be become dynamic to handle hot-plug.
127 */ 127 */
128 dma_stat = hwif->read_sff_dma_status(hwif); 128 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
129 if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { 129 if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) {
130 printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name); 130 printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name);
131 return -1; 131 return -1;
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 2a86af91f64a..659db3f7ae08 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -142,7 +142,8 @@ static void ide_scsi_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
142 unsigned int bcount, int write) 142 unsigned int bcount, int write)
143{ 143{
144 ide_hwif_t *hwif = drive->hwif; 144 ide_hwif_t *hwif = drive->hwif;
145 xfer_func_t *xf = write ? hwif->output_data : hwif->input_data; 145 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
146 xfer_func_t *xf = write ? tp_ops->output_data : tp_ops->input_data;
146 char *buf; 147 char *buf;
147 int count; 148 int count;
148 149
@@ -246,9 +247,9 @@ idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
246{ 247{
247 ide_hwif_t *hwif = drive->hwif; 248 ide_hwif_t *hwif = drive->hwif;
248 249
249 if (hwif->read_status(hwif) & (BUSY_STAT | DRQ_STAT)) 250 if (hwif->tp_ops->read_status(hwif) & (BUSY_STAT | DRQ_STAT))
250 /* force an abort */ 251 /* force an abort */
251 hwif->exec_command(hwif, WIN_IDLEIMMEDIATE); 252 hwif->tp_ops->exec_command(hwif, WIN_IDLEIMMEDIATE);
252 253
253 rq->errors++; 254 rq->errors++;
254 255
diff --git a/include/linux/ide.h b/include/linux/ide.h
index e340218b2a5f..1286a2275efb 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -408,8 +408,28 @@ typedef struct ide_drive_s {
408 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx)) 408 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx))
409#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1) 409#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1)
410 410
411struct ide_task_s;
411struct ide_port_info; 412struct ide_port_info;
412 413
414struct ide_tp_ops {
415 void (*exec_command)(struct hwif_s *, u8);
416 u8 (*read_status)(struct hwif_s *);
417 u8 (*read_altstatus)(struct hwif_s *);
418 u8 (*read_sff_dma_status)(struct hwif_s *);
419
420 void (*set_irq)(struct hwif_s *, int);
421
422 void (*tf_load)(ide_drive_t *, struct ide_task_s *);
423 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
424
425 void (*input_data)(ide_drive_t *, struct request *, void *,
426 unsigned int);
427 void (*output_data)(ide_drive_t *, struct request *, void *,
428 unsigned int);
429};
430
431extern const struct ide_tp_ops default_tp_ops;
432
413struct ide_port_ops { 433struct ide_port_ops {
414 /* host specific initialization of a device */ 434 /* host specific initialization of a device */
415 void (*init_dev)(ide_drive_t *); 435 void (*init_dev)(ide_drive_t *);
@@ -447,8 +467,6 @@ struct ide_dma_ops {
447 void (*dma_timeout)(struct ide_drive_s *); 467 void (*dma_timeout)(struct ide_drive_s *);
448}; 468};
449 469
450struct ide_task_s;
451
452typedef struct hwif_s { 470typedef struct hwif_s {
453 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 471 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
454 struct hwif_s *mate; /* other hwif from same PCI chip */ 472 struct hwif_s *mate; /* other hwif from same PCI chip */
@@ -486,22 +504,10 @@ typedef struct hwif_s {
486 504
487 void (*rw_disk)(ide_drive_t *, struct request *); 505 void (*rw_disk)(ide_drive_t *, struct request *);
488 506
507 const struct ide_tp_ops *tp_ops;
489 const struct ide_port_ops *port_ops; 508 const struct ide_port_ops *port_ops;
490 const struct ide_dma_ops *dma_ops; 509 const struct ide_dma_ops *dma_ops;
491 510
492 void (*exec_command)(struct hwif_s *, u8);
493 u8 (*read_status)(struct hwif_s *);
494 u8 (*read_altstatus)(struct hwif_s *);
495 u8 (*read_sff_dma_status)(struct hwif_s *);
496
497 void (*set_irq)(struct hwif_s *, int);
498
499 void (*tf_load)(ide_drive_t *, struct ide_task_s *);
500 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
501
502 void (*input_data)(ide_drive_t *, struct request *, void *, unsigned);
503 void (*output_data)(ide_drive_t *, struct request *, void *, unsigned);
504
505 void (*ide_dma_clear_irq)(ide_drive_t *drive); 511 void (*ide_dma_clear_irq)(ide_drive_t *drive);
506 512
507 /* dma physical region descriptor table (cpu view) */ 513 /* dma physical region descriptor table (cpu view) */
@@ -949,6 +955,19 @@ typedef struct ide_task_s {
949 955
950void ide_tf_dump(const char *, struct ide_taskfile *); 956void ide_tf_dump(const char *, struct ide_taskfile *);
951 957
958void ide_exec_command(ide_hwif_t *, u8);
959u8 ide_read_status(ide_hwif_t *);
960u8 ide_read_altstatus(ide_hwif_t *);
961u8 ide_read_sff_dma_status(ide_hwif_t *);
962
963void ide_set_irq(ide_hwif_t *, int);
964
965void ide_tf_load(ide_drive_t *, ide_task_t *);
966void ide_tf_read(ide_drive_t *, ide_task_t *);
967
968void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int);
969void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int);
970
952extern void SELECT_DRIVE(ide_drive_t *); 971extern void SELECT_DRIVE(ide_drive_t *);
953void SELECT_MASK(ide_drive_t *, int); 972void SELECT_MASK(ide_drive_t *, int);
954 973
@@ -1022,8 +1041,6 @@ static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
1022} 1041}
1023#endif 1042#endif
1024 1043
1025extern void default_hwif_transport(ide_hwif_t *);
1026
1027typedef struct ide_pci_enablebit_s { 1044typedef struct ide_pci_enablebit_s {
1028 u8 reg; /* byte pci reg holding the enable-bit */ 1045 u8 reg; /* byte pci reg holding the enable-bit */
1029 u8 mask; /* mask to isolate the enable-bit */ 1046 u8 mask; /* mask to isolate the enable-bit */
@@ -1112,6 +1129,7 @@ struct ide_port_info {
1112 int (*init_dma)(ide_hwif_t *, 1129 int (*init_dma)(ide_hwif_t *,
1113 const struct ide_port_info *); 1130 const struct ide_port_info *);
1114 1131
1132 const struct ide_tp_ops *tp_ops;
1115 const struct ide_port_ops *port_ops; 1133 const struct ide_port_ops *port_ops;
1116 const struct ide_dma_ops *dma_ops; 1134 const struct ide_dma_ops *dma_ops;
1117 1135