diff options
Diffstat (limited to 'drivers/pci/hotplug/cpqphp_core.c')
-rw-r--r-- | drivers/pci/hotplug/cpqphp_core.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index b3659ffccac..9bc1deb8df5 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c | |||
@@ -347,26 +347,22 @@ static int ctrl_slot_setup(struct controller *ctrl, | |||
347 | slot_number = ctrl->first_slot; | 347 | slot_number = ctrl->first_slot; |
348 | 348 | ||
349 | while (number_of_slots) { | 349 | while (number_of_slots) { |
350 | slot = kmalloc(sizeof(*slot), GFP_KERNEL); | 350 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
351 | if (!slot) | 351 | if (!slot) |
352 | goto error; | 352 | goto error; |
353 | 353 | ||
354 | memset(slot, 0, sizeof(struct slot)); | 354 | slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)), |
355 | slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)), | ||
356 | GFP_KERNEL); | 355 | GFP_KERNEL); |
357 | if (!slot->hotplug_slot) | 356 | if (!slot->hotplug_slot) |
358 | goto error_slot; | 357 | goto error_slot; |
359 | hotplug_slot = slot->hotplug_slot; | 358 | hotplug_slot = slot->hotplug_slot; |
360 | memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); | ||
361 | 359 | ||
362 | hotplug_slot->info = | 360 | hotplug_slot->info = |
363 | kmalloc(sizeof(*(hotplug_slot->info)), | 361 | kzalloc(sizeof(*(hotplug_slot->info)), |
364 | GFP_KERNEL); | 362 | GFP_KERNEL); |
365 | if (!hotplug_slot->info) | 363 | if (!hotplug_slot->info) |
366 | goto error_hpslot; | 364 | goto error_hpslot; |
367 | hotplug_slot_info = hotplug_slot->info; | 365 | hotplug_slot_info = hotplug_slot->info; |
368 | memset(hotplug_slot_info, 0, | ||
369 | sizeof(struct hotplug_slot_info)); | ||
370 | hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | 366 | hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); |
371 | 367 | ||
372 | if (!hotplug_slot->name) | 368 | if (!hotplug_slot->name) |
@@ -599,7 +595,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
599 | hp_slot = func->device - ctrl->slot_device_offset; | 595 | hp_slot = func->device - ctrl->slot_device_offset; |
600 | 596 | ||
601 | // Wait for exclusive access to hardware | 597 | // Wait for exclusive access to hardware |
602 | down(&ctrl->crit_sect); | 598 | mutex_lock(&ctrl->crit_sect); |
603 | 599 | ||
604 | if (status == 1) { | 600 | if (status == 1) { |
605 | amber_LED_on (ctrl, hp_slot); | 601 | amber_LED_on (ctrl, hp_slot); |
@@ -607,7 +603,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
607 | amber_LED_off (ctrl, hp_slot); | 603 | amber_LED_off (ctrl, hp_slot); |
608 | } else { | 604 | } else { |
609 | // Done with exclusive hardware access | 605 | // Done with exclusive hardware access |
610 | up(&ctrl->crit_sect); | 606 | mutex_unlock(&ctrl->crit_sect); |
611 | return(1); | 607 | return(1); |
612 | } | 608 | } |
613 | 609 | ||
@@ -617,7 +613,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func, | |||
617 | wait_for_ctrl_irq (ctrl); | 613 | wait_for_ctrl_irq (ctrl); |
618 | 614 | ||
619 | // Done with exclusive hardware access | 615 | // Done with exclusive hardware access |
620 | up(&ctrl->crit_sect); | 616 | mutex_unlock(&ctrl->crit_sect); |
621 | 617 | ||
622 | return(0); | 618 | return(0); |
623 | } | 619 | } |
@@ -854,13 +850,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
854 | goto err_disable_device; | 850 | goto err_disable_device; |
855 | } | 851 | } |
856 | 852 | ||
857 | ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL); | 853 | ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL); |
858 | if (!ctrl) { | 854 | if (!ctrl) { |
859 | err("%s : out of memory\n", __FUNCTION__); | 855 | err("%s : out of memory\n", __FUNCTION__); |
860 | rc = -ENOMEM; | 856 | rc = -ENOMEM; |
861 | goto err_disable_device; | 857 | goto err_disable_device; |
862 | } | 858 | } |
863 | memset(ctrl, 0, sizeof(struct controller)); | ||
864 | 859 | ||
865 | rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid); | 860 | rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid); |
866 | if (rc) { | 861 | if (rc) { |
@@ -1084,7 +1079,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1084 | dbg("bus device function rev: %d %d %d %d\n", ctrl->bus, | 1079 | dbg("bus device function rev: %d %d %d %d\n", ctrl->bus, |
1085 | PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), ctrl->rev); | 1080 | PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), ctrl->rev); |
1086 | 1081 | ||
1087 | init_MUTEX(&ctrl->crit_sect); | 1082 | mutex_init(&ctrl->crit_sect); |
1088 | init_waitqueue_head(&ctrl->queue); | 1083 | init_waitqueue_head(&ctrl->queue); |
1089 | 1084 | ||
1090 | /* initialize our threads if they haven't already been started up */ | 1085 | /* initialize our threads if they haven't already been started up */ |
@@ -1223,7 +1218,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1223 | 1218 | ||
1224 | // turn off empty slots here unless command line option "ON" set | 1219 | // turn off empty slots here unless command line option "ON" set |
1225 | // Wait for exclusive access to hardware | 1220 | // Wait for exclusive access to hardware |
1226 | down(&ctrl->crit_sect); | 1221 | mutex_lock(&ctrl->crit_sect); |
1227 | 1222 | ||
1228 | num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F; | 1223 | num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F; |
1229 | 1224 | ||
@@ -1270,12 +1265,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1270 | rc = init_SERR(ctrl); | 1265 | rc = init_SERR(ctrl); |
1271 | if (rc) { | 1266 | if (rc) { |
1272 | err("init_SERR failed\n"); | 1267 | err("init_SERR failed\n"); |
1273 | up(&ctrl->crit_sect); | 1268 | mutex_unlock(&ctrl->crit_sect); |
1274 | goto err_free_irq; | 1269 | goto err_free_irq; |
1275 | } | 1270 | } |
1276 | 1271 | ||
1277 | // Done with exclusive hardware access | 1272 | // Done with exclusive hardware access |
1278 | up(&ctrl->crit_sect); | 1273 | mutex_unlock(&ctrl->crit_sect); |
1279 | 1274 | ||
1280 | cpqhp_create_debugfs_files(ctrl); | 1275 | cpqhp_create_debugfs_files(ctrl); |
1281 | 1276 | ||