Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[pandora-kernel.git] / drivers / ide / setup-pci.c
index 7a3a12d..34a5e52 100644 (file)
@@ -1,13 +1,14 @@
 /*
  *  Copyright (C) 1998-2000  Andre Hedrick <andre@linux-ide.org>
  *  Copyright (C) 1995-1998  Mark Lord
- *  Copyright (C)      2007  Bartlomiej Zolnierkiewicz
+ *  Copyright (C) 2007-2009  Bartlomiej Zolnierkiewicz
  *
  *  May be copied or modified under the terms of the GNU General Public License
  */
 
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/export.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -301,11 +302,11 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
 }
 
 /**
- *     ide_hw_configure        -       configure a hw_regs_t instance
+ *     ide_hw_configure        -       configure a struct ide_hw instance
  *     @dev: PCI device holding interface
  *     @d: IDE port info
  *     @port: port number
- *     @hw: hw_regs_t instance corresponding to this port
+ *     @hw: struct ide_hw instance corresponding to this port
  *
  *     Perform the initial set up for the hardware interface structure. This
  *     is done per interface port rather than per PCI device. There may be
@@ -315,7 +316,7 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *
  */
 
 static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d,
-                           unsigned int port, hw_regs_t *hw)
+                           unsigned int port, struct ide_hw *hw)
 {
        unsigned long ctl = 0, base = 0;
 
@@ -344,7 +345,6 @@ static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d,
 
        memset(hw, 0, sizeof(*hw));
        hw->dev = &dev->dev;
-       hw->chipset = d->chipset ? d->chipset : ide_pci;
        ide_std_init_ports(hw, base, ctl | 2);
 
        return 0;
@@ -446,8 +446,8 @@ out:
  *     ide_pci_setup_ports     -       configure ports/devices on PCI IDE
  *     @dev: PCI device
  *     @d: IDE port info
- *     @hw: hw_regs_t instances corresponding to this PCI IDE device
- *     @hws: hw_regs_t pointers table to update
+ *     @hw: struct ide_hw instances corresponding to this PCI IDE device
+ *     @hws: struct ide_hw pointers table to update
  *
  *     Scan the interfaces attached to this device and do any
  *     necessary per port setup. Attach the devices and ask the
@@ -459,7 +459,7 @@ out:
  */
 
 void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d,
-                        hw_regs_t *hw, hw_regs_t **hws)
+                        struct ide_hw *hw, struct ide_hw **hws)
 {
        int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port;
        u8 tmp;
@@ -535,61 +535,15 @@ out:
        return ret;
 }
 
-int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d,
-                    void *priv)
-{
-       struct ide_host *host;
-       hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
-       int ret;
-
-       ret = ide_setup_pci_controller(dev, d, 1);
-       if (ret < 0)
-               goto out;
-
-       ide_pci_setup_ports(dev, d, &hw[0], &hws[0]);
-
-       host = ide_host_alloc(d, hws);
-       if (host == NULL) {
-               ret = -ENOMEM;
-               goto out;
-       }
-
-       host->dev[0] = &dev->dev;
-
-       host->host_priv = priv;
-
-       host->irq_flags = IRQF_SHARED;
-
-       pci_set_drvdata(dev, host);
-
-       ret = do_ide_setup_pci_device(dev, d, 1);
-       if (ret < 0)
-               goto out;
-
-       /* fixup IRQ */
-       if (ide_pci_is_in_compatibility_mode(dev)) {
-               hw[0].irq = pci_get_legacy_ide_irq(dev, 0);
-               hw[1].irq = pci_get_legacy_ide_irq(dev, 1);
-       } else
-               hw[1].irq = hw[0].irq = ret;
-
-       ret = ide_host_register(host, d, hws);
-       if (ret)
-               ide_host_free(host);
-out:
-       return ret;
-}
-EXPORT_SYMBOL_GPL(ide_pci_init_one);
-
 int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
                     const struct ide_port_info *d, void *priv)
 {
        struct pci_dev *pdev[] = { dev1, dev2 };
        struct ide_host *host;
-       int ret, i;
-       hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
+       int ret, i, n_ports = dev2 ? 4 : 2;
+       struct ide_hw hw[4], *hws[] = { NULL, NULL, NULL, NULL };
 
-       for (i = 0; i < 2; i++) {
+       for (i = 0; i < n_ports / 2; i++) {
                ret = ide_setup_pci_controller(pdev[i], d, !i);
                if (ret < 0)
                        goto out;
@@ -597,23 +551,24 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
                ide_pci_setup_ports(pdev[i], d, &hw[i*2], &hws[i*2]);
        }
 
-       host = ide_host_alloc(d, hws);
+       host = ide_host_alloc(d, hws, n_ports);
        if (host == NULL) {
                ret = -ENOMEM;
                goto out;
        }
 
        host->dev[0] = &dev1->dev;
-       host->dev[1] = &dev2->dev;
+       if (dev2)
+               host->dev[1] = &dev2->dev;
 
        host->host_priv = priv;
-
        host->irq_flags = IRQF_SHARED;
 
        pci_set_drvdata(pdev[0], host);
-       pci_set_drvdata(pdev[1], host);
+       if (dev2)
+               pci_set_drvdata(pdev[1], host);
 
-       for (i = 0; i < 2; i++) {
+       for (i = 0; i < n_ports / 2; i++) {
                ret = do_ide_setup_pci_device(pdev[i], d, !i);
 
                /*
@@ -639,6 +594,13 @@ out:
 }
 EXPORT_SYMBOL_GPL(ide_pci_init_two);
 
+int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d,
+                    void *priv)
+{
+       return ide_pci_init_two(dev, NULL, d, priv);
+}
+EXPORT_SYMBOL_GPL(ide_pci_init_one);
+
 void ide_pci_remove(struct pci_dev *dev)
 {
        struct ide_host *host = pci_get_drvdata(dev);