ide: use ->ata_input_data in ide_driveid_update()
[sfrench/cifs-2.6.git] / drivers / ide / ide-iops.c
index a95178f5e1bb4f1e3b5517ba97c84f2ddefd5596..e77cee0e5d65884f92f4ced39027afc9dcf0e79d 100644 (file)
@@ -430,10 +430,10 @@ int drive_is_ready (ide_drive_t *drive)
         * about possible isa-pnp and pci-pnp issues yet.
         */
        if (IDE_CONTROL_REG)
-               stat = hwif->INB(IDE_ALTSTATUS_REG);
+               stat = ide_read_altstatus(drive);
        else
                /* Note: this may clear a pending IRQ!! */
-               stat = hwif->INB(IDE_STATUS_REG);
+               stat = ide_read_status(drive);
 
        if (stat & BUSY_STAT)
                /* drive busy:  definitely not interrupting */
@@ -458,23 +458,24 @@ EXPORT_SYMBOL(drive_is_ready);
  */
 static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat)
 {
-       ide_hwif_t *hwif = drive->hwif;
        unsigned long flags;
        int i;
        u8 stat;
 
        udelay(1);      /* spec allows drive 400ns to assert "BUSY" */
-       if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) {
+       stat = ide_read_status(drive);
+
+       if (stat & BUSY_STAT) {
                local_irq_set(flags);
                timeout += jiffies;
-               while ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) {
+               while ((stat = ide_read_status(drive)) & BUSY_STAT) {
                        if (time_after(jiffies, timeout)) {
                                /*
                                 * One last read after the timeout in case
                                 * heavy interrupt load made us not make any
                                 * progress during the timeout..
                                 */
-                               stat = hwif->INB(IDE_STATUS_REG);
+                               stat = ide_read_status(drive);
                                if (!(stat & BUSY_STAT))
                                        break;
 
@@ -494,7 +495,9 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
         */
        for (i = 0; i < 10; i++) {
                udelay(1);
-               if (OK_STAT((stat = hwif->INB(IDE_STATUS_REG)), good, bad)) {
+               stat = ide_read_status(drive);
+
+               if (OK_STAT(stat, good, bad)) {
                        *rstat = stat;
                        return 0;
                }
@@ -592,6 +595,7 @@ u8 eighty_ninty_three (ide_drive_t *drive)
 
        /*
         * FIXME:
+        * - change master/slave IDENTIFY order
         * - force bit13 (80c cable present) check also for !ivb devices
         *   (unless the slave device is pre-ATA3)
         */
@@ -617,6 +621,7 @@ int ide_driveid_update(ide_drive_t *drive)
        ide_hwif_t *hwif = drive->hwif;
        struct hd_driveid *id;
        unsigned long timeout, flags;
+       u8 stat;
 
        /*
         * Re-read drive->id for possible DMA mode
@@ -633,10 +638,15 @@ int ide_driveid_update(ide_drive_t *drive)
                        SELECT_MASK(drive, 0);
                        return 0;       /* drive timed-out */
                }
+
                msleep(50);     /* give drive a breather */
-       } while (hwif->INB(IDE_ALTSTATUS_REG) & BUSY_STAT);
+               stat = ide_read_altstatus(drive);
+       } while (stat & BUSY_STAT);
+
        msleep(50);     /* wait for IRQ and DRQ_STAT */
-       if (!OK_STAT(hwif->INB(IDE_STATUS_REG),DRQ_STAT,BAD_R_STAT)) {
+       stat = ide_read_status(drive);
+
+       if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) {
                SELECT_MASK(drive, 0);
                printk("%s: CHECK for good STATUS\n", drive->name);
                return 0;
@@ -648,8 +658,8 @@ int ide_driveid_update(ide_drive_t *drive)
                local_irq_restore(flags);
                return 0;
        }
-       ata_input_data(drive, id, SECTOR_WORDS);
-       (void) hwif->INB(IDE_STATUS_REG);       /* clear drive IRQ */
+       hwif->ata_input_data(drive, id, SECTOR_WORDS);
+       (void)ide_read_status(drive);   /* clear drive IRQ */
        local_irq_enable();
        local_irq_restore(flags);
        ide_fix_driveid(id);
@@ -777,15 +787,11 @@ static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
 {
        ide_hwgroup_t *hwgroup = HWGROUP(drive);
 
-       if (hwgroup->handler != NULL) {
-               printk(KERN_CRIT "%s: ide_set_handler: handler not null; "
-                       "old=%p, new=%p\n",
-                       drive->name, hwgroup->handler, handler);
-       }
+       BUG_ON(hwgroup->handler);
        hwgroup->handler        = handler;
        hwgroup->expiry         = expiry;
        hwgroup->timer.expires  = jiffies + timeout;
-       hwgroup->req_gen_timer = hwgroup->req_gen;
+       hwgroup->req_gen_timer  = hwgroup->req_gen;
        add_timer(&hwgroup->timer);
 }
 
@@ -818,11 +824,9 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
                         unsigned timeout, ide_expiry_t *expiry)
 {
        unsigned long flags;
-       ide_hwgroup_t *hwgroup = HWGROUP(drive);
        ide_hwif_t *hwif = HWIF(drive);
 
        spin_lock_irqsave(&ide_lock, flags);
-       BUG_ON(hwgroup->handler);
        __ide_set_handler(drive, handler, timeout, expiry);
        hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG);
        /*
@@ -850,17 +854,16 @@ static ide_startstop_t do_reset1 (ide_drive_t *, int);
 static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
 {
        ide_hwgroup_t *hwgroup  = HWGROUP(drive);
-       ide_hwif_t *hwif        = HWIF(drive);
        u8 stat;
 
        SELECT_DRIVE(drive);
        udelay (10);
+       stat = ide_read_status(drive);
 
-       if (OK_STAT(stat = hwif->INB(IDE_STATUS_REG), 0, BUSY_STAT)) {
+       if (OK_STAT(stat, 0, BUSY_STAT))
                printk("%s: ATAPI reset complete\n", drive->name);
-       else {
+       else {
                if (time_before(jiffies, hwgroup->poll_timeout)) {
-                       BUG_ON(HWGROUP(drive)->handler != NULL);
                        ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL);
                        /* continue polling */
                        return ide_started;
@@ -898,9 +901,10 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
                }
        }
 
-       if (!OK_STAT(tmp = hwif->INB(IDE_STATUS_REG), 0, BUSY_STAT)) {
+       tmp = ide_read_status(drive);
+
+       if (!OK_STAT(tmp, 0, BUSY_STAT)) {
                if (time_before(jiffies, hwgroup->poll_timeout)) {
-                       BUG_ON(HWGROUP(drive)->handler != NULL);
                        ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
                        /* continue polling */
                        return ide_started;
@@ -909,7 +913,9 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
                drive->failures++;
        } else  {
                printk("%s: reset: ", hwif->name);
-               if ((tmp = hwif->INB(IDE_ERROR_REG)) == 1) {
+               tmp = ide_read_error(drive);
+
+               if (tmp == 1) {
                        printk("success\n");
                        drive->failures = 0;
                } else {