ide: Remove ide_spin_wait_hwgroup() and use special requests instead
[safe/jmp/linux-2.6] / drivers / ide / ide-iops.c
index 21647a2..0a2fd3b 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
-#include <linux/hdreg.h>
 #include <linux/ide.h>
 #include <linux/bitops.h>
 #include <linux/nmi.h>
@@ -423,14 +422,16 @@ void ide_fix_driveid(u16 *id)
 
 void ide_fixstring (u8 *s, const int bytecount, const int byteswap)
 {
-       u8 *p = s, *end = &s[bytecount & ~1]; /* bytecount must be even */
+       u8 *p, *end = &s[bytecount & ~1]; /* bytecount must be even */
 
        if (byteswap) {
                /* convert from big-endian to host byte order */
-               for (p = end ; p != s;)
-                       be16_to_cpus((u16 *)(p -= 2));
+               for (p = s ; p != end ; p += 2)
+                       be16_to_cpus((u16 *) p);
        }
+
        /* strip leading blanks */
+       p = s;
        while (s != end && *s == ' ')
                ++s;
        /* compress internal blanks and strip trailing blanks */
@@ -473,7 +474,7 @@ int drive_is_ready (ide_drive_t *drive)
                /* Note: this may clear a pending IRQ!! */
                stat = hwif->tp_ops->read_status(hwif);
 
-       if (stat & BUSY_STAT)
+       if (stat & ATA_BUSY)
                /* drive busy:  definitely not interrupting */
                return 0;
 
@@ -505,10 +506,10 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
        udelay(1);      /* spec allows drive 400ns to assert "BUSY" */
        stat = tp_ops->read_status(hwif);
 
-       if (stat & BUSY_STAT) {
+       if (stat & ATA_BUSY) {
                local_irq_set(flags);
                timeout += jiffies;
-               while ((stat = tp_ops->read_status(hwif)) & BUSY_STAT) {
+               while ((stat = tp_ops->read_status(hwif)) & ATA_BUSY) {
                        if (time_after(jiffies, timeout)) {
                                /*
                                 * One last read after the timeout in case
@@ -516,7 +517,7 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
                                 * progress during the timeout..
                                 */
                                stat = tp_ops->read_status(hwif);
-                               if (!(stat & BUSY_STAT))
+                               if ((stat & ATA_BUSY) == 0)
                                        break;
 
                                local_irq_restore(flags);
@@ -629,7 +630,7 @@ u8 eighty_ninty_three (ide_drive_t *drive)
                printk(KERN_DEBUG "%s: skipping word 93 validity check\n",
                                  drive->name);
 
-       if (ide_dev_is_sata(id) && !ivb)
+       if (ata_id_is_sata(id) && !ivb)
                return 1;
 
        if (hwif->cbl != ATA_CBL_PATA80 && !ivb)
@@ -664,7 +665,7 @@ int ide_driveid_update(ide_drive_t *drive)
        ide_hwif_t *hwif = drive->hwif;
        const struct ide_tp_ops *tp_ops = hwif->tp_ops;
        u16 *id;
-       unsigned long timeout, flags;
+       unsigned long flags;
        u8 stat;
 
        /*
@@ -676,28 +677,23 @@ int ide_driveid_update(ide_drive_t *drive)
        tp_ops->set_irq(hwif, 0);
        msleep(50);
        tp_ops->exec_command(hwif, ATA_CMD_ID_ATA);
-       timeout = jiffies + WAIT_WORSTCASE;
-       do {
-               if (time_after(jiffies, timeout)) {
-                       SELECT_MASK(drive, 0);
-                       return 0;       /* drive timed-out */
-               }
 
-               msleep(50);     /* give drive a breather */
-               stat = tp_ops->read_altstatus(hwif);
-       } while (stat & BUSY_STAT);
+       if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 1)) {
+               SELECT_MASK(drive, 0);
+               return 0;
+       }
 
-       msleep(50);     /* wait for IRQ and DRQ_STAT */
+       msleep(50);     /* wait for IRQ and ATA_DRQ */
        stat = tp_ops->read_status(hwif);
 
-       if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) {
+       if (!OK_STAT(stat, ATA_DRQ, BAD_R_STAT)) {
                SELECT_MASK(drive, 0);
                printk("%s: CHECK for good STATUS\n", drive->name);
                return 0;
        }
        local_irq_save(flags);
        SELECT_MASK(drive, 0);
-       id = kmalloc(SECTOR_WORDS*4, GFP_ATOMIC);
+       id = kmalloc(SECTOR_SIZE, GFP_ATOMIC);
        if (!id) {
                local_irq_restore(flags);
                return 0;
@@ -776,7 +772,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
                tp_ops->set_irq(hwif, 1);
 
        error = __ide_wait_stat(drive, drive->ready_stat,
-                               BUSY_STAT|DRQ_STAT|ERR_STAT,
+                               ATA_BUSY | ATA_DRQ | ATA_ERR,
                                WAIT_CMD, &stat);
 
        SELECT_MASK(drive, 0);
@@ -923,7 +919,7 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
        udelay (10);
        stat = hwif->tp_ops->read_status(hwif);
 
-       if (OK_STAT(stat, 0, BUSY_STAT))
+       if (OK_STAT(stat, 0, ATA_BUSY))
                printk("%s: ATAPI reset complete\n", drive->name);
        else {
                if (time_before(jiffies, hwgroup->poll_timeout)) {
@@ -969,7 +965,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
 
        tmp = hwif->tp_ops->read_status(hwif);
 
-       if (!OK_STAT(tmp, 0, BUSY_STAT)) {
+       if (!OK_STAT(tmp, 0, ATA_BUSY)) {
                if (time_before(jiffies, hwgroup->poll_timeout)) {
                        ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
                        /* continue polling */
@@ -1183,7 +1179,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
                 */
                mdelay(1);
                stat = hwif->tp_ops->read_status(hwif);
-               if ((stat & BUSY_STAT) == 0)
+               if ((stat & ATA_BUSY) == 0)
                        return 0;
                /*
                 * Assume a value of 0xff means nothing is connected to