diff options
author | Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> | 2006-01-25 20:02:41 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-23 17:35:11 -0500 |
commit | 57c95c0d1c9ec83877dfea2f62bebf31059bc93c (patch) | |
tree | 864e89551bb003665192973b5d3c6831cc478f95 /drivers | |
parent | 287588b3537d0ce56a83f54d0e6ffcd60e54b569 (diff) |
[PATCH] shpchp - replace kmalloc() with kzalloc() and cleanup arg of sizeof()
This patch replaces kmalloc() and memset() pair with kzalloc() and
cleans up the arg of sizeof() in SHPCHP driver.
Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/hotplug/shpchp_core.c | 15 | ||||
-rw-r--r-- | drivers/pci/hotplug/shpchp_hpc.c | 4 |
2 files changed, 6 insertions, 13 deletions
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index 0dd0642e691b..08be8c1f5dcc 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c | |||
@@ -117,22 +117,18 @@ static int init_slots(struct controller *ctrl) | |||
117 | u32 sun; | 117 | u32 sun; |
118 | 118 | ||
119 | for (i = 0; i < ctrl->num_slots; i++) { | 119 | for (i = 0; i < ctrl->num_slots; i++) { |
120 | slot = kmalloc(sizeof(struct slot), GFP_KERNEL); | 120 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
121 | if (!slot) | 121 | if (!slot) |
122 | goto error; | 122 | goto error; |
123 | memset(slot, 0, sizeof(struct slot)); | ||
124 | 123 | ||
125 | hotplug_slot = kmalloc(sizeof(struct hotplug_slot), | 124 | hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); |
126 | GFP_KERNEL); | ||
127 | if (!hotplug_slot) | 125 | if (!hotplug_slot) |
128 | goto error_slot; | 126 | goto error_slot; |
129 | memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); | ||
130 | slot->hotplug_slot = hotplug_slot; | 127 | slot->hotplug_slot = hotplug_slot; |
131 | 128 | ||
132 | info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); | 129 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
133 | if (!info) | 130 | if (!info) |
134 | goto error_hpslot; | 131 | goto error_hpslot; |
135 | memset(info, 0, sizeof (struct hotplug_slot_info)); | ||
136 | hotplug_slot->info = info; | 132 | hotplug_slot->info = info; |
137 | 133 | ||
138 | name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | 134 | name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); |
@@ -383,12 +379,11 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
383 | if (!is_shpc_capable(pdev)) | 379 | if (!is_shpc_capable(pdev)) |
384 | return -ENODEV; | 380 | return -ENODEV; |
385 | 381 | ||
386 | ctrl = kmalloc(sizeof(struct controller), GFP_KERNEL); | 382 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); |
387 | if (!ctrl) { | 383 | if (!ctrl) { |
388 | err("%s : out of memory\n", __FUNCTION__); | 384 | err("%s : out of memory\n", __FUNCTION__); |
389 | goto err_out_none; | 385 | goto err_out_none; |
390 | } | 386 | } |
391 | memset(ctrl, 0, sizeof(struct controller)); | ||
392 | INIT_LIST_HEAD(&ctrl->slot_list); | 387 | INIT_LIST_HEAD(&ctrl->slot_list); |
393 | 388 | ||
394 | rc = shpc_init(ctrl, pdev); | 389 | rc = shpc_init(ctrl, pdev); |
@@ -400,7 +395,7 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
400 | 395 | ||
401 | pci_set_drvdata(pdev, ctrl); | 396 | pci_set_drvdata(pdev, ctrl); |
402 | 397 | ||
403 | ctrl->pci_bus = kmalloc(sizeof (*ctrl->pci_bus), GFP_KERNEL); | 398 | ctrl->pci_bus = kmalloc(sizeof(*ctrl->pci_bus), GFP_KERNEL); |
404 | if (!ctrl->pci_bus) { | 399 | if (!ctrl->pci_bus) { |
405 | err("out of memory\n"); | 400 | err("out of memory\n"); |
406 | rc = -ENOMEM; | 401 | rc = -ENOMEM; |
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index c32a1b16704f..1a6b5448f81d 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c | |||
@@ -1390,15 +1390,13 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev) | |||
1390 | ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ | 1390 | ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ |
1391 | 1391 | ||
1392 | spin_lock_init(&list_lock); | 1392 | spin_lock_init(&list_lock); |
1393 | php_ctlr = (struct php_ctlr_state_s *) kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL); | 1393 | php_ctlr = kzalloc(sizeof(*php_ctlr), GFP_KERNEL); |
1394 | 1394 | ||
1395 | if (!php_ctlr) { /* allocate controller state data */ | 1395 | if (!php_ctlr) { /* allocate controller state data */ |
1396 | err("%s: HPC controller memory allocation error!\n", __FUNCTION__); | 1396 | err("%s: HPC controller memory allocation error!\n", __FUNCTION__); |
1397 | goto abort; | 1397 | goto abort; |
1398 | } | 1398 | } |
1399 | 1399 | ||
1400 | memset(php_ctlr, 0, sizeof(struct php_ctlr_state_s)); | ||
1401 | |||
1402 | php_ctlr->pci_dev = pdev; /* save pci_dev in context */ | 1400 | php_ctlr->pci_dev = pdev; /* save pci_dev in context */ |
1403 | 1401 | ||
1404 | if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device == | 1402 | if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device == |