ide: add struct ide_port_ops (take 2)
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / ide / mips / au1xxx-ide.c
index 0f4bf5d7283598b20b7df331fc62a20085a1c03f..51dddc0f154ef7df310194b0966278d350003efe 100644 (file)
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
-
 #include <linux/init.h>
 #include <linux/ide.h>
-#include <linux/sysdev.h>
-
-#include <linux/dma-mapping.h>
-
-#include "ide-timing.h"
+#include <linux/scatterlist.h>
 
-#include <asm/io.h>
 #include <asm/mach-au1x00/au1xxx.h>
 #include <asm/mach-au1x00/au1xxx_dbdma.h>
-
 #include <asm/mach-au1x00/au1xxx_ide.h>
 
 #define DRV_NAME       "au1200-ide"
@@ -56,6 +49,8 @@
 static _auide_hwif auide_hwif;
 static int dbdma_init_done;
 
+static int auide_ddma_init(_auide_hwif *auide);
+
 #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
 
 void auide_insw(unsigned long port, void *addr, u32 count)
@@ -548,7 +543,16 @@ static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif)
        *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET);
 }
 
+static const struct ide_port_ops au1xxx_port_ops = {
+       .set_pio_mode           = au1xxx_set_pio_mode,
+       .set_dma_mode           = auide_set_dma_mode,
+#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
+       .mdma_filter            = auide_mdma_filter,
+#endif
+};
+
 static const struct ide_port_info au1xxx_port_info = {
+       .port_ops               = &au1xxx_port_ops,
        .host_flags             = IDE_HFLAG_POST_SET_MODE |
                                  IDE_HFLAG_NO_DMA | /* no SFF-style DMA */
                                  IDE_HFLAG_NO_IO_32BIT |
@@ -591,21 +595,24 @@ static int au_ide_probe(struct device *dev)
                goto out;
        }
 
-       if (!request_mem_region (res->start, res->end-res->start, pdev->name)) {
+       if (!request_mem_region(res->start, res->end - res->start + 1,
+                               pdev->name)) {
                pr_debug("%s: request_mem_region failed\n", DRV_NAME);
                ret =  -EBUSY;
                goto out;
        }
 
-       ahwif->regbase = (u32)ioremap(res->start, res->end-res->start);
+       ahwif->regbase = (u32)ioremap(res->start, res->end - res->start + 1);
        if (ahwif->regbase == 0) {
                ret = -ENOMEM;
                goto out;
        }
 
-       /* FIXME:  This might possibly break PCMCIA IDE devices */
-
-       hwif                            = &ide_hwifs[pdev->id];
+       hwif = ide_find_port();
+       if (hwif == NULL) {
+               ret = -ENOENT;
+               goto out;
+       }
 
        memset(&hw, 0, sizeof(hw));
        auide_setup_ports(&hw, ahwif);
@@ -617,9 +624,6 @@ static int au_ide_probe(struct device *dev)
 
        hwif->dev = dev;
 
-       /* hold should be on in all cases */
-       hwif->hold                      = 1;
-
        hwif->mmio  = 1;
 
        /* If the user has selected DDMA assisted copies,
@@ -630,15 +634,8 @@ static int au_ide_probe(struct device *dev)
        hwif->INSW                      = auide_insw;
        hwif->OUTSW                     = auide_outsw;
 #endif
-
-       hwif->set_pio_mode              = &au1xxx_set_pio_mode;
-       hwif->set_dma_mode              = &auide_set_dma_mode;
-
 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
        hwif->dma_timeout               = &auide_dma_timeout;
-
-       hwif->mdma_filter               = &auide_mdma_filter;
-
        hwif->dma_host_set              = &auide_dma_host_set;
        hwif->dma_exec_cmd              = &auide_dma_exec_cmd;
        hwif->dma_start                 = &auide_dma_start;
@@ -677,12 +674,12 @@ static int au_ide_remove(struct device *dev)
        ide_hwif_t *hwif = dev_get_drvdata(dev);
        _auide_hwif *ahwif = &auide_hwif;
 
-       ide_unregister(hwif->index, 0, 0);
+       ide_unregister(hwif->index);
 
        iounmap((void *)ahwif->regbase);
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       release_mem_region(res->start, res->end - res->start);
+       release_mem_region(res->start, res->end - res->start + 1);
 
        return 0;
 }