ide: keep pointer to struct device instead of struct pci_dev in ide_hwif_t
[safe/jmp/linux-2.6] / drivers / ide / pci / it8213.c
index f161836..df74e58 100644 (file)
@@ -28,7 +28,7 @@
 static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct pci_dev *dev     = hwif->pci_dev;
+       struct pci_dev *dev     = to_pci_dev(hwif->dev);
        int is_slave            = drive->dn & 1;
        int master_port         = 0x40;
        int slave_port          = 0x44;
@@ -85,7 +85,7 @@ static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio)
 static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct pci_dev *dev     = hwif->pci_dev;
+       struct pci_dev *dev     = to_pci_dev(hwif->dev);
        u8 maslave              = 0x40;
        int a_speed             = 3 << (drive->dn * 4);
        int u_flag              = 1 << drive->dn;
@@ -101,24 +101,11 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
        pci_read_config_byte(dev, 0x54, &reg54);
        pci_read_config_byte(dev, 0x55, &reg55);
 
-       switch(speed) {
-               case XFER_UDMA_6:
-               case XFER_UDMA_4:
-               case XFER_UDMA_2:       u_speed = 2 << (drive->dn * 4); break;
-               case XFER_UDMA_5:
-               case XFER_UDMA_3:
-               case XFER_UDMA_1:       u_speed = 1 << (drive->dn * 4); break;
-               case XFER_UDMA_0:       u_speed = 0 << (drive->dn * 4); break;
-                       break;
-               case XFER_MW_DMA_2:
-               case XFER_MW_DMA_1:
-               case XFER_SW_DMA_2:
-                       break;
-               default:
-                       return;
-       }
-
        if (speed >= XFER_UDMA_0) {
+               u8 udma = speed - XFER_UDMA_0;
+
+               u_speed = min_t(u8, 2 - (udma & 1), udma) << (drive->dn * 4);
+
                if (!(reg48 & u_flag))
                        pci_write_config_byte(dev, 0x48, reg48 | u_flag);
                if (speed >= XFER_UDMA_5) {
@@ -165,22 +152,16 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
 
 static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
 {
+       struct pci_dev *dev = to_pci_dev(hwif->dev);
        u8 reg42h = 0;
 
        hwif->set_dma_mode = &it8213_set_dma_mode;
        hwif->set_pio_mode = &it8213_set_pio_mode;
 
-       hwif->drives[0].autotune = 1;
-       hwif->drives[1].autotune = 1;
-
        if (!hwif->dma_base)
                return;
 
-       hwif->ultra_mask = 0x7f;
-       hwif->mwdma_mask = 0x06;
-       hwif->swdma_mask = 0x04;
-
-       pci_read_config_byte(hwif->pci_dev, 0x42, &reg42h);
+       pci_read_config_byte(dev, 0x42, &reg42h);
 
        if (hwif->cbl != ATA_CBL_PATA40_SHORT)
                hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
@@ -195,9 +176,12 @@ static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
                .host_flags     = IDE_HFLAG_SINGLE |    \
                                  IDE_HFLAG_BOOTABLE,   \
                .pio_mask       = ATA_PIO4,             \
+               .swdma_mask     = ATA_SWDMA2_ONLY,      \
+               .mwdma_mask     = ATA_MWDMA12_ONLY,     \
+               .udma_mask      = ATA_UDMA6,            \
        }
 
-static ide_pci_device_t it8213_chipsets[] __devinitdata = {
+static const struct ide_port_info it8213_chipsets[] __devinitdata = {
        /* 0 */ DECLARE_ITE_DEV("IT8213"),
 };