]> err.no Git - linux-2.6/blobdiff - drivers/ide/ide-probe.c
au1xxx-ide: use ->init_dma method
[linux-2.6] / drivers / ide / ide-probe.c
index ba16ade15c8cc3c32df2cb02ce02aa60b5876099..e0316869eb6fc2a6996b915f38dba30fb2d6795b 100644 (file)
@@ -644,7 +644,7 @@ static int ide_register_port(ide_hwif_t *hwif)
        ret = device_register(&hwif->gendev);
        if (ret < 0) {
                printk(KERN_WARNING "IDE: %s: device_register error: %d\n",
-                       __FUNCTION__, ret);
+                       __func__, ret);
                goto out;
        }
 
@@ -1356,9 +1356,6 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
        if (d->init_iops)
                d->init_iops(hwif);
 
-       if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0)
-               ide_hwif_setup_dma(hwif, d);
-
        if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) ||
            (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS))
                hwif->irq = port ? 15 : 14;
@@ -1377,9 +1374,21 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
        hwif->mwdma_mask = d->mwdma_mask;
        hwif->ultra_mask = d->udma_mask;
 
-       /* reset DMA masks only for SFF-style DMA controllers */
-       if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0 && hwif->dma_base == 0)
-               hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask = 0;
+       if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) {
+               int rc;
+
+               if (d->init_dma)
+                       rc = d->init_dma(hwif, d);
+               else
+                       rc = ide_hwif_setup_dma(hwif, d);
+
+               if (rc < 0) {
+                       printk(KERN_INFO "%s: DMA disabled\n", hwif->name);
+                       hwif->swdma_mask = 0;
+                       hwif->mwdma_mask = 0;
+                       hwif->ultra_mask = 0;
+               }
+       }
 
        if (d->host_flags & IDE_HFLAG_RQSIZE_256)
                hwif->rqsize = 256;
@@ -1530,25 +1539,15 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
 
                hwif = &ide_hwifs[idx[i]];
 
-               if ((hwif->chipset != ide_4drives || !hwif->mate ||
-                    !hwif->mate->present) && ide_hwif_request_regions(hwif)) {
-                       printk(KERN_ERR "%s: ports already in use, "
-                                       "skipping probe\n", hwif->name);
-                       continue;
-               }
-
-               if (ide_probe_port(hwif) < 0) {
-                       ide_hwif_release_regions(hwif);
-                       continue;
-               }
-
-               hwif->present = 1;
+               if (ide_probe_port(hwif) == 0)
+                       hwif->present = 1;
 
                if (hwif->chipset != ide_4drives || !hwif->mate ||
                    !hwif->mate->present)
                        ide_register_port(hwif);
 
-               ide_port_tune_devices(hwif);
+               if (hwif->present)
+                       ide_port_tune_devices(hwif);
        }
 
        for (i = 0; i < MAX_HWIFS; i++) {
@@ -1557,9 +1556,6 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
 
                hwif = &ide_hwifs[idx[i]];
 
-               if (!hwif->present)
-                       continue;
-
                if (hwif_init(hwif) == 0) {
                        printk(KERN_INFO "%s: failed to initialize IDE "
                                         "interface\n", hwif->name);
@@ -1568,10 +1564,13 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
                        continue;
                }
 
-               ide_port_setup_devices(hwif);
+               if (hwif->present)
+                       ide_port_setup_devices(hwif);
 
                ide_acpi_init(hwif);
-               ide_acpi_port_init_devices(hwif);
+
+               if (hwif->present)
+                       ide_acpi_port_init_devices(hwif);
        }
 
        for (i = 0; i < MAX_HWIFS; i++) {
@@ -1580,11 +1579,11 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
 
                hwif = &ide_hwifs[idx[i]];
 
-               if (hwif->present) {
-                       if (hwif->chipset == ide_unknown)
-                               hwif->chipset = ide_generic;
+               if (hwif->chipset == ide_unknown)
+                       hwif->chipset = ide_generic;
+
+               if (hwif->present)
                        hwif_register_devices(hwif);
-               }
        }
 
        for (i = 0; i < MAX_HWIFS; i++) {
@@ -1593,11 +1592,11 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
 
                hwif = &ide_hwifs[idx[i]];
 
-               if (hwif->present) {
-                       ide_sysfs_register_port(hwif);
-                       ide_proc_register_port(hwif);
+               ide_sysfs_register_port(hwif);
+               ide_proc_register_port(hwif);
+
+               if (hwif->present)
                        ide_proc_port_register_devices(hwif);
-               }
        }
 
        return rc;
@@ -1634,40 +1633,63 @@ void ide_port_scan(ide_hwif_t *hwif)
 }
 EXPORT_SYMBOL_GPL(ide_port_scan);
 
-int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
+static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no,
+                               const struct ide_port_info *d,
+                               unsigned long config)
 {
-       ide_hwif_t *hwif, *mate;
-       u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
-       hw_regs_t hw[2];
+       ide_hwif_t *hwif;
+       unsigned long base, ctl;
+       int irq;
 
-       memset(&hw, 0, sizeof(hw));
+       if (port_no == 0) {
+               base = 0x1f0;
+               ctl  = 0x3f6;
+               irq  = 14;
+       } else {
+               base = 0x170;
+               ctl  = 0x376;
+               irq  = 15;
+       }
 
-       ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
-       hw[0].irq = 14;
+       if (!request_region(base, 8, d->name)) {
+               printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
+                               d->name, base, base + 7);
+               return;
+       }
 
-       ide_std_init_ports(&hw[1], 0x170, 0x376);
-       hw[1].irq = 15;
+       if (!request_region(ctl, 1, d->name)) {
+               printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n",
+                               d->name, ctl);
+               release_region(base, 8);
+               return;
+       }
+
+       ide_std_init_ports(hw, base, ctl);
+       hw->irq = irq;
 
        hwif = ide_find_port_slot(d);
        if (hwif) {
-               u8 j = (d->host_flags & IDE_HFLAG_QD_2ND_PORT) ? 1 : 0;
-
-               ide_init_port_hw(hwif, &hw[j]);
+               ide_init_port_hw(hwif, hw);
                if (config)
                        hwif->config_data = config;
-               idx[j] = hwif->index;
+               idx[port_no] = hwif->index;
        }
+}
 
-       if (hwif == NULL && (d->host_flags & IDE_HFLAG_SINGLE))
-               return -ENOENT;
+int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
+{
+       u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
+       hw_regs_t hw[2];
 
-       mate = ide_find_port_slot(d);
-       if (mate) {
-               ide_init_port_hw(mate, &hw[1]);
-               if (config)
-                       mate->config_data = config;
-               idx[1] = mate->index;
-       }
+       memset(&hw, 0, sizeof(hw));
+
+       if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0)
+               ide_legacy_init_one(idx, &hw[0], 0, d, config);
+       ide_legacy_init_one(idx, &hw[1], 1, d, config);
+
+       if (idx[0] == 0xff && idx[1] == 0xff &&
+           (d->host_flags & IDE_HFLAG_SINGLE))
+               return -ENOENT;
 
        ide_device_add(idx, d);