fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / pci / hotplug / cpcihp_zt5550.c
index cb54fa8..1c12e91 100644 (file)
  * Send feedback to <scottm@somanetworks.com>
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/pci.h>
+#include <linux/interrupt.h>
+#include <linux/signal.h>      /* IRQF_SHARED */
 #include "cpci_hotplug.h"
 #include "cpcihp_zt5550.h"
 
@@ -69,39 +70,49 @@ static struct pci_bus *bus0;
 static struct pci_dev *hc_dev;
 
 /* Host controller register addresses */
-static void *hc_registers;
-static void *csr_hc_index;
-static void *csr_hc_data;
-static void *csr_int_status;
-static void *csr_int_mask;
+static void __iomem *hc_registers;
+static void __iomem *csr_hc_index;
+static void __iomem *csr_hc_data;
+static void __iomem *csr_int_status;
+static void __iomem *csr_int_mask;
 
 
 static int zt5550_hc_config(struct pci_dev *pdev)
 {
+       int ret;
+
        /* Since we know that no boards exist with two HC chips, treat it as an error */
        if(hc_dev) {
                err("too many host controller devices?");
                return -EBUSY;
        }
+
+       ret = pci_enable_device(pdev);
+       if(ret) {
+               err("cannot enable %s\n", pci_name(pdev));
+               return ret;
+       }
+
        hc_dev = pdev;
        dbg("hc_dev = %p", hc_dev);
-       dbg("pci resource start %lx", pci_resource_start(hc_dev, 1));
-       dbg("pci resource len %lx", pci_resource_len(hc_dev, 1));
+       dbg("pci resource start %llx", (unsigned long long)pci_resource_start(hc_dev, 1));
+       dbg("pci resource len %llx", (unsigned long long)pci_resource_len(hc_dev, 1));
 
        if(!request_mem_region(pci_resource_start(hc_dev, 1),
                                pci_resource_len(hc_dev, 1), MY_NAME)) {
                err("cannot reserve MMIO region");
-               return -ENOMEM;
+               ret = -ENOMEM;
+               goto exit_disable_device;
        }
 
        hc_registers =
            ioremap(pci_resource_start(hc_dev, 1), pci_resource_len(hc_dev, 1));
        if(!hc_registers) {
-               err("cannot remap MMIO region %lx @ %lx",
-                   pci_resource_len(hc_dev, 1), pci_resource_start(hc_dev, 1));
-               release_mem_region(pci_resource_start(hc_dev, 1),
-                                  pci_resource_len(hc_dev, 1));
-               return -ENODEV;
+               err("cannot remap MMIO region %llx @ %llx",
+                       (unsigned long long)pci_resource_len(hc_dev, 1),
+                       (unsigned long long)pci_resource_start(hc_dev, 1));
+               ret = -ENODEV;
+               goto exit_release_region;
        }
 
        csr_hc_index = hc_registers + CSR_HCINDEX;
@@ -124,6 +135,13 @@ static int zt5550_hc_config(struct pci_dev *pdev)
        writeb((u8) ALL_DIRECT_INTS_MASK, csr_int_mask);
        dbg("disabled timer0, timer1 and ENUM interrupts");
        return 0;
+
+exit_release_region:
+       release_mem_region(pci_resource_start(hc_dev, 1),
+                          pci_resource_len(hc_dev, 1));
+exit_disable_device:
+       pci_disable_device(hc_dev);
+       return ret;
 }
 
 static int zt5550_hc_cleanup(void)
@@ -134,6 +152,7 @@ static int zt5550_hc_cleanup(void)
        iounmap(hc_registers);
        release_mem_region(pci_resource_start(hc_dev, 1),
                           pci_resource_len(hc_dev, 1));
+       pci_disable_device(hc_dev);
        return 0;
 }
 
@@ -201,7 +220,7 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
        zt5550_hpc.ops = &zt5550_hpc_ops;
        if(!poll) {
                zt5550_hpc.irq = hc_dev->irq;
-               zt5550_hpc.irq_flags = SA_SHIRQ;
+               zt5550_hpc.irq_flags = IRQF_SHARED;
                zt5550_hpc.dev_id = hc_dev;
 
                zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
@@ -219,12 +238,13 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
        dbg("registered controller");
 
        /* Look for first device matching cPCI bus's bridge vendor and device IDs */
-       if(!(bus0_dev = pci_find_device(PCI_VENDOR_ID_DEC,
+       if(!(bus0_dev = pci_get_device(PCI_VENDOR_ID_DEC,
                                         PCI_DEVICE_ID_DEC_21154, NULL))) {
                status = -ENODEV;
                goto init_register_error;
        }
        bus0 = bus0_dev->subordinate;
+       pci_dev_put(bus0_dev);
 
        status = cpci_hp_register_bus(bus0, 0x0a, 0x0f);
        if(status != 0) {
@@ -282,7 +302,7 @@ static int __init zt5550_init(void)
        if(!r)
                return -EBUSY;
 
-       return pci_module_init(&zt5550_hc_driver);
+       return pci_register_driver(&zt5550_hc_driver);
 }
 
 static void __exit
@@ -298,7 +318,7 @@ module_exit(zt5550_exit);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-module_param(debug, bool, 644);
+module_param(debug, bool, 0644);
 MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
-module_param(poll, bool, 644);
+module_param(poll, bool, 0644);
 MODULE_PARM_DESC(poll, "#ENUM polling mode enabled or not");