linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / pci / hotplug / cpqphp_core.c
index 1fc2599..b3659ff 100644 (file)
@@ -29,6 +29,7 @@
  *
  */
 
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
@@ -346,22 +347,26 @@ static int ctrl_slot_setup(struct controller *ctrl,
        slot_number = ctrl->first_slot;
 
        while (number_of_slots) {
-               slot = kzalloc(sizeof(*slot), GFP_KERNEL);
+               slot = kmalloc(sizeof(*slot), GFP_KERNEL);
                if (!slot)
                        goto error;
 
-               slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)),
+               memset(slot, 0, sizeof(struct slot));
+               slot->hotplug_slot = kmalloc(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 =
-                               kzalloc(sizeof(*(hotplug_slot->info)),
+                               kmalloc(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)
@@ -594,7 +599,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
-       mutex_lock(&ctrl->crit_sect);
+       down(&ctrl->crit_sect);
 
        if (status == 1) {
                amber_LED_on (ctrl, hp_slot);
@@ -602,7 +607,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
                amber_LED_off (ctrl, hp_slot);
        } else {
                // Done with exclusive hardware access
-               mutex_unlock(&ctrl->crit_sect);
+               up(&ctrl->crit_sect);
                return(1);
        }
 
@@ -612,7 +617,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
        wait_for_ctrl_irq (ctrl);
 
        // Done with exclusive hardware access
-       mutex_unlock(&ctrl->crit_sect);
+       up(&ctrl->crit_sect);
 
        return(0);
 }
@@ -849,12 +854,13 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                        goto err_disable_device;
                }
 
-               ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL);
+               ctrl = (struct controller *) kmalloc(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) {
@@ -1078,7 +1084,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);
 
-       mutex_init(&ctrl->crit_sect);
+       init_MUTEX(&ctrl->crit_sect);
        init_waitqueue_head(&ctrl->queue);
 
        /* initialize our threads if they haven't already been started up */
@@ -1088,8 +1094,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
        
        dbg("pdev = %p\n", pdev);
-       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));
+       dbg("pci resource start %lx\n", pci_resource_start(pdev, 0));
+       dbg("pci resource len %lx\n", pci_resource_len(pdev, 0));
 
        if (!request_mem_region(pci_resource_start(pdev, 0),
                                pci_resource_len(pdev, 0), MY_NAME)) {
@@ -1101,9 +1107,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 %llx @ %llx\n",
-                   (unsigned long long)pci_resource_len(pdev, 0),
-                   (unsigned long long)pci_resource_start(pdev, 0));
+               err("cannot remap MMIO region %lx @ %lx\n",
+                               pci_resource_len(pdev, 0),
+                               pci_resource_start(pdev, 0));
                rc = -ENODEV;
                goto err_free_mem_region;
        }
@@ -1188,7 +1194,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,
-                       IRQF_SHARED, MY_NAME, ctrl)) {
+                       SA_SHIRQ, MY_NAME, ctrl)) {
                err("Can't get irq %d for the hotplug pci controller\n",
                        ctrl->interrupt);
                rc = -ENODEV;
@@ -1217,7 +1223,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
-       mutex_lock(&ctrl->crit_sect);
+       down(&ctrl->crit_sect);
 
        num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F;
 
@@ -1264,12 +1270,12 @@ 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");
-               mutex_unlock(&ctrl->crit_sect);
+               up(&ctrl->crit_sect);
                goto err_free_irq;
        }
 
        // Done with exclusive hardware access
-       mutex_unlock(&ctrl->crit_sect);
+       up(&ctrl->crit_sect);
 
        cpqhp_create_debugfs_files(ctrl);