ide: sanitize handling of IDE_HFLAG_NO_SET_MODE host flag
[cascardo/linux.git] / drivers / ide / ide-lib.c
index b42940d..c859de7 100644 (file)
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
-/*
- *     IDE library routines. These are plug in code that most 
- *     drivers can use but occasionally may be weird enough
- *     to want to do their own thing with
- *
- *     Add common non I/O op stuff here. Make sure it has proper
- *     kernel-doc function headers or your patch will be rejected
- */
-
 static const char *udma_str[] =
         { "UDMA/16", "UDMA/25",  "UDMA/33",  "UDMA/44",
           "UDMA/66", "UDMA/100", "UDMA/133", "UDMA7" };
@@ -131,7 +122,6 @@ static struct ide_pio_info {
        const char      *name;
        int             pio;
 } ide_pio_blacklist [] = {
-/*     { "Conner Peripherals 1275MB - CFS1275A", 4 }, */
        { "Conner Peripherals 540MB - CFS540A", 3 },
 
        { "WDC AC2700",  3 },
@@ -147,10 +137,8 @@ static struct ide_pio_info {
        { "WDC AC1170",  1 },
        { "WDC AC1210",  1 },
        { "WDC AC280",   0 },
-/*     { "WDC AC21000", 4 }, */
        { "WDC AC31000", 3 },
        { "WDC AC31200", 3 },
-/*     { "WDC AC31600", 4 }, */
 
        { "Maxtor 7131 AT", 1 },
        { "Maxtor 7171 AT", 1 },
@@ -164,13 +152,6 @@ static struct ide_pio_info {
        { "SAMSUNG SHD-3122A", 1 },
        { "SAMSUNG SHD-3172A", 1 },
 
-/*     { "ST51080A", 4 },
- *     { "ST51270A", 4 },
- *     { "ST31220A", 4 },
- *     { "ST31640A", 4 },
- *     { "ST32140A", 4 },
- *     { "ST3780A",  4 },
- */
        { "ST5660A",  3 },
        { "ST3660A",  3 },
        { "ST3630A",  3 },
@@ -293,16 +274,6 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
                if (overridden)
                        printk(KERN_INFO "%s: tPIO > 2, assuming tPIO = 2\n",
                                         drive->name);
-
-               /*
-                * Conservative "downgrade" for all pre-ATA2 drives
-                */
-               if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_DOWNGRADE) == 0 &&
-                   pio_mode && pio_mode < 4) {
-                       pio_mode--;
-                       printk(KERN_INFO "%s: applying conservative "
-                                        "PIO \"downgrade\"\n", drive->name);
-               }
        }
 
        if (pio_mode > max_mode)
@@ -319,7 +290,8 @@ void ide_set_pio(ide_drive_t *drive, u8 req_pio)
        ide_hwif_t *hwif = drive->hwif;
        u8 host_pio, pio;
 
-       if (hwif->set_pio_mode == NULL)
+       if (hwif->set_pio_mode == NULL ||
+           (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
                return;
 
        BUG_ON(hwif->pio_mask == 0x00);
@@ -372,6 +344,9 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
 {
        ide_hwif_t *hwif = drive->hwif;
 
+       if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
+               return 0;
+
        if (hwif->set_pio_mode == NULL)
                return -1;
 
@@ -399,6 +374,9 @@ int ide_set_dma_mode(ide_drive_t *drive, const u8 mode)
 {
        ide_hwif_t *hwif = drive->hwif;
 
+       if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
+               return 0;
+
        if (hwif->set_dma_mode == NULL)
                return -1;
 
@@ -429,7 +407,8 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
 {
        ide_hwif_t *hwif = drive->hwif;
 
-       if (hwif->set_dma_mode == NULL)
+       if (hwif->set_dma_mode == NULL ||
+           (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
                return -1;
 
        rate = ide_rate_filter(drive, rate);
@@ -578,7 +557,7 @@ u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat)
        }
        printk("}\n");
        if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) {
-               err = drive->hwif->INB(IDE_ERROR_REG);
+               err = ide_read_error(drive);
                printk("%s: %s: error=0x%02x ", drive->name, msg, err);
                if (drive->media == ide_disk)
                        ide_dump_ata_error(drive, err);