]> err.no Git - linux-2.6/blobdiff - drivers/ide/pci/sc1200.c
Merge branch 'release' of git://lm-sensors.org/kernel/mhoffman/hwmon-2.6
[linux-2.6] / drivers / ide / pci / sc1200.c
index af499a60eb312afdd6d92326fa98915f5566f0d6..8efaed16fea31d5b5f14b65e1716114d3ac20c50 100644 (file)
 #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 <linux/pm.h>
+
 #include <asm/io.h>
-#include <asm/irq.h>
+
+#define DRV_NAME "sc1200"
 
 #define SC1200_REV_A   0x00
 #define SC1200_REV_B1  0x01
@@ -171,7 +167,7 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode)
  *
  *  returns 1 on error, 0 otherwise
  */
-static int sc1200_ide_dma_end (ide_drive_t *drive)
+static int sc1200_dma_end(ide_drive_t *drive)
 {
        ide_hwif_t *hwif = HWIF(drive);
        unsigned long dma_base = hwif->dma_base;
@@ -220,7 +216,7 @@ static void sc1200_set_pio_mode(ide_drive_t *drive, const u8 pio)
                printk("SC1200: %s: changing (U)DMA mode\n", drive->name);
                ide_dma_off_quietly(drive);
                if (ide_set_dma_mode(drive, mode) == 0 && drive->using_dma)
-                       hwif->dma_host_set(drive, 1);
+                       hwif->dma_ops->dma_host_set(drive, 1);
                return;
        }
 
@@ -240,20 +236,10 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state)
         * we only save state when going from full power to less
         */
        if (state.event == PM_EVENT_ON) {
-               struct sc1200_saved_state *ss;
+               struct ide_host *host = pci_get_drvdata(dev);
+               struct sc1200_saved_state *ss = host->host_priv;
                unsigned int r;
 
-               /*
-                * allocate a permanent save area, if not already allocated
-                */
-               ss = (struct sc1200_saved_state *)pci_get_drvdata(dev);
-               if (ss == NULL) {
-                       ss = kmalloc(sizeof(*ss), GFP_KERNEL);
-                       if (ss == NULL)
-                               return -ENOMEM;
-                       pci_set_drvdata(dev, ss);
-               }
-
                /*
                 * save timing registers
                 * (this may be unnecessary if BIOS also does it)
@@ -269,7 +255,8 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state)
 
 static int sc1200_resume (struct pci_dev *dev)
 {
-       struct sc1200_saved_state *ss;
+       struct ide_host *host = pci_get_drvdata(dev);
+       struct sc1200_saved_state *ss = host->host_priv;
        unsigned int r;
        int i;
 
@@ -277,44 +264,41 @@ static int sc1200_resume (struct pci_dev *dev)
        if (i)
                return i;
 
-       ss = (struct sc1200_saved_state *)pci_get_drvdata(dev);
-
        /*
         * restore timing registers
         * (this may be unnecessary if BIOS also does it)
         */
-       if (ss) {
-               for (r = 0; r < 8; r++)
-                       pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]);
-       }
+       for (r = 0; r < 8; r++)
+               pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]);
 
        return 0;
 }
 #endif
 
-/*
- * This gets invoked by the IDE driver once for each channel,
- * and performs channel-specific pre-initialization before drive probing.
- */
-static void __devinit init_hwif_sc1200 (ide_hwif_t *hwif)
-{
-       hwif->set_pio_mode = &sc1200_set_pio_mode;
-       hwif->set_dma_mode = &sc1200_set_dma_mode;
-
-       if (hwif->dma_base == 0)
-               return;
+static const struct ide_port_ops sc1200_port_ops = {
+       .set_pio_mode           = sc1200_set_pio_mode,
+       .set_dma_mode           = sc1200_set_dma_mode,
+       .udma_filter            = sc1200_udma_filter,
+};
 
-       hwif->udma_filter = sc1200_udma_filter;
-       hwif->ide_dma_end   = &sc1200_ide_dma_end;
-}
+static const struct ide_dma_ops sc1200_dma_ops = {
+       .dma_host_set           = ide_dma_host_set,
+       .dma_setup              = ide_dma_setup,
+       .dma_exec_cmd           = ide_dma_exec_cmd,
+       .dma_start              = ide_dma_start,
+       .dma_end                = sc1200_dma_end,
+       .dma_test_irq           = ide_dma_test_irq,
+       .dma_lost_irq           = ide_dma_lost_irq,
+       .dma_timeout            = ide_dma_timeout,
+};
 
 static const struct ide_port_info sc1200_chipset __devinitdata = {
-       .name           = "SC1200",
-       .init_hwif      = init_hwif_sc1200,
+       .name           = DRV_NAME,
+       .port_ops       = &sc1200_port_ops,
+       .dma_ops        = &sc1200_dma_ops,
        .host_flags     = IDE_HFLAG_SERIALIZE |
                          IDE_HFLAG_POST_SET_MODE |
-                         IDE_HFLAG_ABUSE_DMA_MODES |
-                         IDE_HFLAG_BOOTABLE,
+                         IDE_HFLAG_ABUSE_DMA_MODES,
        .pio_mask       = ATA_PIO4,
        .mwdma_mask     = ATA_MWDMA2,
        .udma_mask      = ATA_UDMA2,
@@ -322,7 +306,19 @@ static const struct ide_port_info sc1200_chipset __devinitdata = {
 
 static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-       return ide_setup_pci_device(dev, &sc1200_chipset);
+       struct sc1200_saved_state *ss = NULL;
+       int rc;
+
+#ifdef CONFIG_PM
+       ss = kmalloc(sizeof(*ss), GFP_KERNEL);
+       if (ss == NULL)
+               return -ENOMEM;
+#endif
+       rc = ide_pci_init_one(dev, &sc1200_chipset, ss);
+       if (rc)
+               kfree(ss);
+
+       return rc;
 }
 
 static const struct pci_device_id sc1200_pci_tbl[] = {
@@ -335,6 +331,7 @@ static struct pci_driver driver = {
        .name           = "SC1200_IDE",
        .id_table       = sc1200_pci_tbl,
        .probe          = sc1200_init_one,
+       .remove         = ide_pci_remove,
 #ifdef CONFIG_PM
        .suspend        = sc1200_suspend,
        .resume         = sc1200_resume,
@@ -346,7 +343,13 @@ static int __init sc1200_ide_init(void)
        return ide_pci_register_driver(&driver);
 }
 
+static void __exit sc1200_ide_exit(void)
+{
+       pci_unregister_driver(&driver);
+}
+
 module_init(sc1200_ide_init);
+module_exit(sc1200_ide_exit);
 
 MODULE_AUTHOR("Mark Lord");
 MODULE_DESCRIPTION("PCI driver module for NS SC1200 IDE");