Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] PCI: kzalloc() conversion in drivers/pci

this patch converts drivers/pci to kzalloc usage.
Compile tested with allyes config.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Eric Sesterhenn and committed by
Greg Kroah-Hartman
f5afe806 7c8f25da

+75 -169
+4 -10
drivers/pci/hotplug/acpiphp_glue.c
··· 143 143 device = (adr >> 16) & 0xffff; 144 144 function = adr & 0xffff; 145 145 146 - newfunc = kmalloc(sizeof(struct acpiphp_func), GFP_KERNEL); 146 + newfunc = kzalloc(sizeof(struct acpiphp_func), GFP_KERNEL); 147 147 if (!newfunc) 148 148 return AE_NO_MEMORY; 149 - memset(newfunc, 0, sizeof(struct acpiphp_func)); 150 149 151 150 INIT_LIST_HEAD(&newfunc->sibling); 152 151 newfunc->handle = handle; ··· 188 189 } 189 190 190 191 if (!slot) { 191 - slot = kmalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); 192 + slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); 192 193 if (!slot) { 193 194 kfree(newfunc); 194 195 return AE_NO_MEMORY; 195 196 } 196 197 197 - memset(slot, 0, sizeof(struct acpiphp_slot)); 198 198 slot->bridge = bridge; 199 199 slot->device = device; 200 200 slot->sun = sun; ··· 374 376 { 375 377 struct acpiphp_bridge *bridge; 376 378 377 - bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); 379 + bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); 378 380 if (bridge == NULL) 379 381 return; 380 - 381 - memset(bridge, 0, sizeof(struct acpiphp_bridge)); 382 382 383 383 bridge->type = BRIDGE_TYPE_HOST; 384 384 bridge->handle = handle; ··· 394 398 { 395 399 struct acpiphp_bridge *bridge; 396 400 397 - bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); 401 + bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); 398 402 if (bridge == NULL) { 399 403 err("out of memory\n"); 400 404 return; 401 405 } 402 - 403 - memset(bridge, 0, sizeof(struct acpiphp_bridge)); 404 406 405 407 bridge->type = BRIDGE_TYPE_P2P; 406 408 bridge->handle = handle;
+3 -6
drivers/pci/hotplug/cpci_hotplug_core.c
··· 248 248 * with the pci_hotplug subsystem. 249 249 */ 250 250 for (i = first; i <= last; ++i) { 251 - slot = kmalloc(sizeof (struct slot), GFP_KERNEL); 251 + slot = kzalloc(sizeof (struct slot), GFP_KERNEL); 252 252 if (!slot) 253 253 goto error; 254 - memset(slot, 0, sizeof (struct slot)); 255 254 256 255 hotplug_slot = 257 - kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL); 256 + kzalloc(sizeof (struct hotplug_slot), GFP_KERNEL); 258 257 if (!hotplug_slot) 259 258 goto error_slot; 260 - memset(hotplug_slot, 0, sizeof (struct hotplug_slot)); 261 259 slot->hotplug_slot = hotplug_slot; 262 260 263 - info = kmalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL); 261 + info = kzalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL); 264 262 if (!info) 265 263 goto error_hpslot; 266 - memset(info, 0, sizeof (struct hotplug_slot_info)); 267 264 hotplug_slot->info = info; 268 265 269 266 name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
+4 -9
drivers/pci/hotplug/cpqphp_core.c
··· 347 347 slot_number = ctrl->first_slot; 348 348 349 349 while (number_of_slots) { 350 - slot = kmalloc(sizeof(*slot), GFP_KERNEL); 350 + slot = kzalloc(sizeof(*slot), GFP_KERNEL); 351 351 if (!slot) 352 352 goto error; 353 353 354 - memset(slot, 0, sizeof(struct slot)); 355 - slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)), 354 + slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)), 356 355 GFP_KERNEL); 357 356 if (!slot->hotplug_slot) 358 357 goto error_slot; 359 358 hotplug_slot = slot->hotplug_slot; 360 - memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); 361 359 362 360 hotplug_slot->info = 363 - kmalloc(sizeof(*(hotplug_slot->info)), 361 + kzalloc(sizeof(*(hotplug_slot->info)), 364 362 GFP_KERNEL); 365 363 if (!hotplug_slot->info) 366 364 goto error_hpslot; 367 365 hotplug_slot_info = hotplug_slot->info; 368 - memset(hotplug_slot_info, 0, 369 - sizeof(struct hotplug_slot_info)); 370 366 hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); 371 367 372 368 if (!hotplug_slot->name) ··· 850 854 goto err_disable_device; 851 855 } 852 856 853 - ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL); 857 + ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL); 854 858 if (!ctrl) { 855 859 err("%s : out of memory\n", __FUNCTION__); 856 860 rc = -ENOMEM; 857 861 goto err_disable_device; 858 862 } 859 - memset(ctrl, 0, sizeof(struct controller)); 860 863 861 864 rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid); 862 865 if (rc) {
+3 -6
drivers/pci/hotplug/fakephp.c
··· 95 95 struct hotplug_slot *slot; 96 96 int retval = -ENOMEM; 97 97 98 - slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL); 98 + slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); 99 99 if (!slot) 100 100 goto error; 101 - memset(slot, 0, sizeof(*slot)); 102 101 103 - slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); 102 + slot->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); 104 103 if (!slot->info) 105 104 goto error_slot; 106 - memset(slot->info, 0, sizeof(struct hotplug_slot_info)); 107 105 108 106 slot->info->power_status = 1; 109 107 slot->info->max_bus_speed = PCI_SPEED_UNKNOWN; ··· 225 227 { 226 228 unsigned int devfn; 227 229 struct pci_dev *dev; 228 - dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); 230 + dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); 229 231 if (!dev) 230 232 return; 231 233 232 - memset(dev, 0, sizeof(dev)); 233 234 dev->bus = (struct pci_bus*)bus; 234 235 dev->sysdata = bus->sysdata; 235 236 for (devfn = 0; devfn < 0x100; devfn += 8) {
+2 -4
drivers/pci/hotplug/ibmphp_core.c
··· 1141 1141 goto error_power; 1142 1142 } 1143 1143 1144 - slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL); 1144 + slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL); 1145 1145 if (!slot_cur->func) { 1146 1146 /* We cannot do update_slot_info here, since no memory for 1147 1147 * kmalloc n.e.ways, and update_slot_info allocates some */ ··· 1149 1149 rc = -ENOMEM; 1150 1150 goto error_power; 1151 1151 } 1152 - memset(slot_cur->func, 0, sizeof(struct pci_func)); 1153 1152 slot_cur->func->busno = slot_cur->bus; 1154 1153 slot_cur->func->device = slot_cur->device; 1155 1154 for (i = 0; i < 4; i++) ··· 1251 1252 1252 1253 if (slot_cur->func == NULL) { 1253 1254 /* We need this for fncs's that were there on bootup */ 1254 - slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL); 1255 + slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL); 1255 1256 if (!slot_cur->func) { 1256 1257 err("out of system memory\n"); 1257 1258 rc = -ENOMEM; 1258 1259 goto error; 1259 1260 } 1260 - memset(slot_cur->func, 0, sizeof(struct pci_func)); 1261 1261 slot_cur->func->busno = slot_cur->bus; 1262 1262 slot_cur->func->device = slot_cur->device; 1263 1263 }
+14 -43
drivers/pci/hotplug/ibmphp_ebda.c
··· 72 72 73 73 static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void) 74 74 { 75 - struct ebda_hpc_list *list; 76 - 77 - list = kmalloc (sizeof (struct ebda_hpc_list), GFP_KERNEL); 78 - if (!list) 79 - return NULL; 80 - memset (list, 0, sizeof (*list)); 81 - return list; 75 + return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL); 82 76 } 83 77 84 78 static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) ··· 81 87 struct ebda_hpc_slot *slots; 82 88 struct ebda_hpc_bus *buses; 83 89 84 - controller = kmalloc (sizeof (struct controller), GFP_KERNEL); 90 + controller = kzalloc(sizeof(struct controller), GFP_KERNEL); 85 91 if (!controller) 86 92 goto error; 87 - memset (controller, 0, sizeof (*controller)); 88 93 89 - slots = kmalloc (sizeof (struct ebda_hpc_slot) * slot_count, GFP_KERNEL); 94 + slots = kcalloc(slot_count, sizeof(struct ebda_hpc_slot), GFP_KERNEL); 90 95 if (!slots) 91 96 goto error_contr; 92 - memset (slots, 0, sizeof (*slots) * slot_count); 93 97 controller->slots = slots; 94 98 95 - buses = kmalloc (sizeof (struct ebda_hpc_bus) * bus_count, GFP_KERNEL); 99 + buses = kcalloc(bus_count, sizeof(struct ebda_hpc_bus), GFP_KERNEL); 96 100 if (!buses) 97 101 goto error_slots; 98 - memset (buses, 0, sizeof (*buses) * bus_count); 99 102 controller->buses = buses; 100 103 101 104 return controller; ··· 113 122 114 123 static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void) 115 124 { 116 - struct ebda_rsrc_list *list; 117 - 118 - list = kmalloc (sizeof (struct ebda_rsrc_list), GFP_KERNEL); 119 - if (!list) 120 - return NULL; 121 - memset (list, 0, sizeof (*list)); 122 - return list; 125 + return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL); 123 126 } 124 127 125 128 static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void) 126 129 { 127 - struct ebda_pci_rsrc *resource; 128 - 129 - resource = kmalloc (sizeof (struct ebda_pci_rsrc), GFP_KERNEL); 130 - if (!resource) 131 - return NULL; 132 - memset (resource, 0, sizeof (*resource)); 133 - return resource; 130 + return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL); 134 131 } 135 132 136 133 static void __init print_bus_info (void) ··· 369 390 debug ("now enter io table ---\n"); 370 391 debug ("rio blk id: %x\n", blk_id); 371 392 372 - rio_table_ptr = kmalloc (sizeof (struct rio_table_hdr), GFP_KERNEL); 393 + rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL); 373 394 if (!rio_table_ptr) 374 395 return -ENOMEM; 375 - memset (rio_table_ptr, 0, sizeof (struct rio_table_hdr) ); 376 396 rio_table_ptr->ver_num = readb (io_mem + offset); 377 397 rio_table_ptr->scal_count = readb (io_mem + offset + 1); 378 398 rio_table_ptr->riodev_count = readb (io_mem + offset + 2); ··· 423 445 424 446 // we do concern about rio details 425 447 for (i = 0; i < rio_table_ptr->riodev_count; i++) { 426 - rio_detail_ptr = kmalloc (sizeof (struct rio_detail), GFP_KERNEL); 448 + rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL); 427 449 if (!rio_detail_ptr) 428 450 return -ENOMEM; 429 - memset (rio_detail_ptr, 0, sizeof (struct rio_detail)); 430 451 rio_detail_ptr->rio_node_id = readb (io_mem + offset); 431 452 rio_detail_ptr->bbar = readl (io_mem + offset + 1); 432 453 rio_detail_ptr->rio_type = readb (io_mem + offset + 5); ··· 480 503 rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); 481 504 opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); 482 505 if (!opt_rio_ptr) { 483 - opt_rio_ptr = (struct opt_rio *) kmalloc (sizeof (struct opt_rio), GFP_KERNEL); 506 + opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); 484 507 if (!opt_rio_ptr) 485 508 return -ENOMEM; 486 - memset (opt_rio_ptr, 0, sizeof (struct opt_rio)); 487 509 opt_rio_ptr->rio_type = rio_detail_ptr->rio_type; 488 510 opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num; 489 511 opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num; ··· 522 546 rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); 523 547 opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); 524 548 if (!opt_rio_lo_ptr) { 525 - opt_rio_lo_ptr = (struct opt_rio_lo *) kmalloc (sizeof (struct opt_rio_lo), GFP_KERNEL); 549 + opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); 526 550 if (!opt_rio_lo_ptr) 527 551 return -ENOMEM; 528 - memset (opt_rio_lo_ptr, 0, sizeof (struct opt_rio_lo)); 529 552 opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type; 530 553 opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num; 531 554 opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num; ··· 817 842 818 843 bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num); 819 844 if (!bus_info_ptr2) { 820 - bus_info_ptr1 = (struct bus_info *) kmalloc (sizeof (struct bus_info), GFP_KERNEL); 845 + bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL); 821 846 if (!bus_info_ptr1) { 822 847 rc = -ENOMEM; 823 848 goto error_no_hp_slot; 824 849 } 825 - memset (bus_info_ptr1, 0, sizeof (struct bus_info)); 826 850 bus_info_ptr1->slot_min = slot_ptr->slot_num; 827 851 bus_info_ptr1->slot_max = slot_ptr->slot_num; 828 852 bus_info_ptr1->slot_count += 1; ··· 920 946 // register slots with hpc core as well as create linked list of ibm slot 921 947 for (index = 0; index < hpc_ptr->slot_count; index++) { 922 948 923 - hp_slot_ptr = kmalloc(sizeof(*hp_slot_ptr), GFP_KERNEL); 949 + hp_slot_ptr = kzalloc(sizeof(*hp_slot_ptr), GFP_KERNEL); 924 950 if (!hp_slot_ptr) { 925 951 rc = -ENOMEM; 926 952 goto error_no_hp_slot; 927 953 } 928 - memset(hp_slot_ptr, 0, sizeof(*hp_slot_ptr)); 929 954 930 - hp_slot_ptr->info = kmalloc (sizeof(struct hotplug_slot_info), GFP_KERNEL); 955 + hp_slot_ptr->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); 931 956 if (!hp_slot_ptr->info) { 932 957 rc = -ENOMEM; 933 958 goto error_no_hp_info; 934 959 } 935 - memset(hp_slot_ptr->info, 0, sizeof(struct hotplug_slot_info)); 936 960 937 961 hp_slot_ptr->name = kmalloc(30, GFP_KERNEL); 938 962 if (!hp_slot_ptr->name) { ··· 938 966 goto error_no_hp_name; 939 967 } 940 968 941 - tmp_slot = kmalloc(sizeof(*tmp_slot), GFP_KERNEL); 969 + tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL); 942 970 if (!tmp_slot) { 943 971 rc = -ENOMEM; 944 972 goto error_no_slot; 945 973 } 946 - memset(tmp_slot, 0, sizeof(*tmp_slot)); 947 974 948 975 tmp_slot->flag = TRUE; 949 976
+21 -42
drivers/pci/hotplug/ibmphp_pci.c
··· 164 164 cleanup_count = 6; 165 165 goto error; 166 166 } 167 - newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); 167 + newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 168 168 if (!newfunc) { 169 169 err ("out of system memory\n"); 170 170 return -ENOMEM; 171 171 } 172 - memset (newfunc, 0, sizeof (struct pci_func)); 173 172 newfunc->busno = cur_func->busno; 174 173 newfunc->device = device; 175 174 cur_func->next = newfunc; ··· 202 203 flag = FALSE; 203 204 for (i = 0; i < 32; i++) { 204 205 if (func->devices[i]) { 205 - newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); 206 + newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 206 207 if (!newfunc) { 207 208 err ("out of system memory\n"); 208 209 return -ENOMEM; 209 210 } 210 - memset (newfunc, 0, sizeof (struct pci_func)); 211 211 newfunc->busno = sec_number; 212 212 newfunc->device = (u8) i; 213 213 for (j = 0; j < 4; j++) ··· 230 232 } 231 233 } 232 234 233 - newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); 235 + newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 234 236 if (!newfunc) { 235 237 err ("out of system memory\n"); 236 238 return -ENOMEM; 237 239 } 238 - memset (newfunc, 0, sizeof (struct pci_func)); 239 240 newfunc->busno = cur_func->busno; 240 241 newfunc->device = device; 241 242 for (j = 0; j < 4; j++) ··· 276 279 for (i = 0; i < 32; i++) { 277 280 if (func->devices[i]) { 278 281 debug ("inside for loop, device is %x\n", i); 279 - newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); 282 + newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 280 283 if (!newfunc) { 281 284 err (" out of system memory\n"); 282 285 return -ENOMEM; 283 286 } 284 - memset (newfunc, 0, sizeof (struct pci_func)); 285 287 newfunc->busno = sec_number; 286 288 newfunc->device = (u8) i; 287 289 for (j = 0; j < 4; j++) ··· 401 405 402 406 debug ("len[count] in IO %x, count %d\n", len[count], count); 403 407 404 - io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 408 + io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 405 409 406 410 if (!io[count]) { 407 411 err ("out of system memory\n"); 408 412 return -ENOMEM; 409 413 } 410 - memset (io[count], 0, sizeof (struct resource_node)); 411 414 io[count]->type = IO; 412 415 io[count]->busno = func->busno; 413 416 io[count]->devfunc = PCI_DEVFN(func->device, func->function); ··· 439 444 440 445 debug ("len[count] in PFMEM %x, count %d\n", len[count], count); 441 446 442 - pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 447 + pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 443 448 if (!pfmem[count]) { 444 449 err ("out of system memory\n"); 445 450 return -ENOMEM; 446 451 } 447 - memset (pfmem[count], 0, sizeof (struct resource_node)); 448 452 pfmem[count]->type = PFMEM; 449 453 pfmem[count]->busno = func->busno; 450 454 pfmem[count]->devfunc = PCI_DEVFN(func->device, ··· 454 460 ibmphp_add_resource (pfmem[count]); 455 461 func->pfmem[count] = pfmem[count]; 456 462 } else { 457 - mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); 463 + mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); 458 464 if (!mem_tmp) { 459 465 err ("out of system memory\n"); 460 466 kfree (pfmem[count]); 461 467 return -ENOMEM; 462 468 } 463 - memset (mem_tmp, 0, sizeof (struct resource_node)); 464 469 mem_tmp->type = MEM; 465 470 mem_tmp->busno = pfmem[count]->busno; 466 471 mem_tmp->devfunc = pfmem[count]->devfunc; ··· 505 512 506 513 debug ("len[count] in Mem %x, count %d\n", len[count], count); 507 514 508 - mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 515 + mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 509 516 if (!mem[count]) { 510 517 err ("out of system memory\n"); 511 518 return -ENOMEM; 512 519 } 513 - memset (mem[count], 0, sizeof (struct resource_node)); 514 520 mem[count]->type = MEM; 515 521 mem[count]->busno = func->busno; 516 522 mem[count]->devfunc = PCI_DEVFN(func->device, ··· 669 677 670 678 debug ("len[count] in IO = %x\n", len[count]); 671 679 672 - bus_io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 680 + bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 673 681 674 682 if (!bus_io[count]) { 675 683 err ("out of system memory\n"); 676 684 retval = -ENOMEM; 677 685 goto error; 678 686 } 679 - memset (bus_io[count], 0, sizeof (struct resource_node)); 680 687 bus_io[count]->type = IO; 681 688 bus_io[count]->busno = func->busno; 682 689 bus_io[count]->devfunc = PCI_DEVFN(func->device, ··· 702 711 703 712 debug ("len[count] in PFMEM = %x\n", len[count]); 704 713 705 - bus_pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 714 + bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 706 715 if (!bus_pfmem[count]) { 707 716 err ("out of system memory\n"); 708 717 retval = -ENOMEM; 709 718 goto error; 710 719 } 711 - memset (bus_pfmem[count], 0, sizeof (struct resource_node)); 712 720 bus_pfmem[count]->type = PFMEM; 713 721 bus_pfmem[count]->busno = func->busno; 714 722 bus_pfmem[count]->devfunc = PCI_DEVFN(func->device, ··· 718 728 ibmphp_add_resource (bus_pfmem[count]); 719 729 func->pfmem[count] = bus_pfmem[count]; 720 730 } else { 721 - mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); 731 + mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); 722 732 if (!mem_tmp) { 723 733 err ("out of system memory\n"); 724 734 retval = -ENOMEM; 725 735 goto error; 726 736 } 727 - memset (mem_tmp, 0, sizeof (struct resource_node)); 728 737 mem_tmp->type = MEM; 729 738 mem_tmp->busno = bus_pfmem[count]->busno; 730 739 mem_tmp->devfunc = bus_pfmem[count]->devfunc; ··· 759 770 760 771 debug ("len[count] in Memory is %x\n", len[count]); 761 772 762 - bus_mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 773 + bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 763 774 if (!bus_mem[count]) { 764 775 err ("out of system memory\n"); 765 776 retval = -ENOMEM; 766 777 goto error; 767 778 } 768 - memset (bus_mem[count], 0, sizeof (struct resource_node)); 769 779 bus_mem[count]->type = MEM; 770 780 bus_mem[count]->busno = func->busno; 771 781 bus_mem[count]->devfunc = PCI_DEVFN(func->device, ··· 829 841 flag_io = TRUE; 830 842 } else { 831 843 debug ("it wants %x IO behind the bridge\n", amount_needed->io); 832 - io = kmalloc(sizeof(*io), GFP_KERNEL); 844 + io = kzalloc(sizeof(*io), GFP_KERNEL); 833 845 834 846 if (!io) { 835 847 err ("out of system memory\n"); 836 848 retval = -ENOMEM; 837 849 goto error; 838 850 } 839 - memset (io, 0, sizeof (struct resource_node)); 840 851 io->type = IO; 841 852 io->busno = func->busno; 842 853 io->devfunc = PCI_DEVFN(func->device, func->function); ··· 852 865 flag_mem = TRUE; 853 866 } else { 854 867 debug ("it wants %x memory behind the bridge\n", amount_needed->mem); 855 - mem = kmalloc(sizeof(*mem), GFP_KERNEL); 868 + mem = kzalloc(sizeof(*mem), GFP_KERNEL); 856 869 if (!mem) { 857 870 err ("out of system memory\n"); 858 871 retval = -ENOMEM; 859 872 goto error; 860 873 } 861 - memset (mem, 0, sizeof (struct resource_node)); 862 874 mem->type = MEM; 863 875 mem->busno = func->busno; 864 876 mem->devfunc = PCI_DEVFN(func->device, func->function); ··· 874 888 flag_pfmem = TRUE; 875 889 } else { 876 890 debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); 877 - pfmem = kmalloc(sizeof(*pfmem), GFP_KERNEL); 891 + pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); 878 892 if (!pfmem) { 879 893 err ("out of system memory\n"); 880 894 retval = -ENOMEM; 881 895 goto error; 882 896 } 883 - memset (pfmem, 0, sizeof (struct resource_node)); 884 897 pfmem->type = PFMEM; 885 898 pfmem->busno = func->busno; 886 899 pfmem->devfunc = PCI_DEVFN(func->device, func->function); ··· 889 904 ibmphp_add_resource (pfmem); 890 905 flag_pfmem = TRUE; 891 906 } else { 892 - mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); 907 + mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); 893 908 if (!mem_tmp) { 894 909 err ("out of system memory\n"); 895 910 retval = -ENOMEM; 896 911 goto error; 897 912 } 898 - memset (mem_tmp, 0, sizeof (struct resource_node)); 899 913 mem_tmp->type = MEM; 900 914 mem_tmp->busno = pfmem->busno; 901 915 mem_tmp->devfunc = pfmem->devfunc; ··· 920 936 */ 921 937 bus = ibmphp_find_res_bus (sec_number); 922 938 if (!bus) { 923 - bus = kmalloc(sizeof(*bus), GFP_KERNEL); 939 + bus = kzalloc(sizeof(*bus), GFP_KERNEL); 924 940 if (!bus) { 925 941 err ("out of system memory\n"); 926 942 retval = -ENOMEM; 927 943 goto error; 928 944 } 929 - memset (bus, 0, sizeof (struct bus_node)); 930 945 bus->busno = sec_number; 931 946 debug ("b4 adding new bus\n"); 932 947 rc = add_new_bus (bus, io, mem, pfmem, func->busno); ··· 1094 1111 }; 1095 1112 struct res_needed *amount; 1096 1113 1097 - amount = kmalloc(sizeof(*amount), GFP_KERNEL); 1114 + amount = kzalloc(sizeof(*amount), GFP_KERNEL); 1098 1115 if (amount == NULL) 1099 1116 return NULL; 1100 - memset (amount, 0, sizeof (struct res_needed)); 1101 1117 1102 1118 ibmphp_pci_bus->number = busno; 1103 1119 ··· 1654 1672 list_add (&bus->bus_list, &cur_bus->bus_list); 1655 1673 } 1656 1674 if (io) { 1657 - io_range = kmalloc(sizeof(*io_range), GFP_KERNEL); 1675 + io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); 1658 1676 if (!io_range) { 1659 1677 err ("out of system memory\n"); 1660 1678 return -ENOMEM; 1661 1679 } 1662 - memset (io_range, 0, sizeof (struct range_node)); 1663 1680 io_range->start = io->start; 1664 1681 io_range->end = io->end; 1665 1682 io_range->rangeno = 1; ··· 1666 1685 bus->rangeIO = io_range; 1667 1686 } 1668 1687 if (mem) { 1669 - mem_range = kmalloc(sizeof(*mem_range), GFP_KERNEL); 1688 + mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); 1670 1689 if (!mem_range) { 1671 1690 err ("out of system memory\n"); 1672 1691 return -ENOMEM; 1673 1692 } 1674 - memset (mem_range, 0, sizeof (struct range_node)); 1675 1693 mem_range->start = mem->start; 1676 1694 mem_range->end = mem->end; 1677 1695 mem_range->rangeno = 1; ··· 1678 1698 bus->rangeMem = mem_range; 1679 1699 } 1680 1700 if (pfmem) { 1681 - pfmem_range = kmalloc(sizeof(*pfmem_range), GFP_KERNEL); 1701 + pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); 1682 1702 if (!pfmem_range) { 1683 1703 err ("out of system memory\n"); 1684 1704 return -ENOMEM; 1685 1705 } 1686 - memset (pfmem_range, 0, sizeof (struct range_node)); 1687 1706 pfmem_range->start = pfmem->start; 1688 1707 pfmem_range->end = pfmem->end; 1689 1708 pfmem_range->rangeno = 1;
+11 -22
drivers/pci/hotplug/ibmphp_res.c
··· 55 55 return NULL; 56 56 } 57 57 58 - newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL); 58 + newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); 59 59 if (!newbus) { 60 60 err ("out of system memory\n"); 61 61 return NULL; 62 62 } 63 63 64 - memset (newbus, 0, sizeof (struct bus_node)); 65 64 if (flag) 66 65 newbus->busno = busno; 67 66 else ··· 78 79 return NULL; 79 80 } 80 81 81 - rs = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 82 + rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 82 83 if (!rs) { 83 84 err ("out of system memory\n"); 84 85 return NULL; 85 86 } 86 - memset (rs, 0, sizeof (struct resource_node)); 87 87 rs->busno = curr->bus_num; 88 88 rs->devfunc = curr->dev_fun; 89 89 rs->start = curr->start_addr; ··· 98 100 u8 num_ranges = 0; 99 101 100 102 if (first_bus) { 101 - newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL); 103 + newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); 102 104 if (!newbus) { 103 105 err ("out of system memory.\n"); 104 106 return -ENOMEM; 105 107 } 106 - memset (newbus, 0, sizeof (struct bus_node)); 107 108 newbus->busno = curr->bus_num; 108 109 } else { 109 110 newbus = *new_bus; ··· 119 122 } 120 123 } 121 124 122 - newrange = kmalloc (sizeof (struct range_node), GFP_KERNEL); 125 + newrange = kzalloc(sizeof(struct range_node), GFP_KERNEL); 123 126 if (!newrange) { 124 127 if (first_bus) 125 128 kfree (newbus); 126 129 err ("out of system memory\n"); 127 130 return -ENOMEM; 128 131 } 129 - memset (newrange, 0, sizeof (struct range_node)); 130 132 newrange->start = curr->start_addr; 131 133 newrange->end = curr->end_addr; 132 134 ··· 1701 1705 1702 1706 bus_cur->firstPFMemFromMem = pfmem_cur; 1703 1707 1704 - mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 1708 + mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 1705 1709 if (!mem) { 1706 1710 err ("out of system memory\n"); 1707 1711 return -ENOMEM; 1708 1712 } 1709 - memset (mem, 0, sizeof (struct resource_node)); 1710 1713 mem->type = MEM; 1711 1714 mem->busno = pfmem_cur->busno; 1712 1715 mem->devfunc = pfmem_cur->devfunc; ··· 1989 1994 end_address |= (upper_io_end << 16); 1990 1995 1991 1996 if ((start_address) && (start_address <= end_address)) { 1992 - range = kmalloc (sizeof (struct range_node), GFP_KERNEL); 1997 + range = kzalloc(sizeof(struct range_node), GFP_KERNEL); 1993 1998 if (!range) { 1994 1999 err ("out of system memory\n"); 1995 2000 return -ENOMEM; 1996 2001 } 1997 - memset (range, 0, sizeof (struct range_node)); 1998 2002 range->start = start_address; 1999 2003 range->end = end_address + 0xfff; 2000 2004 ··· 2014 2020 fix_resources (bus_sec); 2015 2021 2016 2022 if (ibmphp_find_resource (bus_cur, start_address, &io, IO)) { 2017 - io = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 2023 + io = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 2018 2024 if (!io) { 2019 2025 kfree (range); 2020 2026 err ("out of system memory\n"); 2021 2027 return -ENOMEM; 2022 2028 } 2023 - memset (io, 0, sizeof (struct resource_node)); 2024 2029 io->type = IO; 2025 2030 io->busno = bus_cur->busno; 2026 2031 io->devfunc = ((device << 3) | (function & 0x7)); ··· 2038 2045 2039 2046 if ((start_address) && (start_address <= end_address)) { 2040 2047 2041 - range = kmalloc (sizeof (struct range_node), GFP_KERNEL); 2048 + range = kzalloc(sizeof(struct range_node), GFP_KERNEL); 2042 2049 if (!range) { 2043 2050 err ("out of system memory\n"); 2044 2051 return -ENOMEM; 2045 2052 } 2046 - memset (range, 0, sizeof (struct range_node)); 2047 2053 range->start = start_address; 2048 2054 range->end = end_address + 0xfffff; 2049 2055 ··· 2064 2072 fix_resources (bus_sec); 2065 2073 2066 2074 if (ibmphp_find_resource (bus_cur, start_address, &mem, MEM)) { 2067 - mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 2075 + mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 2068 2076 if (!mem) { 2069 2077 kfree (range); 2070 2078 err ("out of system memory\n"); 2071 2079 return -ENOMEM; 2072 2080 } 2073 - memset (mem, 0, sizeof (struct resource_node)); 2074 2081 mem->type = MEM; 2075 2082 mem->busno = bus_cur->busno; 2076 2083 mem->devfunc = ((device << 3) | (function & 0x7)); ··· 2092 2101 2093 2102 if ((start_address) && (start_address <= end_address)) { 2094 2103 2095 - range = kmalloc (sizeof (struct range_node), GFP_KERNEL); 2104 + range = kzalloc(sizeof(struct range_node), GFP_KERNEL); 2096 2105 if (!range) { 2097 2106 err ("out of system memory\n"); 2098 2107 return -ENOMEM; 2099 2108 } 2100 - memset (range, 0, sizeof (struct range_node)); 2101 2109 range->start = start_address; 2102 2110 range->end = end_address + 0xfffff; 2103 2111 ··· 2117 2127 2118 2128 fix_resources (bus_sec); 2119 2129 if (ibmphp_find_resource (bus_cur, start_address, &pfmem, PFMEM)) { 2120 - pfmem = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 2130 + pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 2121 2131 if (!pfmem) { 2122 2132 kfree (range); 2123 2133 err ("out of system memory\n"); 2124 2134 return -ENOMEM; 2125 2135 } 2126 - memset (pfmem, 0, sizeof (struct resource_node)); 2127 2136 pfmem->type = PFMEM; 2128 2137 pfmem->busno = bus_cur->busno; 2129 2138 pfmem->devfunc = ((device << 3) | (function & 0x7));
+4 -9
drivers/pci/hotplug/pciehp_core.c
··· 117 117 slot_number = ctrl->first_slot; 118 118 119 119 while (number_of_slots) { 120 - slot = kmalloc(sizeof(*slot), GFP_KERNEL); 120 + slot = kzalloc(sizeof(*slot), GFP_KERNEL); 121 121 if (!slot) 122 122 goto error; 123 123 124 - memset(slot, 0, sizeof(struct slot)); 125 124 slot->hotplug_slot = 126 - kmalloc(sizeof(*(slot->hotplug_slot)), 125 + kzalloc(sizeof(*(slot->hotplug_slot)), 127 126 GFP_KERNEL); 128 127 if (!slot->hotplug_slot) 129 128 goto error_slot; 130 129 hotplug_slot = slot->hotplug_slot; 131 - memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); 132 130 133 131 hotplug_slot->info = 134 - kmalloc(sizeof(*(hotplug_slot->info)), 132 + kzalloc(sizeof(*(hotplug_slot->info)), 135 133 GFP_KERNEL); 136 134 if (!hotplug_slot->info) 137 135 goto error_hpslot; 138 136 hotplug_slot_info = hotplug_slot->info; 139 - memset(hotplug_slot_info, 0, 140 - sizeof(struct hotplug_slot_info)); 141 137 hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); 142 138 if (!hotplug_slot->name) 143 139 goto error_info; ··· 369 373 u8 value; 370 374 struct pci_dev *pdev; 371 375 372 - ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL); 376 + ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); 373 377 if (!ctrl) { 374 378 err("%s : out of memory\n", __FUNCTION__); 375 379 goto err_out_none; 376 380 } 377 - memset(ctrl, 0, sizeof(struct controller)); 378 381 379 382 pdev = dev->port; 380 383 ctrl->pci_dev = pdev;
+3 -6
drivers/pci/hotplug/rpaphp_slot.c
··· 84 84 { 85 85 struct slot *slot; 86 86 87 - slot = kmalloc(sizeof (struct slot), GFP_KERNEL); 87 + slot = kzalloc(sizeof(struct slot), GFP_KERNEL); 88 88 if (!slot) 89 89 goto error_nomem; 90 - memset(slot, 0, sizeof (struct slot)); 91 - slot->hotplug_slot = kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL); 90 + slot->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL); 92 91 if (!slot->hotplug_slot) 93 92 goto error_slot; 94 - memset(slot->hotplug_slot, 0, sizeof (struct hotplug_slot)); 95 - slot->hotplug_slot->info = kmalloc(sizeof (struct hotplug_slot_info), 93 + slot->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info), 96 94 GFP_KERNEL); 97 95 if (!slot->hotplug_slot->info) 98 96 goto error_hpslot; 99 - memset(slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info)); 100 97 slot->hotplug_slot->name = kmalloc(BUS_ID_SIZE + 1, GFP_KERNEL); 101 98 if (!slot->hotplug_slot->name) 102 99 goto error_info;
+1 -2
drivers/pci/pci-driver.c
··· 53 53 if (fields < 0) 54 54 return -EINVAL; 55 55 56 - dynid = kmalloc(sizeof(*dynid), GFP_KERNEL); 56 + dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 57 57 if (!dynid) 58 58 return -ENOMEM; 59 59 60 - memset(dynid, 0, sizeof(*dynid)); 61 60 INIT_LIST_HEAD(&dynid->node); 62 61 dynid->id.vendor = vendor; 63 62 dynid->id.device = device;
+1 -2
drivers/pci/pci-sysfs.c
··· 501 501 if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { 502 502 struct bin_attribute *rom_attr; 503 503 504 - rom_attr = kmalloc(sizeof(*rom_attr), GFP_ATOMIC); 504 + rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC); 505 505 if (rom_attr) { 506 - memset(rom_attr, 0x00, sizeof(*rom_attr)); 507 506 pdev->rom_attr = rom_attr; 508 507 rom_attr->size = pci_resource_len(pdev, PCI_ROM_RESOURCE); 509 508 rom_attr->attr.name = "rom";
+1 -2
drivers/pci/pcie/portdrv_core.c
··· 248 248 { 249 249 struct pcie_device *device; 250 250 251 - device = kmalloc(sizeof(struct pcie_device), GFP_KERNEL); 251 + device = kzalloc(sizeof(struct pcie_device), GFP_KERNEL); 252 252 if (!device) 253 253 return NULL; 254 254 255 - memset(device, 0, sizeof(struct pcie_device)); 256 255 pcie_device_init(parent, device, port_type, service_type, irq,irq_mode); 257 256 printk(KERN_DEBUG "Allocate Port Service[%s]\n", device->device.bus_id); 258 257 return device;
+3 -6
drivers/pci/probe.c
··· 33 33 */ 34 34 static void pci_create_legacy_files(struct pci_bus *b) 35 35 { 36 - b->legacy_io = kmalloc(sizeof(struct bin_attribute) * 2, 36 + b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2, 37 37 GFP_ATOMIC); 38 38 if (b->legacy_io) { 39 - memset(b->legacy_io, 0, sizeof(struct bin_attribute) * 2); 40 39 b->legacy_io->attr.name = "legacy_io"; 41 40 b->legacy_io->size = 0xffff; 42 41 b->legacy_io->attr.mode = S_IRUSR | S_IWUSR; ··· 319 320 { 320 321 struct pci_bus *b; 321 322 322 - b = kmalloc(sizeof(*b), GFP_KERNEL); 323 + b = kzalloc(sizeof(*b), GFP_KERNEL); 323 324 if (b) { 324 - memset(b, 0, sizeof(*b)); 325 325 INIT_LIST_HEAD(&b->node); 326 326 INIT_LIST_HEAD(&b->children); 327 327 INIT_LIST_HEAD(&b->devices); ··· 795 797 if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type)) 796 798 return NULL; 797 799 798 - dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); 800 + dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); 799 801 if (!dev) 800 802 return NULL; 801 803 802 - memset(dev, 0, sizeof(struct pci_dev)); 803 804 dev->bus = bus; 804 805 dev->sysdata = bus->sysdata; 805 806 dev->dev.parent = bus->bridge;