Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[pandora-kernel.git] / drivers / pci / hotplug / cpqphp_core.c
index d364470..1fc2599 100644 (file)
@@ -29,7 +29,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
@@ -347,26 +346,22 @@ static int ctrl_slot_setup(struct controller *ctrl,
        slot_number = ctrl->first_slot;
 
        while (number_of_slots) {
-               slot = kmalloc(sizeof(*slot), GFP_KERNEL);
+               slot = kzalloc(sizeof(*slot), GFP_KERNEL);
                if (!slot)
                        goto error;
 
-               memset(slot, 0, sizeof(struct slot));
-               slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)),
+               slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)),
                                                GFP_KERNEL);
                if (!slot->hotplug_slot)
                        goto error_slot;
                hotplug_slot = slot->hotplug_slot;
-               memset(hotplug_slot, 0, sizeof(struct hotplug_slot));
 
                hotplug_slot->info =
-                               kmalloc(sizeof(*(hotplug_slot->info)),
+                               kzalloc(sizeof(*(hotplug_slot->info)),
                                                        GFP_KERNEL);
                if (!hotplug_slot->info)
                        goto error_hpslot;
                hotplug_slot_info = hotplug_slot->info;
-               memset(hotplug_slot_info, 0,
-                               sizeof(struct hotplug_slot_info));
                hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
 
                if (!hotplug_slot->name)
@@ -479,6 +474,8 @@ static int ctrl_slot_cleanup (struct controller * ctrl)
                old_slot = next_slot;
        }
 
+       cpqhp_remove_debugfs_files(ctrl);
+
        //Free IRQ associated with hot plug device
        free_irq(ctrl->interrupt, ctrl);
        //Unmap the memory
@@ -597,7 +594,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
        hp_slot = func->device - ctrl->slot_device_offset;
 
        // Wait for exclusive access to hardware
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        if (status == 1) {
                amber_LED_on (ctrl, hp_slot);
@@ -605,7 +602,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
                amber_LED_off (ctrl, hp_slot);
        } else {
                // Done with exclusive hardware access
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return(1);
        }
 
@@ -615,7 +612,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
        wait_for_ctrl_irq (ctrl);
 
        // Done with exclusive hardware access
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        return(0);
 }
@@ -852,13 +849,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                        goto err_disable_device;
                }
 
-               ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL);
+               ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL);
                if (!ctrl) {
                        err("%s : out of memory\n", __FUNCTION__);
                        rc = -ENOMEM;
                        goto err_disable_device;
                }
-               memset(ctrl, 0, sizeof(struct controller));
 
                rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid);
                if (rc) {
@@ -1082,7 +1078,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        dbg("bus device function rev: %d %d %d %d\n", ctrl->bus,
                PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), ctrl->rev);
 
-       init_MUTEX(&ctrl->crit_sect);
+       mutex_init(&ctrl->crit_sect);
        init_waitqueue_head(&ctrl->queue);
 
        /* initialize our threads if they haven't already been started up */
@@ -1092,8 +1088,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
        
        dbg("pdev = %p\n", pdev);
-       dbg("pci resource start %lx\n", pci_resource_start(pdev, 0));
-       dbg("pci resource len %lx\n", pci_resource_len(pdev, 0));
+       dbg("pci resource start %llx\n", (unsigned long long)pci_resource_start(pdev, 0));
+       dbg("pci resource len %llx\n", (unsigned long long)pci_resource_len(pdev, 0));
 
        if (!request_mem_region(pci_resource_start(pdev, 0),
                                pci_resource_len(pdev, 0), MY_NAME)) {
@@ -1105,9 +1101,9 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        ctrl->hpc_reg = ioremap(pci_resource_start(pdev, 0),
                                        pci_resource_len(pdev, 0));
        if (!ctrl->hpc_reg) {
-               err("cannot remap MMIO region %lx @ %lx\n",
-                               pci_resource_len(pdev, 0),
-                               pci_resource_start(pdev, 0));
+               err("cannot remap MMIO region %llx @ %llx\n",
+                   (unsigned long long)pci_resource_len(pdev, 0),
+                   (unsigned long long)pci_resource_start(pdev, 0));
                rc = -ENODEV;
                goto err_free_mem_region;
        }
@@ -1192,7 +1188,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        /* set up the interrupt */
        dbg("HPC interrupt = %d \n", ctrl->interrupt);
        if (request_irq(ctrl->interrupt, cpqhp_ctrl_intr,
-                       SA_SHIRQ, MY_NAME, ctrl)) {
+                       IRQF_SHARED, MY_NAME, ctrl)) {
                err("Can't get irq %d for the hotplug pci controller\n",
                        ctrl->interrupt);
                rc = -ENODEV;
@@ -1221,7 +1217,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        // turn off empty slots here unless command line option "ON" set
        // Wait for exclusive access to hardware
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F;
 
@@ -1268,14 +1264,14 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        rc = init_SERR(ctrl);
        if (rc) {
                err("init_SERR failed\n");
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                goto err_free_irq;
        }
 
        // Done with exclusive hardware access
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
-       cpqhp_create_ctrl_files(ctrl);
+       cpqhp_create_debugfs_files(ctrl);
 
        return 0;
 
@@ -1515,6 +1511,7 @@ static int __init cpqhpc_init(void)
        cpqhp_debug = debug;
 
        info (DRIVER_DESC " version: " DRIVER_VERSION "\n");
+       cpqhp_initialize_debugfs();
        result = pci_register_driver(&cpqhpc_driver);
        dbg("pci_register_driver = %d\n", result);
        return result;
@@ -1528,6 +1525,7 @@ static void __exit cpqhpc_cleanup(void)
 
        dbg("pci_unregister_driver\n");
        pci_unregister_driver(&cpqhpc_driver);
+       cpqhp_shutdown_debugfs();
 }