ide: add struct ide_port_ops (take 2)
[safe/jmp/linux-2.6] / drivers / ide / pci / cs5530.c
index 9dfd35f..f5534c1 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/drivers/ide/pci/cs5530.c              Version 0.76    Aug 3 2007
- *
  * Copyright (C) 2000                  Andre Hedrick <andre@linux-ide.org>
  * Copyright (C) 2000                  Mark Lord <mlord@pobox.com>
  * Copyright (C) 2007                  Bartlomiej Zolnierkiewicz
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/ioport.h>
-#include <linux/blkdev.h>
 #include <linux/hdreg.h>
-#include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/ide.h>
+
 #include <asm/io.h>
-#include <asm/irq.h>
 
 /*
  * Here are the standard PIO mode 0-4 timings for each "format".
@@ -116,9 +108,6 @@ static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode)
                case XFER_MW_DMA_0:     timings = 0x00077771; break;
                case XFER_MW_DMA_1:     timings = 0x00012121; break;
                case XFER_MW_DMA_2:     timings = 0x00002020; break;
-               default:
-                       BUG();
-                       break;
        }
        basereg = CS5530_BASEREG(drive->hwif);
        reg = inl(basereg + 4);                 /* get drive0 config register */
@@ -146,7 +135,6 @@ static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode)
 static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const char *name)
 {
        struct pci_dev *master_0 = NULL, *cs5530_0 = NULL;
-       unsigned long flags;
 
        if (pci_resource_start(dev, 4) == 0)
                return -EFAULT;
@@ -171,9 +159,6 @@ static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const ch
                goto out;
        }
 
-       spin_lock_irqsave(&ide_lock, flags);
-               /* all CPUs (there should only be one CPU with this chipset) */
-
        /*
         * Enable BusMaster and MemoryWriteAndInvalidate for the cs5530:
         * -->  OR 0x14 into 16-bit PCI COMMAND reg of function 0 of the cs5530
@@ -224,8 +209,6 @@ static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const ch
        pci_write_config_byte(master_0, 0x42, 0x00);
        pci_write_config_byte(master_0, 0x43, 0xc1);
 
-       spin_unlock_irqrestore(&ide_lock, flags);
-
 out:
        pci_dev_put(master_0);
        pci_dev_put(cs5530_0);
@@ -245,37 +228,30 @@ static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif)
        unsigned long basereg;
        u32 d0_timings;
 
-       if (hwif->mate)
-               hwif->serialized = hwif->mate->serialized = 1;
-
-       hwif->set_pio_mode = &cs5530_set_pio_mode;
-       hwif->set_dma_mode = &cs5530_set_dma_mode;
-
        basereg = CS5530_BASEREG(hwif);
        d0_timings = inl(basereg + 0);
        if (CS5530_BAD_PIO(d0_timings))
                outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 0);
        if (CS5530_BAD_PIO(inl(basereg + 8)))
                outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 8);
-
-       hwif->drives[0].autotune = 1;
-       hwif->drives[1].autotune = 1;
-
-       if (hwif->dma_base == 0)
-               return;
-
-       hwif->ultra_mask = 0x07;
-       hwif->mwdma_mask = 0x07;
-
-       hwif->udma_filter = cs5530_udma_filter;
 }
 
-static ide_pci_device_t cs5530_chipset __devinitdata = {
+static const struct ide_port_ops cs5530_port_ops = {
+       .set_pio_mode           = cs5530_set_pio_mode,
+       .set_dma_mode           = cs5530_set_dma_mode,
+       .udma_filter            = cs5530_udma_filter,
+};
+
+static const struct ide_port_info cs5530_chipset __devinitdata = {
        .name           = "CS5530",
        .init_chipset   = init_chipset_cs5530,
        .init_hwif      = init_hwif_cs5530,
-       .host_flags     = IDE_HFLAG_POST_SET_MODE | IDE_HFLAG_BOOTABLE,
+       .port_ops       = &cs5530_port_ops,
+       .host_flags     = IDE_HFLAG_SERIALIZE |
+                         IDE_HFLAG_POST_SET_MODE,
        .pio_mask       = ATA_PIO4,
+       .mwdma_mask     = ATA_MWDMA2,
+       .udma_mask      = ATA_UDMA2,
 };
 
 static int __devinit cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id)