mutex_unlock(&idefloppy_ref_mutex);
 }
 
-/*
- * Too bad. The drive wants to send us data which we are not ready to accept.
- * Just throw it away.
- */
-static void idefloppy_discard_data(ide_drive_t *drive, unsigned int bcount)
-{
-       while (bcount--)
-               (void) HWIF(drive)->INB(IDE_DATA_REG);
-}
-
-static void idefloppy_write_zeros(ide_drive_t *drive, unsigned int bcount)
-{
-       while (bcount--)
-               HWIF(drive)->OUTB(0, IDE_DATA_REG);
-}
-
-
 /*
  * Used to finish servicing a request. For read/write requests, we will call
  * ide_end_request to pass to the next buffer.
                printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n",
                                drive->name, __func__, bcount);
                if (direction)
-                       idefloppy_write_zeros(drive, bcount);
+                       ide_atapi_write_zeros(drive, bcount);
                else
-                       idefloppy_discard_data(drive, bcount);
-
+                       ide_atapi_discard_data(drive, bcount);
        }
 }
 
                                printk(KERN_ERR "ide-floppy: The floppy wants "
                                        "to send us more data than expected "
                                        "- discarding data\n");
-                               idefloppy_discard_data(drive, bcount);
+                               ide_atapi_discard_data(drive, bcount);
 
                                ide_set_handler(drive,
                                                &idefloppy_pc_intr,
 
        return tape;
 }
 
-/*
- * Too bad. The drive wants to send us data which we are not ready to accept.
- * Just throw it away.
- */
-static void idetape_discard_data(ide_drive_t *drive, unsigned int bcount)
-{
-       while (bcount--)
-               (void) HWIF(drive)->INB(IDE_DATA_REG);
-}
-
 static void idetape_input_buffers(ide_drive_t *drive, idetape_pc_t *pc,
                                  unsigned int bcount)
 {
                if (bh == NULL) {
                        printk(KERN_ERR "ide-tape: bh == NULL in "
                                "idetape_input_buffers\n");
-                       idetape_discard_data(drive, bcount);
+                       ide_atapi_discard_data(drive, bcount);
                        return;
                }
                count = min(
                                printk(KERN_ERR "ide-tape: The tape wants to "
                                        "send us more data than expected "
                                        "- discarding data\n");
-                               idetape_discard_data(drive, bcount);
+                               ide_atapi_discard_data(drive, bcount);
                                ide_set_handler(drive, &idetape_pc_intr,
                                                IDETAPE_WAIT_CMD, NULL);
                                return ide_started;
 
  */
 #define IDESCSI_PC_RQ                  90
 
-static void idescsi_discard_data (ide_drive_t *drive, unsigned int bcount)
-{
-       while (bcount--)
-               (void) HWIF(drive)->INB(IDE_DATA_REG);
-}
-
-static void idescsi_output_zeros (ide_drive_t *drive, unsigned int bcount)
-{
-       while (bcount--)
-               HWIF(drive)->OUTB(0, IDE_DATA_REG);
-}
-
 /*
  *     PIO data transfer routines using the scatter gather table.
  */
 
        if (bcount) {
                printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n");
-               idescsi_discard_data (drive, bcount);
+               ide_atapi_discard_data(drive, bcount);
        }
 }
 
 
        if (bcount) {
                printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n");
-               idescsi_output_zeros (drive, bcount);
+               ide_atapi_write_zeros(drive, bcount);
        }
 }
 
                                }
                                pc->actually_transferred += temp;
                                pc->current_position += temp;
-                               idescsi_discard_data(drive, bcount - temp);
+                               ide_atapi_discard_data(drive, bcount - temp);
                                ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
                                return ide_started;
                        }
 
        return hwif->INB(hwif->io_ports[IDE_ERROR_OFFSET]);
 }
 
+/*
+ * Too bad. The drive wants to send us data which we are not ready to accept.
+ * Just throw it away.
+ */
+static inline void ide_atapi_discard_data(ide_drive_t *drive, unsigned bcount)
+{
+       ide_hwif_t *hwif = drive->hwif;
+
+       /* FIXME: use ->atapi_input_bytes */
+       while (bcount--)
+               (void)hwif->INB(hwif->io_ports[IDE_DATA_OFFSET]);
+}
+
+static inline void ide_atapi_write_zeros(ide_drive_t *drive, unsigned bcount)
+{
+       ide_hwif_t *hwif = drive->hwif;
+
+       /* FIXME: use ->atapi_output_bytes */
+       while (bcount--)
+               hwif->OUTB(0, hwif->io_ports[IDE_DATA_OFFSET]);
+}
+
 #endif /* _IDE_H */