]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/pci/hotplug/shpchp_core.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
[mv-sheeva.git] / drivers / pci / hotplug / shpchp_core.c
index 5de659d23d1ac5421858660e4458b3a15a3f3959..a14e7de1984621cd9281751df06cc0624fee5d87 100644 (file)
@@ -39,7 +39,6 @@
 int shpchp_debug;
 int shpchp_poll_mode;
 int shpchp_poll_time;
-LIST_HEAD(shpchp_ctrl_list);
 struct workqueue_struct *shpchp_wq;
 
 #define DRIVER_VERSION "0.4"
@@ -105,6 +104,23 @@ static void make_slot_name(struct slot *slot)
                 slot->bus, slot->number);
 }
 
+
+
+
+static int
+shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun,
+                               u8 busnum, u8 devnum)
+{
+       int offset = devnum - ctrl->slot_device_offset;
+
+       dbg("%s: ctrl->slot_num_inc %d, offset %d\n", __FUNCTION__,
+                       ctrl->slot_num_inc, offset);
+       *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc *offset);
+       return 0;
+}
+
+
+
 static int init_slots(struct controller *ctrl)
 {
        struct slot *slot;
@@ -136,13 +152,14 @@ static int init_slots(struct controller *ctrl)
                slot->bus = ctrl->slot_bus;
                slot->device = ctrl->slot_device_offset + i;
                slot->hpc_ops = ctrl->hpc_ops;
+               mutex_init(&slot->lock);
 
                if (shpchprm_get_physical_slot_number(ctrl, &sun,
                                                      slot->bus, slot->device))
                        goto error_info;
 
                slot->number = sun;
-               INIT_WORK(&slot->work, shpchp_pushbutton_thread, slot);
+               INIT_WORK(&slot->work, queue_pushbutton_work, slot);
 
                /* register this slot with the hotplug pci core */
                hotplug_slot->private = slot;
@@ -188,6 +205,7 @@ void cleanup_slots(struct controller *ctrl)
                slot = list_entry(tmp, struct slot, slot_list);
                list_del(&slot->slot_list);
                cancel_delayed_work(&slot->work);
+               flush_scheduled_work();
                flush_workqueue(shpchp_wq);
                pci_hp_deregister(slot->hotplug_slot);
        }
@@ -244,7 +262,7 @@ static int enable_slot (struct hotplug_slot *hotplug_slot)
 
        dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
 
-       return shpchp_enable_slot(slot);
+       return shpchp_sysfs_enable_slot(slot);
 }
 
 static int disable_slot (struct hotplug_slot *hotplug_slot)
@@ -253,7 +271,7 @@ static int disable_slot (struct hotplug_slot *hotplug_slot)
 
        dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
 
-       return shpchp_disable_slot(slot);
+       return shpchp_sysfs_disable_slot(slot);
 }
 
 static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value)
@@ -431,8 +449,6 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                ctrl->speed = PCI_SPEED_33MHz;
        }
 
-       list_add(&ctrl->ctrl_list, &shpchp_ctrl_list);
-
        shpchp_create_ctrl_files(ctrl);
 
        return 0;
@@ -445,20 +461,13 @@ err_out_none:
        return -ENODEV;
 }
 
-static void __exit unload_shpchpd(void)
+static void shpc_remove(struct pci_dev *dev)
 {
-       struct list_head *tmp;
-       struct list_head *next;
-       struct controller *ctrl;
+       struct controller *ctrl = pci_get_drvdata(dev);
 
-       list_for_each_safe(tmp, next, &shpchp_ctrl_list) {
-               ctrl = list_entry(tmp, struct controller, ctrl_list);
-               shpchp_remove_ctrl_files(ctrl);
-               ctrl->hpc_ops->release_ctlr(ctrl);
-               kfree(ctrl);
-       }
-
-       destroy_workqueue(shpchp_wq);
+       shpchp_remove_ctrl_files(ctrl);
+       ctrl->hpc_ops->release_ctlr(ctrl);
+       kfree(ctrl);
 }
 
 static struct pci_device_id shpcd_pci_tbl[] = {
@@ -471,7 +480,7 @@ static struct pci_driver shpc_driver = {
        .name =         SHPC_MODULE_NAME,
        .id_table =     shpcd_pci_tbl,
        .probe =        shpc_probe,
-       /* remove:      shpc_remove_one, */
+       .remove =       shpc_remove,
 };
 
 static int __init shpcd_init(void)
@@ -482,26 +491,16 @@ static int __init shpcd_init(void)
        shpchp_poll_mode = 1;
 #endif
 
-       shpchp_wq = create_singlethread_workqueue("shpchpd");
-       if (!shpchp_wq)
-               return -ENOMEM;
-
        retval = pci_register_driver(&shpc_driver);
        dbg("%s: pci_register_driver = %d\n", __FUNCTION__, retval);
        info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
-       if (retval) {
-               destroy_workqueue(shpchp_wq);
-       }
        return retval;
 }
 
 static void __exit shpcd_cleanup(void)
 {
        dbg("unload_shpchpd()\n");
-       unload_shpchpd();
-
        pci_unregister_driver(&shpc_driver);
-
        info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
 }