@@ -72,13 +72,7 @@ static int ebda_rio_table (void);
7272
7373static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void )
7474{
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 );
8276}
8377
8478static 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)
8781 struct ebda_hpc_slot * slots ;
8882 struct ebda_hpc_bus * buses ;
8983
90- controller = kmalloc (sizeof (struct controller ), GFP_KERNEL );
84+ controller = kzalloc (sizeof (struct controller ), GFP_KERNEL );
9185 if (!controller )
9286 goto error ;
93- memset (controller , 0 , sizeof (* controller ));
9487
95- slots = kmalloc ( sizeof (struct ebda_hpc_slot ) * slot_count , GFP_KERNEL );
88+ slots = kcalloc ( slot_count , sizeof (struct ebda_hpc_slot ), GFP_KERNEL );
9689 if (!slots )
9790 goto error_contr ;
98- memset (slots , 0 , sizeof (* slots ) * slot_count );
9991 controller -> slots = slots ;
10092
101- buses = kmalloc ( sizeof (struct ebda_hpc_bus ) * bus_count , GFP_KERNEL );
93+ buses = kcalloc ( bus_count , sizeof (struct ebda_hpc_bus ), GFP_KERNEL );
10294 if (!buses )
10395 goto error_slots ;
104- memset (buses , 0 , sizeof (* buses ) * bus_count );
10596 controller -> buses = buses ;
10697
10798 return controller ;
@@ -122,24 +113,12 @@ static void free_ebda_hpc (struct controller *controller)
122113
123114static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void )
124115{
125- struct ebda_rsrc_list * list ;
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 ;
116+ return kzalloc (sizeof (struct ebda_rsrc_list ), GFP_KERNEL );
132117}
133118
134119static struct ebda_pci_rsrc * alloc_ebda_pci_rsrc (void )
135120{
136- struct ebda_pci_rsrc * resource ;
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 ;
121+ return kzalloc (sizeof (struct ebda_pci_rsrc ), GFP_KERNEL );
143122}
144123
145124static void __init print_bus_info (void )
@@ -390,10 +369,9 @@ int __init ibmphp_access_ebda (void)
390369 debug ("now enter io table ---\n" );
391370 debug ("rio blk id: %x\n" , blk_id );
392371
393- rio_table_ptr = kmalloc (sizeof (struct rio_table_hdr ), GFP_KERNEL );
372+ rio_table_ptr = kzalloc (sizeof (struct rio_table_hdr ), GFP_KERNEL );
394373 if (!rio_table_ptr )
395374 return - ENOMEM ;
396- memset (rio_table_ptr , 0 , sizeof (struct rio_table_hdr ) );
397375 rio_table_ptr -> ver_num = readb (io_mem + offset );
398376 rio_table_ptr -> scal_count = readb (io_mem + offset + 1 );
399377 rio_table_ptr -> riodev_count = readb (io_mem + offset + 2 );
@@ -445,10 +423,9 @@ static int __init ebda_rio_table (void)
445423
446424 // we do concern about rio details
447425 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 );
449427 if (!rio_detail_ptr )
450428 return - ENOMEM ;
451- memset (rio_detail_ptr , 0 , sizeof (struct rio_detail ));
452429 rio_detail_ptr -> rio_node_id = readb (io_mem + offset );
453430 rio_detail_ptr -> bbar = readl (io_mem + offset + 1 );
454431 rio_detail_ptr -> rio_type = readb (io_mem + offset + 5 );
@@ -503,10 +480,9 @@ static int __init combine_wpg_for_chassis (void)
503480 rio_detail_ptr = list_entry (list_head_ptr , struct rio_detail , rio_detail_list );
504481 opt_rio_ptr = search_opt_vg (rio_detail_ptr -> chassis_num );
505482 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 );
507484 if (!opt_rio_ptr )
508485 return - ENOMEM ;
509- memset (opt_rio_ptr , 0 , sizeof (struct opt_rio ));
510486 opt_rio_ptr -> rio_type = rio_detail_ptr -> rio_type ;
511487 opt_rio_ptr -> chassis_num = rio_detail_ptr -> chassis_num ;
512488 opt_rio_ptr -> first_slot_num = rio_detail_ptr -> first_slot_num ;
@@ -546,10 +522,9 @@ static int combine_wpg_for_expansion (void)
546522 rio_detail_ptr = list_entry (list_head_ptr , struct rio_detail , rio_detail_list );
547523 opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr -> chassis_num );
548524 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 );
550526 if (!opt_rio_lo_ptr )
551527 return - ENOMEM ;
552- memset (opt_rio_lo_ptr , 0 , sizeof (struct opt_rio_lo ));
553528 opt_rio_lo_ptr -> rio_type = rio_detail_ptr -> rio_type ;
554529 opt_rio_lo_ptr -> chassis_num = rio_detail_ptr -> chassis_num ;
555530 opt_rio_lo_ptr -> first_slot_num = rio_detail_ptr -> first_slot_num ;
@@ -842,12 +817,11 @@ static int __init ebda_rsrc_controller (void)
842817
843818 bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr -> slot_bus_num );
844819 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 );
846821 if (!bus_info_ptr1 ) {
847822 rc = - ENOMEM ;
848823 goto error_no_hp_slot ;
849824 }
850- memset (bus_info_ptr1 , 0 , sizeof (struct bus_info ));
851825 bus_info_ptr1 -> slot_min = slot_ptr -> slot_num ;
852826 bus_info_ptr1 -> slot_max = slot_ptr -> slot_num ;
853827 bus_info_ptr1 -> slot_count += 1 ;
@@ -946,32 +920,29 @@ static int __init ebda_rsrc_controller (void)
946920 // register slots with hpc core as well as create linked list of ibm slot
947921 for (index = 0 ; index < hpc_ptr -> slot_count ; index ++ ) {
948922
949- hp_slot_ptr = kmalloc (sizeof (* hp_slot_ptr ), GFP_KERNEL );
923+ hp_slot_ptr = kzalloc (sizeof (* hp_slot_ptr ), GFP_KERNEL );
950924 if (!hp_slot_ptr ) {
951925 rc = - ENOMEM ;
952926 goto error_no_hp_slot ;
953927 }
954- memset (hp_slot_ptr , 0 , sizeof (* hp_slot_ptr ));
955928
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 );
957930 if (!hp_slot_ptr -> info ) {
958931 rc = - ENOMEM ;
959932 goto error_no_hp_info ;
960933 }
961- memset (hp_slot_ptr -> info , 0 , sizeof (struct hotplug_slot_info ));
962934
963935 hp_slot_ptr -> name = kmalloc (30 , GFP_KERNEL );
964936 if (!hp_slot_ptr -> name ) {
965937 rc = - ENOMEM ;
966938 goto error_no_hp_name ;
967939 }
968940
969- tmp_slot = kmalloc (sizeof (* tmp_slot ), GFP_KERNEL );
941+ tmp_slot = kzalloc (sizeof (* tmp_slot ), GFP_KERNEL );
970942 if (!tmp_slot ) {
971943 rc = - ENOMEM ;
972944 goto error_no_slot ;
973945 }
974- memset (tmp_slot , 0 , sizeof (* tmp_slot ));
975946
976947 tmp_slot -> flag = TRUE;
977948
0 commit comments