]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-iops.c
ide: sanitize ide*_pm_* enums
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-iops.c
index 01b1943b315e920ba322dea3a5d61e9a1c4609bb..cec744cbbde0fe37724def1c53fa7ba1c6df1f4d 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>
@@ -404,26 +403,10 @@ void ide_fix_driveid(u16 *id)
 {
 #ifndef __LITTLE_ENDIAN
 # ifdef __BIG_ENDIAN
-       struct hd_driveid *driveid = (struct hd_driveid *)id;
        int i;
 
-       for (i = 0; i < 256; i++) {
-               /*  these words are accessed as two 8-bit values */
-               if (i == 47 || i == 49 || i == 51 || i == 52 || i == 59)
-                       continue;
-               if (i == 60 || i == 61) /* ->lba_capacity is 32-bit */
-                       continue;
-               if (i == 98 || i == 99) /* ->spg is 32-bit */
-                       continue;
-               if (i > 99 && i < 104)  /* ->lba_capacity_2 is 64-bit */
-                       continue;
-
+       for (i = 0; i < 256; i++)
                id[i] = __le16_to_cpu(id[i]);
-       }
-
-       driveid->lba_capacity   = __le32_to_cpu(driveid->lba_capacity);
-       driveid->spg            = __le32_to_cpu(driveid->spg);
-       driveid->lba_capacity_2 = __le64_to_cpu(driveid->lba_capacity_2);
 # else
 #  error "Please fix <asm/byteorder.h>"
 # endif
@@ -434,19 +417,21 @@ void ide_fix_driveid(u16 *id)
  * ide_fixstring() cleans up and (optionally) byte-swaps a text string,
  * removing leading/trailing blanks and compressing internal blanks.
  * It is primarily used to tidy up the model name/number fields as
- * returned by the WIN_[P]IDENTIFY commands.
+ * returned by the ATA_CMD_ID_ATA[PI] commands.
  */
 
 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 */
@@ -489,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;
 
@@ -521,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
@@ -532,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);
@@ -645,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)
@@ -662,7 +647,7 @@ u8 eighty_ninty_three (ide_drive_t *drive)
                return 1;
 
 no_80w:
-       if (drive->udma33_warned == 1)
+       if (drive->dev_flags & IDE_DFLAG_UDMA33_WARNED)
                return 0;
 
        printk(KERN_WARNING "%s: %s side 80-wire cable detection failed, "
@@ -670,7 +655,7 @@ no_80w:
                            drive->name,
                            hwif->cbl == ATA_CBL_PATA80 ? "drive" : "host");
 
-       drive->udma33_warned = 1;
+       drive->dev_flags |= IDE_DFLAG_UDMA33_WARNED;
 
        return 0;
 }
@@ -680,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;
 
        /*
@@ -691,29 +676,24 @@ int ide_driveid_update(ide_drive_t *drive)
        SELECT_MASK(drive, 1);
        tp_ops->set_irq(hwif, 0);
        msleep(50);
-       tp_ops->exec_command(hwif, WIN_IDENTIFY);
-       timeout = jiffies + WAIT_WORSTCASE;
-       do {
-               if (time_after(jiffies, timeout)) {
-                       SELECT_MASK(drive, 0);
-                       return 0;       /* drive timed-out */
-               }
+       tp_ops->exec_command(hwif, ATA_CMD_ID_ATA);
 
-               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;
@@ -731,7 +711,7 @@ int ide_driveid_update(ide_drive_t *drive)
 
        kfree(id);
 
-       if (drive->using_dma && ide_id_dma_bug(drive))
+       if ((drive->dev_flags & IDE_DFLAG_USING_DMA) && ide_id_dma_bug(drive))
                ide_dma_off(drive);
 
        return 1;
@@ -752,7 +732,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
 #endif
 
        /* Skip setting PIO flow-control modes on pre-EIDE drives */
-       if ((speed & 0xf8) == XFER_PIO_0 && !(drive->driveid->capability & 8))
+       if ((speed & 0xf8) == XFER_PIO_0 && ata_id_has_iordy(drive->id) == 0)
                goto skip;
 
        /*
@@ -786,13 +766,13 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
 
        tp_ops->tf_load(drive, &task);
 
-       tp_ops->exec_command(hwif, WIN_SETFEATURES);
+       tp_ops->exec_command(hwif, ATA_CMD_SET_FEATURES);
 
        if (drive->quirk_list == 2)
                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);
@@ -810,7 +790,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
 
  skip:
 #ifdef CONFIG_BLK_DEV_IDEDMA
-       if (speed >= XFER_SW_DMA_0 && drive->using_dma)
+       if (speed >= XFER_SW_DMA_0 && (drive->dev_flags & IDE_DFLAG_USING_DMA))
                hwif->dma_ops->dma_host_set(drive, 1);
        else if (hwif->dma_ops) /* check if host supports DMA */
                ide_dma_off_quietly(drive);
@@ -906,7 +886,7 @@ void ide_execute_pkt_cmd(ide_drive_t *drive)
        unsigned long flags;
 
        spin_lock_irqsave(&ide_lock, flags);
-       hwif->tp_ops->exec_command(hwif, WIN_PACKETCMD);
+       hwif->tp_ops->exec_command(hwif, ATA_CMD_PACKET);
        ndelay(400);
        spin_unlock_irqrestore(&ide_lock, flags);
 }
@@ -939,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)) {
@@ -985,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 */
@@ -1036,9 +1016,13 @@ static void ide_disk_pre_reset(ide_drive_t *drive)
        drive->special.all = 0;
        drive->special.b.set_geometry = legacy;
        drive->special.b.recalibrate  = legacy;
+
        drive->mult_count = 0;
-       if (!drive->keep_settings && !drive->using_dma)
+
+       if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0 &&
+           (drive->dev_flags & IDE_DFLAG_USING_DMA) == 0)
                drive->mult_req = 0;
+
        if (drive->mult_req != drive->mult_count)
                drive->special.b.set_multmode = 1;
 }
@@ -1050,18 +1034,18 @@ static void pre_reset(ide_drive_t *drive)
        if (drive->media == ide_disk)
                ide_disk_pre_reset(drive);
        else
-               drive->post_reset = 1;
+               drive->dev_flags |= IDE_DFLAG_POST_RESET;
 
-       if (drive->using_dma) {
+       if (drive->dev_flags & IDE_DFLAG_USING_DMA) {
                if (drive->crc_count)
                        ide_check_dma_crc(drive);
                else
                        ide_dma_off(drive);
        }
 
-       if (!drive->keep_settings) {
-               if (!drive->using_dma) {
-                       drive->unmask = 0;
+       if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0) {
+               if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0) {
+                       drive->dev_flags &= ~IDE_DFLAG_UNMASK;
                        drive->io_32bit = 0;
                }
                return;
@@ -1116,7 +1100,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
                pre_reset(drive);
                SELECT_DRIVE(drive);
                udelay (20);
-               tp_ops->exec_command(hwif, WIN_SRST);
+               tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
                ndelay(400);
                hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
                hwgroup->polling = 1;
@@ -1199,7 +1183,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