diff options
author | Eric Sesterhenn <snakebyte@gmx.de> | 2006-02-28 09:34:49 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-23 17:35:17 -0500 |
commit | f5afe8064f3087bead8fea7e32547c2a3ada5fd0 (patch) | |
tree | de6a9d60aad6ee262c04290d73e414cd92b4ad5d /drivers/pci/hotplug/ibmphp_ebda.c | |
parent | 7c8f25da12a3dda46fb730699582895d5fc51287 (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_ebda.c')
-rw-r--r-- | drivers/pci/hotplug/ibmphp_ebda.c | 57 |
1 files changed, 14 insertions, 43 deletions
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c index aea1187c73ad..ba12034c5d3a 100644 --- a/drivers/pci/hotplug/ibmphp_ebda.c +++ b/drivers/pci/hotplug/ibmphp_ebda.c | |||
@@ -72,13 +72,7 @@ static int ebda_rio_table (void); | |||
72 | 72 | ||
73 | static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void) | 73 | static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void) |
74 | { | 74 | { |
75 | struct ebda_hpc_list *list; | 75 | return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL); |
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; | ||
82 | } | 76 | } |
83 | 77 | ||
84 | static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) | 78 | static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) |
@@ -87,21 +81,18 @@ static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) | |||
87 | struct ebda_hpc_slot *slots; | 81 | struct ebda_hpc_slot *slots; |
88 | struct ebda_hpc_bus *buses; | 82 | struct ebda_hpc_bus *buses; |
89 | 83 | ||
90 | controller = kmalloc (sizeof (struct controller), GFP_KERNEL); | 84 | controller = kzalloc(sizeof(struct controller), GFP_KERNEL); |
91 | if (!controller) | 85 | if (!controller) |
92 | goto error; | 86 | goto error; |
93 | memset (controller, 0, sizeof (*controller)); | ||
94 | 87 | ||
95 | slots = kmalloc (sizeof (struct ebda_hpc_slot) * slot_count, GFP_KERNEL); | 88 | slots = kcalloc(slot_count, sizeof(struct ebda_hpc_slot), GFP_KERNEL); |
96 | if (!slots) | 89 | if (!slots) |
97 | goto error_contr; | 90 | goto error_contr; |
98 | memset (slots, 0, sizeof (*slots) * slot_count); | ||
99 | controller->slots = slots; | 91 | controller->slots = slots; |
100 | 92 | ||
101 | buses = kmalloc (sizeof (struct ebda_hpc_bus) * bus_count, GFP_KERNEL); | 93 | buses = kcalloc(bus_count, sizeof(struct ebda_hpc_bus), GFP_KERNEL); |
102 | if (!buses) | 94 | if (!buses) |
103 | goto error_slots; | 95 | goto error_slots; |
104 | memset (buses, 0, sizeof (*buses) * bus_count); | ||
105 | controller->buses = buses; | 96 | controller->buses = buses; |
106 | 97 | ||
107 | return controller; | 98 | return controller; |
@@ -122,24 +113,12 @@ static void free_ebda_hpc (struct controller *controller) | |||
122 | 113 | ||
123 | static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void) | 114 | static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void) |
124 | { | 115 | { |
125 | struct ebda_rsrc_list *list; | 116 | return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL); |
126 | |||
127 | list = kmalloc (sizeof (struct ebda_rsrc_list), GFP_KERNEL); | ||
128 | if (!list) | ||
129 | return NULL; | ||
130 | memset (list, 0, sizeof (*list)); | ||
131 | return list; | ||
132 | } | 117 | } |
133 | 118 | ||
134 | static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void) | 119 | static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void) |
135 | { | 120 | { |
136 | struct ebda_pci_rsrc *resource; | 121 | return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL); |
137 | |||
138 | resource = kmalloc (sizeof (struct ebda_pci_rsrc), GFP_KERNEL); | ||
139 | if (!resource) | ||
140 | return NULL; | ||
141 | memset (resource, 0, sizeof (*resource)); | ||
142 | return resource; | ||
143 | } | 122 | } |
144 | 123 | ||
145 | static void __init print_bus_info (void) | 124 | static void __init print_bus_info (void) |
@@ -390,10 +369,9 @@ int __init ibmphp_access_ebda (void) | |||
390 | debug ("now enter io table ---\n"); | 369 | debug ("now enter io table ---\n"); |
391 | debug ("rio blk id: %x\n", blk_id); | 370 | debug ("rio blk id: %x\n", blk_id); |
392 | 371 | ||
393 | rio_table_ptr = kmalloc (sizeof (struct rio_table_hdr), GFP_KERNEL); | 372 | rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL); |
394 | if (!rio_table_ptr) | 373 | if (!rio_table_ptr) |
395 | return -ENOMEM; | 374 | return -ENOMEM; |
396 | memset (rio_table_ptr, 0, sizeof (struct rio_table_hdr) ); | ||
397 | rio_table_ptr->ver_num = readb (io_mem + offset); | 375 | rio_table_ptr->ver_num = readb (io_mem + offset); |
398 | rio_table_ptr->scal_count = readb (io_mem + offset + 1); | 376 | rio_table_ptr->scal_count = readb (io_mem + offset + 1); |
399 | rio_table_ptr->riodev_count = readb (io_mem + offset + 2); | 377 | rio_table_ptr->riodev_count = readb (io_mem + offset + 2); |
@@ -445,10 +423,9 @@ static int __init ebda_rio_table (void) | |||
445 | 423 | ||
446 | // we do concern about rio details | 424 | // we do concern about rio details |
447 | for (i = 0; i < rio_table_ptr->riodev_count; i++) { | 425 | for (i = 0; i < rio_table_ptr->riodev_count; i++) { |
448 | rio_detail_ptr = kmalloc (sizeof (struct rio_detail), GFP_KERNEL); | 426 | rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL); |
449 | if (!rio_detail_ptr) | 427 | if (!rio_detail_ptr) |
450 | return -ENOMEM; | 428 | return -ENOMEM; |
451 | memset (rio_detail_ptr, 0, sizeof (struct rio_detail)); | ||
452 | rio_detail_ptr->rio_node_id = readb (io_mem + offset); | 429 | rio_detail_ptr->rio_node_id = readb (io_mem + offset); |
453 | rio_detail_ptr->bbar = readl (io_mem + offset + 1); | 430 | rio_detail_ptr->bbar = readl (io_mem + offset + 1); |
454 | rio_detail_ptr->rio_type = readb (io_mem + offset + 5); | 431 | rio_detail_ptr->rio_type = readb (io_mem + offset + 5); |
@@ -503,10 +480,9 @@ static int __init combine_wpg_for_chassis (void) | |||
503 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); | 480 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); |
504 | opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); | 481 | opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); |
505 | if (!opt_rio_ptr) { | 482 | if (!opt_rio_ptr) { |
506 | opt_rio_ptr = (struct opt_rio *) kmalloc (sizeof (struct opt_rio), GFP_KERNEL); | 483 | opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); |
507 | if (!opt_rio_ptr) | 484 | if (!opt_rio_ptr) |
508 | return -ENOMEM; | 485 | return -ENOMEM; |
509 | memset (opt_rio_ptr, 0, sizeof (struct opt_rio)); | ||
510 | opt_rio_ptr->rio_type = rio_detail_ptr->rio_type; | 486 | opt_rio_ptr->rio_type = rio_detail_ptr->rio_type; |
511 | opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num; | 487 | opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num; |
512 | opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num; | 488 | opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num; |
@@ -546,10 +522,9 @@ static int combine_wpg_for_expansion (void) | |||
546 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); | 522 | rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list); |
547 | opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); | 523 | opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); |
548 | if (!opt_rio_lo_ptr) { | 524 | if (!opt_rio_lo_ptr) { |
549 | opt_rio_lo_ptr = (struct opt_rio_lo *) kmalloc (sizeof (struct opt_rio_lo), GFP_KERNEL); | 525 | opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); |
550 | if (!opt_rio_lo_ptr) | 526 | if (!opt_rio_lo_ptr) |
551 | return -ENOMEM; | 527 | return -ENOMEM; |
552 | memset (opt_rio_lo_ptr, 0, sizeof (struct opt_rio_lo)); | ||
553 | opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type; | 528 | opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type; |
554 | opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num; | 529 | opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num; |
555 | opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num; | 530 | opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num; |
@@ -842,12 +817,11 @@ static int __init ebda_rsrc_controller (void) | |||
842 | 817 | ||
843 | bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num); | 818 | bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num); |
844 | if (!bus_info_ptr2) { | 819 | if (!bus_info_ptr2) { |
845 | bus_info_ptr1 = (struct bus_info *) kmalloc (sizeof (struct bus_info), GFP_KERNEL); | 820 | bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL); |
846 | if (!bus_info_ptr1) { | 821 | if (!bus_info_ptr1) { |
847 | rc = -ENOMEM; | 822 | rc = -ENOMEM; |
848 | goto error_no_hp_slot; | 823 | goto error_no_hp_slot; |
849 | } | 824 | } |
850 | memset (bus_info_ptr1, 0, sizeof (struct bus_info)); | ||
851 | bus_info_ptr1->slot_min = slot_ptr->slot_num; | 825 | bus_info_ptr1->slot_min = slot_ptr->slot_num; |
852 | bus_info_ptr1->slot_max = slot_ptr->slot_num; | 826 | bus_info_ptr1->slot_max = slot_ptr->slot_num; |
853 | bus_info_ptr1->slot_count += 1; | 827 | bus_info_ptr1->slot_count += 1; |
@@ -946,19 +920,17 @@ static int __init ebda_rsrc_controller (void) | |||
946 | // register slots with hpc core as well as create linked list of ibm slot | 920 | // register slots with hpc core as well as create linked list of ibm slot |
947 | for (index = 0; index < hpc_ptr->slot_count; index++) { | 921 | for (index = 0; index < hpc_ptr->slot_count; index++) { |
948 | 922 | ||
949 | hp_slot_ptr = kmalloc(sizeof(*hp_slot_ptr), GFP_KERNEL); | 923 | hp_slot_ptr = kzalloc(sizeof(*hp_slot_ptr), GFP_KERNEL); |
950 | if (!hp_slot_ptr) { | 924 | if (!hp_slot_ptr) { |
951 | rc = -ENOMEM; | 925 | rc = -ENOMEM; |
952 | goto error_no_hp_slot; | 926 | goto error_no_hp_slot; |
953 | } | 927 | } |
954 | memset(hp_slot_ptr, 0, sizeof(*hp_slot_ptr)); | ||
955 | 928 | ||
956 | hp_slot_ptr->info = kmalloc (sizeof(struct hotplug_slot_info), GFP_KERNEL); | 929 | hp_slot_ptr->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); |
957 | if (!hp_slot_ptr->info) { | 930 | if (!hp_slot_ptr->info) { |
958 | rc = -ENOMEM; | 931 | rc = -ENOMEM; |
959 | goto error_no_hp_info; | 932 | goto error_no_hp_info; |
960 | } | 933 | } |
961 | memset(hp_slot_ptr->info, 0, sizeof(struct hotplug_slot_info)); | ||
962 | 934 | ||
963 | hp_slot_ptr->name = kmalloc(30, GFP_KERNEL); | 935 | hp_slot_ptr->name = kmalloc(30, GFP_KERNEL); |
964 | if (!hp_slot_ptr->name) { | 936 | if (!hp_slot_ptr->name) { |
@@ -966,12 +938,11 @@ static int __init ebda_rsrc_controller (void) | |||
966 | goto error_no_hp_name; | 938 | goto error_no_hp_name; |
967 | } | 939 | } |
968 | 940 | ||
969 | tmp_slot = kmalloc(sizeof(*tmp_slot), GFP_KERNEL); | 941 | tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL); |
970 | if (!tmp_slot) { | 942 | if (!tmp_slot) { |
971 | rc = -ENOMEM; | 943 | rc = -ENOMEM; |
972 | goto error_no_slot; | 944 | goto error_no_slot; |
973 | } | 945 | } |
974 | memset(tmp_slot, 0, sizeof(*tmp_slot)); | ||
975 | 946 | ||
976 | tmp_slot->flag = TRUE; | 947 | tmp_slot->flag = TRUE; |
977 | 948 | ||