[PATCH] shpchp: fix improper mmio mapping
[powerpc.git] / drivers / pci / hotplug / pciehp_core.c
index e20cf8e..8df7048 100644 (file)
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
-#include <linux/proc_fs.h>
-#include <linux/slab.h>
-#include <linux/workqueue.h>
 #include <linux/pci.h>
-#include <linux/init.h>
-#include <asm/uaccess.h>
 #include "pciehp.h"
 #include <linux/interrupt.h>
 
@@ -45,8 +39,8 @@
 int pciehp_debug;
 int pciehp_poll_mode;
 int pciehp_poll_time;
+int pciehp_force;
 struct controller *pciehp_ctrl_list;
-struct pci_func *pciehp_slot_list[256];
 
 #define DRIVER_VERSION "0.4"
 #define DRIVER_AUTHOR  "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>"
@@ -59,9 +53,11 @@ MODULE_LICENSE("GPL");
 module_param(pciehp_debug, bool, 0644);
 module_param(pciehp_poll_mode, bool, 0644);
 module_param(pciehp_poll_time, int, 0644);
+module_param(pciehp_force, bool, 0644);
 MODULE_PARM_DESC(pciehp_debug, "Debugging mode enabled or not");
 MODULE_PARM_DESC(pciehp_poll_mode, "Using polling mechanism for hot-plug events or not");
 MODULE_PARM_DESC(pciehp_poll_time, "Polling mechanism frequency, in seconds");
+MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if _OSC and OSHP are missing");
 
 #define PCIE_MODULE_NAME "pciehp"
 
@@ -113,8 +109,6 @@ static int init_slots(struct controller *ctrl)
        u32 slot_number;
        int result = -ENOMEM;
 
-       dbg("%s\n",__FUNCTION__);
-
        number_of_slots = ctrl->num_slots;
        slot_device = ctrl->slot_device_offset;
        slot_number = ctrl->first_slot;
@@ -369,7 +363,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        u8 value;
        struct pci_dev *pdev;
        
-       dbg("%s: Called by hp_drv\n", __FUNCTION__);
        ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL);
        if (!ctrl) {
                err("%s : out of memory\n", __FUNCTION__);
@@ -377,16 +370,10 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        }
        memset(ctrl, 0, sizeof(struct controller));
 
-       dbg("%s: DRV_thread pid = %d\n", __FUNCTION__, current->pid);
-       
        pdev = dev->port;
        ctrl->pci_dev = pdev;
 
-       rc = pcie_init(ctrl, dev,
-               (php_intr_callback_t) pciehp_handle_attention_button,
-               (php_intr_callback_t) pciehp_handle_switch_change,
-               (php_intr_callback_t) pciehp_handle_presence_change,
-               (php_intr_callback_t) pciehp_handle_power_fault);
+       rc = pcie_init(ctrl, dev);
        if (rc) {
                dbg("%s: controller initialization failed\n", PCIE_MODULE_NAME);
                goto err_out_free_ctrl;
@@ -400,7 +387,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
                rc = -ENOMEM;
                goto err_out_unmap_mmio_region;
        }
-       dbg("%s: ctrl->pci_bus %p\n", __FUNCTION__, ctrl->pci_bus);
        memcpy (ctrl->pci_bus, pdev->bus, sizeof (*ctrl->pci_bus));
        ctrl->bus = pdev->bus->number;  /* ctrl bus */
        ctrl->slot_bus = pdev->subordinate->number;  /* bus controlled by this HPC */
@@ -422,17 +408,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        first_device_num = ctrl->slot_device_offset;
        num_ctlr_slots = ctrl->num_slots; 
 
-       /* Store PCI Config Space for all devices on this bus */
-       dbg("%s: Before calling pciehp_save_config, ctrl->bus %x,ctrl->slot_bus %x\n", 
-               __FUNCTION__,ctrl->bus, ctrl->slot_bus);
-       rc = pciehp_save_config(ctrl, ctrl->slot_bus, num_ctlr_slots, first_device_num);
-       if (rc) {
-               err("%s: unable to save PCI configuration data, error %d\n", __FUNCTION__, rc);
-               goto err_out_free_ctrl_bus;
-       }
-
-       ctrl->add_support = 1;
-       
        /* Setup the slot information structures */
        rc = init_slots(ctrl);
        if (rc) {
@@ -441,7 +416,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        }
 
        t_slot = pciehp_find_slot(ctrl, first_device_num);
-       dbg("%s: t_slot %p\n", __FUNCTION__, t_slot);
 
        /*      Finish setting up the hot plug ctrl device */
        ctrl->next_event = 0;
@@ -458,7 +432,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        down(&ctrl->crit_sect);
 
        t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
-       dbg("%s: adpater value %x\n", __FUNCTION__, value);
        
        if ((POWER_CTRL(ctrl->ctrlcap)) && !value) {
                rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
@@ -491,7 +464,6 @@ err_out_none:
 
 static int pcie_start_thread(void)
 {
-       int loop;
        int retval = 0;
        
        dbg("Initialize + Start the notification/polling mechanism \n");
@@ -502,20 +474,11 @@ static int pcie_start_thread(void)
                return retval;
        }
 
-       dbg("Initialize slot lists\n");
-       /* One slot list for each bus in the system */
-       for (loop = 0; loop < 256; loop++) {
-               pciehp_slot_list[loop] = NULL;
-       }
-
        return retval;
 }
 
 static void __exit unload_pciehpd(void)
 {
-       struct pci_func *next;
-       struct pci_func *TempSlot;
-       int loop;
        struct controller *ctrl;
        struct controller *tctrl;
 
@@ -534,15 +497,6 @@ static void __exit unload_pciehpd(void)
                kfree(tctrl);
        }
 
-       for (loop = 0; loop < 256; loop++) {
-               next = pciehp_slot_list[loop];
-               while (next != NULL) {
-                       TempSlot = next;
-                       next = next->next;
-                       kfree(TempSlot);
-               }
-       }
-
        /* Stop the notification mechanism */
        pciehp_event_stop_thread();
 
@@ -626,7 +580,6 @@ static void __exit pcied_cleanup(void)
        dbg("unload_pciehpd()\n");
        unload_pciehpd();
 
-       dbg("pcie_port_service_unregister\n");
        pcie_port_service_unregister(&hpdriver_portdrv);
 
        info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");