]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/pci/hpt34x.c
ide: use PIO/MMIO operations directly where possible (v2)
[linux-2.6-omap-h63xx.git] / drivers / ide / pci / hpt34x.c
index ce7b08f08a0959fe428cec32ff01e1b218ed3afc..0830089c77fd547938474b9fe138dbe14a6c35df 100644 (file)
@@ -48,19 +48,6 @@ static u8 hpt34x_ratemask (ide_drive_t *drive)
        return 1;
 }
 
-static void hpt34x_clear_chipset (ide_drive_t *drive)
-{
-       struct pci_dev *dev     = HWIF(drive)->pci_dev;
-       u32 reg1 = 0, tmp1 = 0, reg2 = 0, tmp2 = 0;
-
-       pci_read_config_dword(dev, 0x44, &reg1);
-       pci_read_config_dword(dev, 0x48, &reg2);
-       tmp1 = ((0x00 << (3*drive->dn)) | (reg1 & ~(7 << (3*drive->dn))));
-       tmp2 = (reg2 & ~(0x11 << drive->dn));
-       pci_write_config_dword(dev, 0x44, tmp1);
-       pci_write_config_dword(dev, 0x48, tmp2);
-}
-
 static int hpt34x_tune_chipset (ide_drive_t *drive, u8 xferspeed)
 {
        struct pci_dev *dev     = HWIF(drive)->pci_dev;
@@ -81,7 +68,7 @@ static int hpt34x_tune_chipset (ide_drive_t *drive, u8 xferspeed)
        pci_read_config_dword(dev, 0x44, &reg1);
        pci_read_config_dword(dev, 0x48, &reg2);
        tmp1 = ((lo_speed << (3*drive->dn)) | (reg1 & ~(7 << (3*drive->dn))));
-       tmp2 = ((hi_speed << drive->dn) | reg2);
+       tmp2 = ((hi_speed << drive->dn) | (reg2 & ~(0x11 << drive->dn)));
        pci_write_config_dword(dev, 0x44, tmp1);
        pci_write_config_dword(dev, 0x48, tmp2);
 
@@ -99,7 +86,6 @@ static int hpt34x_tune_chipset (ide_drive_t *drive, u8 xferspeed)
 static void hpt34x_tune_drive (ide_drive_t *drive, u8 pio)
 {
        pio = ide_get_best_pio_mode(drive, pio, 5, NULL);
-       hpt34x_clear_chipset(drive);
        (void) hpt34x_tune_chipset(drive, (XFER_PIO_0 + pio));
 }
 
@@ -117,7 +103,6 @@ static int config_chipset_for_dma (ide_drive_t *drive)
        if (!(speed))
                return 0;
 
-       hpt34x_clear_chipset(drive);
        (void) hpt34x_tune_chipset(drive, speed);
        return ide_dma_enable(drive);
 }
@@ -125,25 +110,17 @@ static int config_chipset_for_dma (ide_drive_t *drive)
 static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
 
        drive->init_speed = 0;
 
-       if (id && (id->capability & 1) && drive->autodma) {
-
-               if (ide_use_dma(drive)) {
-                       if (config_chipset_for_dma(drive))
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
 #ifndef CONFIG_HPT34X_AUTODMA
-                               return hwif->ide_dma_off_quietly(drive);
+               return hwif->ide_dma_off_quietly(drive);
 #else
-                               return hwif->ide_dma_on(drive);
+               return hwif->ide_dma_on(drive);
 #endif
-               }
-
-               goto fast_ata_pio;
 
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                hpt34x_tune_drive(drive, 255);
                return hwif->ide_dma_off_quietly(drive);
        }
@@ -209,7 +186,6 @@ static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif)
 
        hwif->tuneproc = &hpt34x_tune_drive;
        hwif->speedproc = &hpt34x_tune_chipset;
-       hwif->no_dsc = 1;
        hwif->drives[0].autotune = 1;
        hwif->drives[1].autotune = 1;