]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pci/hotplug/shpchp_core.c
[PATCH] shpchp: fix oops at driver unload
[linux-2.6-omap-h63xx.git] / drivers / pci / hotplug / shpchp_core.c
index 5d4fc28969d01fb604cf6ab726de75e536c055da..63628e01dd436edefa8e0fe8dda89b503e97f7eb 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 "shpchp.h"
 
 /* Global variables */
@@ -45,7 +39,6 @@ int shpchp_debug;
 int shpchp_poll_mode;
 int shpchp_poll_time;
 struct controller *shpchp_ctrl_list;   /* = NULL */
-struct pci_func *shpchp_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>"
@@ -112,8 +105,6 @@ static int init_slots(struct controller *ctrl)
        u32 slot_number, sun;
        int result = -ENOMEM;
 
-       dbg("%s\n",__FUNCTION__);
-
        number_of_slots = ctrl->num_slots;
        slot_device = ctrl->slot_device_offset;
        slot_number = ctrl->first_slot;
@@ -380,19 +371,12 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
        memset(ctrl, 0, sizeof(struct controller));
 
-       dbg("DRV_thread pid = %d\n", current->pid);
-
-       rc = shpc_init(ctrl, pdev,
-                       (php_intr_callback_t) shpchp_handle_attention_button,
-                       (php_intr_callback_t) shpchp_handle_switch_change,
-                       (php_intr_callback_t) shpchp_handle_presence_change,
-                       (php_intr_callback_t) shpchp_handle_power_fault);
+       rc = shpc_init(ctrl, pdev);
        if (rc) {
                dbg("%s: controller initialization failed\n", SHPC_MODULE_NAME);
                goto err_out_free_ctrl;
        }
 
-       dbg("%s: controller initialization success\n", __FUNCTION__);
        ctrl->pci_dev = pdev;  /* pci_dev of the P2P bridge */
 
        pci_set_drvdata(pdev, ctrl);
@@ -475,7 +459,6 @@ err_out_none:
 
 static int shpc_start_thread(void)
 {
-       int loop;
        int retval = 0;
        
        dbg("Initialize + Start the notification/polling mechanism \n");
@@ -486,31 +469,21 @@ static int shpc_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++) {
-               shpchp_slot_list[loop] = NULL;
-       }
-
        return retval;
 }
 
 static void __exit unload_shpchpd(void)
 {
-       struct pci_func *next;
-       struct pci_func *TempSlot;
-       int loop;
        struct controller *ctrl;
        struct controller *tctrl;
 
        ctrl = shpchp_ctrl_list;
 
        while (ctrl) {
+               shpchp_remove_ctrl_files(ctrl);
                cleanup_slots(ctrl);
 
                kfree (ctrl->pci_bus);
-
-               dbg("%s: calling release_ctlr\n", __FUNCTION__);
                ctrl->hpc_ops->release_ctlr(ctrl);
 
                tctrl = ctrl;
@@ -519,15 +492,6 @@ static void __exit unload_shpchpd(void)
                kfree(tctrl);
        }
 
-       for (loop = 0; loop < 256; loop++) {
-               next = shpchp_slot_list[loop];
-               while (next != NULL) {
-                       TempSlot = next;
-                       next = next->next;
-                       kfree(TempSlot);
-               }
-       }
-
        /* Stop the notification mechanism */
        shpchp_event_stop_thread();
 
@@ -588,7 +552,6 @@ static void __exit shpcd_cleanup(void)
        dbg("unload_shpchpd()\n");
        unload_shpchpd();
 
-       dbg("pci_unregister_driver\n");
        pci_unregister_driver(&shpc_driver);
 
        info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");