]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ide: remove ide_find_best_pio_mode()
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Thu, 19 Jul 2007 23:11:58 +0000 (01:11 +0200)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Thu, 19 Jul 2007 23:11:58 +0000 (01:11 +0200)
* Add ->host_flags to ide_hwif_t to store ide_pci_device_t.host_flags,
  assign it in setup-pci.c:ide_pci_setup_ports().

* Add IDE_HFLAG_PIO_NO_{BLACKLIST,DOWNGRADE} to ide_pci_device_t.host_flags
  and teach ide_get_best_pio_mode() about them.  Also remove needless
  !drive->id check while at it (drive->id is always present).

* Convert amd74xx, via82cxxx and ide-timing.h to use ide_get_best_pio_mode()
  and then remove no longer needed ide_find_best_pio_mode().

There should be no functionality changes caused by this patch.

Acked-by: Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/ide-lib.c
drivers/ide/ide-timing.h
drivers/ide/ide.c
drivers/ide/pci/amd74xx.c
drivers/ide/pci/via82cxxx.c
drivers/ide/setup-pci.c
include/linux/ide.h

index df29868209f39f15cb4e7aaae67215cf06660b46..92a6c7bcf5278dc8594eb7a73113c9d648647f63 100644 (file)
@@ -291,11 +291,11 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
        struct hd_driveid* id = drive->id;
        int overridden  = 0;
 
-       if (mode_wanted != 255) {
-               pio_mode = mode_wanted;
-       } else if (!drive->id) {
-               pio_mode = 0;
-       } else if ((pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
+       if (mode_wanted != 255)
+               return min_t(u8, mode_wanted, max_mode);
+
+       if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0 &&
+           (pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
                printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name);
        } else {
                pio_mode = id->tPIO;
@@ -324,7 +324,8 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
                /*
                 * Conservative "downgrade" for all pre-ATA2 drives
                 */
-               if (pio_mode && pio_mode < 4) {
+               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);
index 9b5afebafbf49ef281fa1e8cfa1fe0fc7a5448b9..daffbb9797e18d756299786d2326e0f892fe67f6 100644 (file)
@@ -106,21 +106,6 @@ static struct ide_timing ide_timing[] = {
 #define XFER_EPIO      0x01
 #define XFER_PIO       0x00
 
-static short ide_find_best_pio_mode(ide_drive_t *drive)
-{
-       struct hd_driveid *id = drive->id;
-       short best = 0;
-
-       /* EIDE PIO modes */
-       if ((id->field_valid & 2) && (id->capability & 8)) {
-               if ((best = (drive->id->eide_pio_modes & 4) ? XFER_PIO_5 :
-                           (drive->id->eide_pio_modes & 2) ? XFER_PIO_4 :
-                           (drive->id->eide_pio_modes & 1) ? XFER_PIO_3 : 0)) return best;
-       }
-
-       return XFER_PIO_0 + min_t(u8, id->tPIO, 2);
-}
-
 static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int T, int UT)
 {
        q->setup   = EZ(t->setup   * 1000,  T);
@@ -210,7 +195,8 @@ static int ide_timing_compute(ide_drive_t *drive, short speed, struct ide_timing
  */
 
        if ((speed & XFER_MODE) != XFER_PIO) {
-               ide_timing_compute(drive, ide_find_best_pio_mode(drive), &p, T, UT);
+               u8 pio = ide_get_best_pio_mode(drive, 255, 5);
+               ide_timing_compute(drive, XFER_PIO_0 + pio, &p, T, UT);
                ide_timing_merge(&p, t, t, IDE_TIMING_ALL);
        }
 
index 077fb674a96df3002a11bac7bd72777341e224ba..b442b341d52ef015405f29ff99da6c8d1f9d2384 100644 (file)
@@ -455,6 +455,8 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
        hwif->straight8                 = tmp_hwif->straight8;
        hwif->bus_state                 = tmp_hwif->bus_state;
 
+       hwif->host_flags                = tmp_hwif->host_flags;
+
        hwif->atapi_dma                 = tmp_hwif->atapi_dma;
        hwif->ultra_mask                = tmp_hwif->ultra_mask;
        hwif->mwdma_mask                = tmp_hwif->mwdma_mask;
index 9c3ea90aeb8bf931c5b55aa901470ab96e539567..5ed1d485fc7e1a852762af61b1a77c9312ea1ad7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Version 2.20
+ * Version 2.21
  *
  * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04
  * IDE driver for Linux.
@@ -272,10 +272,8 @@ static int amd_set_drive(ide_drive_t *drive, u8 speed)
 
 static void amd74xx_tune_drive(ide_drive_t *drive, u8 pio)
 {
-       if (pio == 255) {
-               amd_set_drive(drive, ide_find_best_pio_mode(drive));
-               return;
-       }
+       if (pio == 255)
+               pio = ide_get_best_pio_mode(drive, 255, 5);
 
        amd_set_drive(drive, XFER_PIO_0 + min_t(byte, pio, 5));
 }
@@ -284,12 +282,14 @@ static int amd74xx_ide_dma_check(ide_drive_t *drive)
 {
        u8 speed = ide_max_dma_mode(drive);
 
-       if (speed == 0)
-               speed = ide_find_best_pio_mode(drive);
+       if (speed == 0) {
+               amd74xx_tune_drive(drive, 255);
+               return -1;
+       }
 
        amd_set_drive(drive, speed);
 
-       if (drive->autodma && (speed & XFER_MODE) != XFER_PIO)
+       if (drive->autodma)
                return 0;
 
        return -1;
@@ -451,6 +451,8 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
                .autodma        = AUTODMA,                              \
                .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \
                .bootable       = ON_BOARD,                             \
+               .host_flags     = IDE_HFLAG_PIO_NO_BLACKLIST            \
+                               | IDE_HFLAG_PIO_NO_DOWNGRADE,           \
        }
 
 #define DECLARE_NV_DEV(name_str)                                       \
@@ -461,6 +463,8 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
                .autodma        = AUTODMA,                              \
                .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \
                .bootable       = ON_BOARD,                             \
+               .host_flags     = IDE_HFLAG_PIO_NO_BLACKLIST            \
+                               | IDE_HFLAG_PIO_NO_DOWNGRADE,           \
        }
 
 static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
index bfc9b67f8c9293f935784a5ef9cfe6b231033123..b107ee3588f79750220344648af1b8eabcdabf54 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- * Version 3.45
+ * Version 3.46
  *
  * VIA IDE driver for Linux. Supported southbridges:
  *
@@ -203,10 +203,8 @@ static int via_set_drive(ide_drive_t *drive, u8 speed)
 
 static void via82cxxx_tune_drive(ide_drive_t *drive, u8 pio)
 {
-       if (pio == 255) {
-               via_set_drive(drive, ide_find_best_pio_mode(drive));
-               return;
-       }
+       if (pio == 255)
+               pio = ide_get_best_pio_mode(drive, 255, 5);
 
        via_set_drive(drive, XFER_PIO_0 + min_t(u8, pio, 5));
 }
@@ -223,12 +221,14 @@ static int via82cxxx_ide_dma_check (ide_drive_t *drive)
 {
        u8 speed = ide_max_dma_mode(drive);
 
-       if (speed == 0)
-               speed = ide_find_best_pio_mode(drive);
+       if (speed == 0) {
+               via82cxxx_tune_drive(drive, 255);
+               return -1;
+       }
 
        via_set_drive(drive, speed);
 
-       if (drive->autodma && (speed & XFER_MODE) != XFER_PIO)
+       if (drive->autodma)
                return 0;
 
        return -1;
@@ -500,7 +500,9 @@ static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
                .init_hwif      = init_hwif_via82cxxx,
                .autodma        = NOAUTODMA,
                .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
-               .bootable       = ON_BOARD
+               .bootable       = ON_BOARD,
+               .host_flags     = IDE_HFLAG_PIO_NO_BLACKLIST
+                               | IDE_HFLAG_PIO_NO_DOWNGRADE,
        },{     /* 1 */
                .name           = "VP_IDE",
                .init_chipset   = init_chipset_via82cxxx,
@@ -508,6 +510,8 @@ static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
                .autodma        = AUTODMA,
                .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
                .bootable       = ON_BOARD,
+               .host_flags     = IDE_HFLAG_PIO_NO_BLACKLIST
+                               | IDE_HFLAG_PIO_NO_DOWNGRADE,
        }
 };
 
index bfe1f4e595975fb70ad8453130f4f08af9d255a9..e9f3267456e2925f5cf9e7ebf34fda1aee411382 100644 (file)
@@ -613,6 +613,8 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a
                else
                        ide_hwif_setup_dma(dev, d, hwif);
 bypass_legacy_dma:
+               hwif->host_flags = d->host_flags;
+
                if (d->init_hwif)
                        /* Call chipset-specific routine
                         * for each enabled hwif
index 14a87f619d17c538e158d9d10425b1d753eb3808..9f72f6e0c9549e284349e057e564ab15c0e060e5 100644 (file)
@@ -681,6 +681,8 @@ typedef struct hwif_s {
        u8 straight8;   /* Alan's straight 8 check */
        u8 bus_state;   /* power state of the IDE bus */
 
+       u8 host_flags;
+
        u8 atapi_dma;   /* host supports atapi_dma */
        u8 ultra_mask;
        u8 mwdma_mask;
@@ -1245,7 +1247,12 @@ typedef struct ide_pci_enablebit_s {
 enum {
        /* Uses ISA control ports not PCI ones. */
        IDE_HFLAG_ISA_PORTS             = (1 << 0),
+       /* single port device */
        IDE_HFLAG_SINGLE                = (1 << 1),
+       /* don't use legacy PIO blacklist */
+       IDE_HFLAG_PIO_NO_BLACKLIST      = (1 << 2),
+       /* don't use conservative PIO "downgrade" */
+       IDE_HFLAG_PIO_NO_DOWNGRADE      = (1 << 3),
 };
 
 typedef struct ide_pci_device_s {