linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / pci / hotplug / cpqphp_core.c
index 9bc1deb..b3659ff 100644 (file)
@@ -347,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)
@@ -595,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);
@@ -603,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);
        }
 
@@ -613,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);
 }
@@ -850,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) {
@@ -1079,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 */
@@ -1218,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;
 
@@ -1265,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);