aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/ibmphp_pci.c
diff options
context:
space:
mode:
authorEric Sesterhenn <snakebyte@gmx.de>2006-02-28 09:34:49 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-23 17:35:17 -0500
commitf5afe8064f3087bead8fea7e32547c2a3ada5fd0 (patch)
treede6a9d60aad6ee262c04290d73e414cd92b4ad5d /drivers/pci/hotplug/ibmphp_pci.c
parent7c8f25da12a3dda46fb730699582895d5fc51287 (diff)
[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>
Diffstat (limited to 'drivers/pci/hotplug/ibmphp_pci.c')
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c63
1 files changed, 21 insertions, 42 deletions
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index 155133fe5c12..97753ddcd856 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -164,12 +164,11 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
164 cleanup_count = 6; 164 cleanup_count = 6;
165 goto error; 165 goto error;
166 } 166 }
167 newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); 167 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
168 if (!newfunc) { 168 if (!newfunc) {
169 err ("out of system memory\n"); 169 err ("out of system memory\n");
170 return -ENOMEM; 170 return -ENOMEM;
171 } 171 }
172 memset (newfunc, 0, sizeof (struct pci_func));
173 newfunc->busno = cur_func->busno; 172 newfunc->busno = cur_func->busno;
174 newfunc->device = device; 173 newfunc->device = device;
175 cur_func->next = newfunc; 174 cur_func->next = newfunc;
@@ -203,12 +202,11 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
203 flag = FALSE; 202 flag = FALSE;
204 for (i = 0; i < 32; i++) { 203 for (i = 0; i < 32; i++) {
205 if (func->devices[i]) { 204 if (func->devices[i]) {
206 newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); 205 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
207 if (!newfunc) { 206 if (!newfunc) {
208 err ("out of system memory\n"); 207 err ("out of system memory\n");
209 return -ENOMEM; 208 return -ENOMEM;
210 } 209 }
211 memset (newfunc, 0, sizeof (struct pci_func));
212 newfunc->busno = sec_number; 210 newfunc->busno = sec_number;
213 newfunc->device = (u8) i; 211 newfunc->device = (u8) i;
214 for (j = 0; j < 4; j++) 212 for (j = 0; j < 4; j++)
@@ -232,12 +230,11 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
232 } 230 }
233 } 231 }
234 232
235 newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); 233 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
236 if (!newfunc) { 234 if (!newfunc) {
237 err ("out of system memory\n"); 235 err ("out of system memory\n");
238 return -ENOMEM; 236 return -ENOMEM;
239 } 237 }
240 memset (newfunc, 0, sizeof (struct pci_func));
241 newfunc->busno = cur_func->busno; 238 newfunc->busno = cur_func->busno;
242 newfunc->device = device; 239 newfunc->device = device;
243 for (j = 0; j < 4; j++) 240 for (j = 0; j < 4; j++)
@@ -279,12 +276,11 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
279 for (i = 0; i < 32; i++) { 276 for (i = 0; i < 32; i++) {
280 if (func->devices[i]) { 277 if (func->devices[i]) {
281 debug ("inside for loop, device is %x\n", i); 278 debug ("inside for loop, device is %x\n", i);
282 newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL); 279 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
283 if (!newfunc) { 280 if (!newfunc) {
284 err (" out of system memory\n"); 281 err (" out of system memory\n");
285 return -ENOMEM; 282 return -ENOMEM;
286 } 283 }
287 memset (newfunc, 0, sizeof (struct pci_func));
288 newfunc->busno = sec_number; 284 newfunc->busno = sec_number;
289 newfunc->device = (u8) i; 285 newfunc->device = (u8) i;
290 for (j = 0; j < 4; j++) 286 for (j = 0; j < 4; j++)
@@ -405,13 +401,12 @@ static int configure_device (struct pci_func *func)
405 401
406 debug ("len[count] in IO %x, count %d\n", len[count], count); 402 debug ("len[count] in IO %x, count %d\n", len[count], count);
407 403
408 io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 404 io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
409 405
410 if (!io[count]) { 406 if (!io[count]) {
411 err ("out of system memory\n"); 407 err ("out of system memory\n");
412 return -ENOMEM; 408 return -ENOMEM;
413 } 409 }
414 memset (io[count], 0, sizeof (struct resource_node));
415 io[count]->type = IO; 410 io[count]->type = IO;
416 io[count]->busno = func->busno; 411 io[count]->busno = func->busno;
417 io[count]->devfunc = PCI_DEVFN(func->device, func->function); 412 io[count]->devfunc = PCI_DEVFN(func->device, func->function);
@@ -444,12 +439,11 @@ static int configure_device (struct pci_func *func)
444 439
445 debug ("len[count] in PFMEM %x, count %d\n", len[count], count); 440 debug ("len[count] in PFMEM %x, count %d\n", len[count], count);
446 441
447 pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 442 pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
448 if (!pfmem[count]) { 443 if (!pfmem[count]) {
449 err ("out of system memory\n"); 444 err ("out of system memory\n");
450 return -ENOMEM; 445 return -ENOMEM;
451 } 446 }
452 memset (pfmem[count], 0, sizeof (struct resource_node));
453 pfmem[count]->type = PFMEM; 447 pfmem[count]->type = PFMEM;
454 pfmem[count]->busno = func->busno; 448 pfmem[count]->busno = func->busno;
455 pfmem[count]->devfunc = PCI_DEVFN(func->device, 449 pfmem[count]->devfunc = PCI_DEVFN(func->device,
@@ -460,13 +454,12 @@ static int configure_device (struct pci_func *func)
460 ibmphp_add_resource (pfmem[count]); 454 ibmphp_add_resource (pfmem[count]);
461 func->pfmem[count] = pfmem[count]; 455 func->pfmem[count] = pfmem[count];
462 } else { 456 } else {
463 mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); 457 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
464 if (!mem_tmp) { 458 if (!mem_tmp) {
465 err ("out of system memory\n"); 459 err ("out of system memory\n");
466 kfree (pfmem[count]); 460 kfree (pfmem[count]);
467 return -ENOMEM; 461 return -ENOMEM;
468 } 462 }
469 memset (mem_tmp, 0, sizeof (struct resource_node));
470 mem_tmp->type = MEM; 463 mem_tmp->type = MEM;
471 mem_tmp->busno = pfmem[count]->busno; 464 mem_tmp->busno = pfmem[count]->busno;
472 mem_tmp->devfunc = pfmem[count]->devfunc; 465 mem_tmp->devfunc = pfmem[count]->devfunc;
@@ -512,12 +505,11 @@ static int configure_device (struct pci_func *func)
512 505
513 debug ("len[count] in Mem %x, count %d\n", len[count], count); 506 debug ("len[count] in Mem %x, count %d\n", len[count], count);
514 507
515 mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 508 mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
516 if (!mem[count]) { 509 if (!mem[count]) {
517 err ("out of system memory\n"); 510 err ("out of system memory\n");
518 return -ENOMEM; 511 return -ENOMEM;
519 } 512 }
520 memset (mem[count], 0, sizeof (struct resource_node));
521 mem[count]->type = MEM; 513 mem[count]->type = MEM;
522 mem[count]->busno = func->busno; 514 mem[count]->busno = func->busno;
523 mem[count]->devfunc = PCI_DEVFN(func->device, 515 mem[count]->devfunc = PCI_DEVFN(func->device,
@@ -677,14 +669,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
677 669
678 debug ("len[count] in IO = %x\n", len[count]); 670 debug ("len[count] in IO = %x\n", len[count]);
679 671
680 bus_io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 672 bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
681 673
682 if (!bus_io[count]) { 674 if (!bus_io[count]) {
683 err ("out of system memory\n"); 675 err ("out of system memory\n");
684 retval = -ENOMEM; 676 retval = -ENOMEM;
685 goto error; 677 goto error;
686 } 678 }
687 memset (bus_io[count], 0, sizeof (struct resource_node));
688 bus_io[count]->type = IO; 679 bus_io[count]->type = IO;
689 bus_io[count]->busno = func->busno; 680 bus_io[count]->busno = func->busno;
690 bus_io[count]->devfunc = PCI_DEVFN(func->device, 681 bus_io[count]->devfunc = PCI_DEVFN(func->device,
@@ -711,13 +702,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
711 702
712 debug ("len[count] in PFMEM = %x\n", len[count]); 703 debug ("len[count] in PFMEM = %x\n", len[count]);
713 704
714 bus_pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 705 bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
715 if (!bus_pfmem[count]) { 706 if (!bus_pfmem[count]) {
716 err ("out of system memory\n"); 707 err ("out of system memory\n");
717 retval = -ENOMEM; 708 retval = -ENOMEM;
718 goto error; 709 goto error;
719 } 710 }
720 memset (bus_pfmem[count], 0, sizeof (struct resource_node));
721 bus_pfmem[count]->type = PFMEM; 711 bus_pfmem[count]->type = PFMEM;
722 bus_pfmem[count]->busno = func->busno; 712 bus_pfmem[count]->busno = func->busno;
723 bus_pfmem[count]->devfunc = PCI_DEVFN(func->device, 713 bus_pfmem[count]->devfunc = PCI_DEVFN(func->device,
@@ -728,13 +718,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
728 ibmphp_add_resource (bus_pfmem[count]); 718 ibmphp_add_resource (bus_pfmem[count]);
729 func->pfmem[count] = bus_pfmem[count]; 719 func->pfmem[count] = bus_pfmem[count];
730 } else { 720 } else {
731 mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); 721 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
732 if (!mem_tmp) { 722 if (!mem_tmp) {
733 err ("out of system memory\n"); 723 err ("out of system memory\n");
734 retval = -ENOMEM; 724 retval = -ENOMEM;
735 goto error; 725 goto error;
736 } 726 }
737 memset (mem_tmp, 0, sizeof (struct resource_node));
738 mem_tmp->type = MEM; 727 mem_tmp->type = MEM;
739 mem_tmp->busno = bus_pfmem[count]->busno; 728 mem_tmp->busno = bus_pfmem[count]->busno;
740 mem_tmp->devfunc = bus_pfmem[count]->devfunc; 729 mem_tmp->devfunc = bus_pfmem[count]->devfunc;
@@ -770,13 +759,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
770 759
771 debug ("len[count] in Memory is %x\n", len[count]); 760 debug ("len[count] in Memory is %x\n", len[count]);
772 761
773 bus_mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL); 762 bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
774 if (!bus_mem[count]) { 763 if (!bus_mem[count]) {
775 err ("out of system memory\n"); 764 err ("out of system memory\n");
776 retval = -ENOMEM; 765 retval = -ENOMEM;
777 goto error; 766 goto error;
778 } 767 }
779 memset (bus_mem[count], 0, sizeof (struct resource_node));
780 bus_mem[count]->type = MEM; 768 bus_mem[count]->type = MEM;
781 bus_mem[count]->busno = func->busno; 769 bus_mem[count]->busno = func->busno;
782 bus_mem[count]->devfunc = PCI_DEVFN(func->device, 770 bus_mem[count]->devfunc = PCI_DEVFN(func->device,
@@ -841,14 +829,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
841 flag_io = TRUE; 829 flag_io = TRUE;
842 } else { 830 } else {
843 debug ("it wants %x IO behind the bridge\n", amount_needed->io); 831 debug ("it wants %x IO behind the bridge\n", amount_needed->io);
844 io = kmalloc(sizeof(*io), GFP_KERNEL); 832 io = kzalloc(sizeof(*io), GFP_KERNEL);
845 833
846 if (!io) { 834 if (!io) {
847 err ("out of system memory\n"); 835 err ("out of system memory\n");
848 retval = -ENOMEM; 836 retval = -ENOMEM;
849 goto error; 837 goto error;
850 } 838 }
851 memset (io, 0, sizeof (struct resource_node));
852 io->type = IO; 839 io->type = IO;
853 io->busno = func->busno; 840 io->busno = func->busno;
854 io->devfunc = PCI_DEVFN(func->device, func->function); 841 io->devfunc = PCI_DEVFN(func->device, func->function);
@@ -865,13 +852,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
865 flag_mem = TRUE; 852 flag_mem = TRUE;
866 } else { 853 } else {
867 debug ("it wants %x memory behind the bridge\n", amount_needed->mem); 854 debug ("it wants %x memory behind the bridge\n", amount_needed->mem);
868 mem = kmalloc(sizeof(*mem), GFP_KERNEL); 855 mem = kzalloc(sizeof(*mem), GFP_KERNEL);
869 if (!mem) { 856 if (!mem) {
870 err ("out of system memory\n"); 857 err ("out of system memory\n");
871 retval = -ENOMEM; 858 retval = -ENOMEM;
872 goto error; 859 goto error;
873 } 860 }
874 memset (mem, 0, sizeof (struct resource_node));
875 mem->type = MEM; 861 mem->type = MEM;
876 mem->busno = func->busno; 862 mem->busno = func->busno;
877 mem->devfunc = PCI_DEVFN(func->device, func->function); 863 mem->devfunc = PCI_DEVFN(func->device, func->function);
@@ -888,13 +874,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
888 flag_pfmem = TRUE; 874 flag_pfmem = TRUE;
889 } else { 875 } else {
890 debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); 876 debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem);
891 pfmem = kmalloc(sizeof(*pfmem), GFP_KERNEL); 877 pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL);
892 if (!pfmem) { 878 if (!pfmem) {
893 err ("out of system memory\n"); 879 err ("out of system memory\n");
894 retval = -ENOMEM; 880 retval = -ENOMEM;
895 goto error; 881 goto error;
896 } 882 }
897 memset (pfmem, 0, sizeof (struct resource_node));
898 pfmem->type = PFMEM; 883 pfmem->type = PFMEM;
899 pfmem->busno = func->busno; 884 pfmem->busno = func->busno;
900 pfmem->devfunc = PCI_DEVFN(func->device, func->function); 885 pfmem->devfunc = PCI_DEVFN(func->device, func->function);
@@ -904,13 +889,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
904 ibmphp_add_resource (pfmem); 889 ibmphp_add_resource (pfmem);
905 flag_pfmem = TRUE; 890 flag_pfmem = TRUE;
906 } else { 891 } else {
907 mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL); 892 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
908 if (!mem_tmp) { 893 if (!mem_tmp) {
909 err ("out of system memory\n"); 894 err ("out of system memory\n");
910 retval = -ENOMEM; 895 retval = -ENOMEM;
911 goto error; 896 goto error;
912 } 897 }
913 memset (mem_tmp, 0, sizeof (struct resource_node));
914 mem_tmp->type = MEM; 898 mem_tmp->type = MEM;
915 mem_tmp->busno = pfmem->busno; 899 mem_tmp->busno = pfmem->busno;
916 mem_tmp->devfunc = pfmem->devfunc; 900 mem_tmp->devfunc = pfmem->devfunc;
@@ -936,13 +920,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
936 */ 920 */
937 bus = ibmphp_find_res_bus (sec_number); 921 bus = ibmphp_find_res_bus (sec_number);
938 if (!bus) { 922 if (!bus) {
939 bus = kmalloc(sizeof(*bus), GFP_KERNEL); 923 bus = kzalloc(sizeof(*bus), GFP_KERNEL);
940 if (!bus) { 924 if (!bus) {
941 err ("out of system memory\n"); 925 err ("out of system memory\n");
942 retval = -ENOMEM; 926 retval = -ENOMEM;
943 goto error; 927 goto error;
944 } 928 }
945 memset (bus, 0, sizeof (struct bus_node));
946 bus->busno = sec_number; 929 bus->busno = sec_number;
947 debug ("b4 adding new bus\n"); 930 debug ("b4 adding new bus\n");
948 rc = add_new_bus (bus, io, mem, pfmem, func->busno); 931 rc = add_new_bus (bus, io, mem, pfmem, func->busno);
@@ -1111,10 +1094,9 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno)
1111 }; 1094 };
1112 struct res_needed *amount; 1095 struct res_needed *amount;
1113 1096
1114 amount = kmalloc(sizeof(*amount), GFP_KERNEL); 1097 amount = kzalloc(sizeof(*amount), GFP_KERNEL);
1115 if (amount == NULL) 1098 if (amount == NULL)
1116 return NULL; 1099 return NULL;
1117 memset (amount, 0, sizeof (struct res_needed));
1118 1100
1119 ibmphp_pci_bus->number = busno; 1101 ibmphp_pci_bus->number = busno;
1120 1102
@@ -1672,12 +1654,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
1672 list_add (&bus->bus_list, &cur_bus->bus_list); 1654 list_add (&bus->bus_list, &cur_bus->bus_list);
1673 } 1655 }
1674 if (io) { 1656 if (io) {
1675 io_range = kmalloc(sizeof(*io_range), GFP_KERNEL); 1657 io_range = kzalloc(sizeof(*io_range), GFP_KERNEL);
1676 if (!io_range) { 1658 if (!io_range) {
1677 err ("out of system memory\n"); 1659 err ("out of system memory\n");
1678 return -ENOMEM; 1660 return -ENOMEM;
1679 } 1661 }
1680 memset (io_range, 0, sizeof (struct range_node));
1681 io_range->start = io->start; 1662 io_range->start = io->start;
1682 io_range->end = io->end; 1663 io_range->end = io->end;
1683 io_range->rangeno = 1; 1664 io_range->rangeno = 1;
@@ -1685,12 +1666,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
1685 bus->rangeIO = io_range; 1666 bus->rangeIO = io_range;
1686 } 1667 }
1687 if (mem) { 1668 if (mem) {
1688 mem_range = kmalloc(sizeof(*mem_range), GFP_KERNEL); 1669 mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL);
1689 if (!mem_range) { 1670 if (!mem_range) {
1690 err ("out of system memory\n"); 1671 err ("out of system memory\n");
1691 return -ENOMEM; 1672 return -ENOMEM;
1692 } 1673 }
1693 memset (mem_range, 0, sizeof (struct range_node));
1694 mem_range->start = mem->start; 1674 mem_range->start = mem->start;
1695 mem_range->end = mem->end; 1675 mem_range->end = mem->end;
1696 mem_range->rangeno = 1; 1676 mem_range->rangeno = 1;
@@ -1698,12 +1678,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
1698 bus->rangeMem = mem_range; 1678 bus->rangeMem = mem_range;
1699 } 1679 }
1700 if (pfmem) { 1680 if (pfmem) {
1701 pfmem_range = kmalloc(sizeof(*pfmem_range), GFP_KERNEL); 1681 pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL);
1702 if (!pfmem_range) { 1682 if (!pfmem_range) {
1703 err ("out of system memory\n"); 1683 err ("out of system memory\n");
1704 return -ENOMEM; 1684 return -ENOMEM;
1705 } 1685 }
1706 memset (pfmem_range, 0, sizeof (struct range_node));
1707 pfmem_range->start = pfmem->start; 1686 pfmem_range->start = pfmem->start;
1708 pfmem_range->end = pfmem->end; 1687 pfmem_range->end = pfmem->end;
1709 pfmem_range->rangeno = 1; 1688 pfmem_range->rangeno = 1;