aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorakpm@linux-foundation.org <akpm@linux-foundation.org>2008-08-22 16:28:17 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2008-10-20 13:53:44 -0400
commita8d2dbd38481e0c35c6bdd8196dd38a42ae45d02 (patch)
tree0ca9825cbdefab7326682e8aacca616d556ff474 /drivers
parent34a2e15e95fce6d6f4d30162f53a0ceb25d5bbaf (diff)
PCI: ibmphp: list_for_each to list_for_each_entry
Make code more readable with list_for_each_entry(). Signed-off-by: Cordelia Sam <cordesam@gmail.com> Cc: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/hotplug/ibmphp_ebda.c92
1 files changed, 23 insertions, 69 deletions
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index 7d27631e6e62..1bc08a5b2c7d 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -123,10 +123,8 @@ static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void)
123static void __init print_bus_info (void) 123static void __init print_bus_info (void)
124{ 124{
125 struct bus_info *ptr; 125 struct bus_info *ptr;
126 struct list_head *ptr1;
127 126
128 list_for_each (ptr1, &bus_info_head) { 127 list_for_each_entry (ptr, &bus_info_head, bus_info_list) {
129 ptr = list_entry (ptr1, struct bus_info, bus_info_list);
130 debug ("%s - slot_min = %x\n", __func__, ptr->slot_min); 128 debug ("%s - slot_min = %x\n", __func__, ptr->slot_min);
131 debug ("%s - slot_max = %x\n", __func__, ptr->slot_max); 129 debug ("%s - slot_max = %x\n", __func__, ptr->slot_max);
132 debug ("%s - slot_count = %x\n", __func__, ptr->slot_count); 130 debug ("%s - slot_count = %x\n", __func__, ptr->slot_count);
@@ -146,10 +144,8 @@ static void __init print_bus_info (void)
146static void print_lo_info (void) 144static void print_lo_info (void)
147{ 145{
148 struct rio_detail *ptr; 146 struct rio_detail *ptr;
149 struct list_head *ptr1;
150 debug ("print_lo_info ----\n"); 147 debug ("print_lo_info ----\n");
151 list_for_each (ptr1, &rio_lo_head) { 148 list_for_each_entry (ptr, &rio_lo_head, rio_detail_list) {
152 ptr = list_entry (ptr1, struct rio_detail, rio_detail_list);
153 debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); 149 debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id);
154 debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); 150 debug ("%s - rio_type = %x\n", __func__, ptr->rio_type);
155 debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); 151 debug ("%s - owner_id = %x\n", __func__, ptr->owner_id);
@@ -163,10 +159,8 @@ static void print_lo_info (void)
163static void print_vg_info (void) 159static void print_vg_info (void)
164{ 160{
165 struct rio_detail *ptr; 161 struct rio_detail *ptr;
166 struct list_head *ptr1;
167 debug ("%s ---\n", __func__); 162 debug ("%s ---\n", __func__);
168 list_for_each (ptr1, &rio_vg_head) { 163 list_for_each_entry (ptr, &rio_vg_head, rio_detail_list) {
169 ptr = list_entry (ptr1, struct rio_detail, rio_detail_list);
170 debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); 164 debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id);
171 debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); 165 debug ("%s - rio_type = %x\n", __func__, ptr->rio_type);
172 debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); 166 debug ("%s - owner_id = %x\n", __func__, ptr->owner_id);
@@ -180,10 +174,8 @@ static void print_vg_info (void)
180static void __init print_ebda_pci_rsrc (void) 174static void __init print_ebda_pci_rsrc (void)
181{ 175{
182 struct ebda_pci_rsrc *ptr; 176 struct ebda_pci_rsrc *ptr;
183 struct list_head *ptr1;
184 177
185 list_for_each (ptr1, &ibmphp_ebda_pci_rsrc_head) { 178 list_for_each_entry (ptr, &ibmphp_ebda_pci_rsrc_head, ebda_pci_rsrc_list) {
186 ptr = list_entry (ptr1, struct ebda_pci_rsrc, ebda_pci_rsrc_list);
187 debug ("%s - rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", 179 debug ("%s - rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n",
188 __func__, ptr->rsrc_type ,ptr->bus_num, ptr->dev_fun,ptr->start_addr, ptr->end_addr); 180 __func__, ptr->rsrc_type ,ptr->bus_num, ptr->dev_fun,ptr->start_addr, ptr->end_addr);
189 } 181 }
@@ -192,10 +184,8 @@ static void __init print_ebda_pci_rsrc (void)
192static void __init print_ibm_slot (void) 184static void __init print_ibm_slot (void)
193{ 185{
194 struct slot *ptr; 186 struct slot *ptr;
195 struct list_head *ptr1;
196 187
197 list_for_each (ptr1, &ibmphp_slot_head) { 188 list_for_each_entry (ptr, &ibmphp_slot_head, ibm_slot_list) {
198 ptr = list_entry (ptr1, struct slot, ibm_slot_list);
199 debug ("%s - slot_number: %x\n", __func__, ptr->number); 189 debug ("%s - slot_number: %x\n", __func__, ptr->number);
200 } 190 }
201} 191}
@@ -203,10 +193,8 @@ static void __init print_ibm_slot (void)
203static void __init print_opt_vg (void) 193static void __init print_opt_vg (void)
204{ 194{
205 struct opt_rio *ptr; 195 struct opt_rio *ptr;
206 struct list_head *ptr1;
207 debug ("%s ---\n", __func__); 196 debug ("%s ---\n", __func__);
208 list_for_each (ptr1, &opt_vg_head) { 197 list_for_each_entry (ptr, &opt_vg_head, opt_rio_list) {
209 ptr = list_entry (ptr1, struct opt_rio, opt_rio_list);
210 debug ("%s - rio_type %x\n", __func__, ptr->rio_type); 198 debug ("%s - rio_type %x\n", __func__, ptr->rio_type);
211 debug ("%s - chassis_num: %x\n", __func__, ptr->chassis_num); 199 debug ("%s - chassis_num: %x\n", __func__, ptr->chassis_num);
212 debug ("%s - first_slot_num: %x\n", __func__, ptr->first_slot_num); 200 debug ("%s - first_slot_num: %x\n", __func__, ptr->first_slot_num);
@@ -217,13 +205,9 @@ static void __init print_opt_vg (void)
217static void __init print_ebda_hpc (void) 205static void __init print_ebda_hpc (void)
218{ 206{
219 struct controller *hpc_ptr; 207 struct controller *hpc_ptr;
220 struct list_head *ptr1;
221 u16 index; 208 u16 index;
222 209
223 list_for_each (ptr1, &ebda_hpc_head) { 210 list_for_each_entry (hpc_ptr, &ebda_hpc_head, ebda_hpc_list) {
224
225 hpc_ptr = list_entry (ptr1, struct controller, ebda_hpc_list);
226
227 for (index = 0; index < hpc_ptr->slot_count; index++) { 211 for (index = 0; index < hpc_ptr->slot_count; index++) {
228 debug ("%s - physical slot#: %x\n", __func__, hpc_ptr->slots[index].slot_num); 212 debug ("%s - physical slot#: %x\n", __func__, hpc_ptr->slots[index].slot_num);
229 debug ("%s - pci bus# of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_bus_num); 213 debug ("%s - pci bus# of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_bus_num);
@@ -460,9 +444,7 @@ static int __init ebda_rio_table (void)
460static struct opt_rio *search_opt_vg (u8 chassis_num) 444static struct opt_rio *search_opt_vg (u8 chassis_num)
461{ 445{
462 struct opt_rio *ptr; 446 struct opt_rio *ptr;
463 struct list_head *ptr1; 447 list_for_each_entry (ptr, &opt_vg_head, opt_rio_list) {
464 list_for_each (ptr1, &opt_vg_head) {
465 ptr = list_entry (ptr1, struct opt_rio, opt_rio_list);
466 if (ptr->chassis_num == chassis_num) 448 if (ptr->chassis_num == chassis_num)
467 return ptr; 449 return ptr;
468 } 450 }
@@ -473,10 +455,8 @@ static int __init combine_wpg_for_chassis (void)
473{ 455{
474 struct opt_rio *opt_rio_ptr = NULL; 456 struct opt_rio *opt_rio_ptr = NULL;
475 struct rio_detail *rio_detail_ptr = NULL; 457 struct rio_detail *rio_detail_ptr = NULL;
476 struct list_head *list_head_ptr = NULL;
477 458
478 list_for_each (list_head_ptr, &rio_vg_head) { 459 list_for_each_entry (rio_detail_ptr, &rio_vg_head, rio_detail_list) {
479 rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list);
480 opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); 460 opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num);
481 if (!opt_rio_ptr) { 461 if (!opt_rio_ptr) {
482 opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); 462 opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL);
@@ -497,14 +477,12 @@ static int __init combine_wpg_for_chassis (void)
497} 477}
498 478
499/* 479/*
500 * reorgnizing linked list of expansion box 480 * reorganizing linked list of expansion box
501 */ 481 */
502static struct opt_rio_lo *search_opt_lo (u8 chassis_num) 482static struct opt_rio_lo *search_opt_lo (u8 chassis_num)
503{ 483{
504 struct opt_rio_lo *ptr; 484 struct opt_rio_lo *ptr;
505 struct list_head *ptr1; 485 list_for_each_entry (ptr, &opt_lo_head, opt_rio_lo_list) {
506 list_for_each (ptr1, &opt_lo_head) {
507 ptr = list_entry (ptr1, struct opt_rio_lo, opt_rio_lo_list);
508 if (ptr->chassis_num == chassis_num) 486 if (ptr->chassis_num == chassis_num)
509 return ptr; 487 return ptr;
510 } 488 }
@@ -515,10 +493,8 @@ static int combine_wpg_for_expansion (void)
515{ 493{
516 struct opt_rio_lo *opt_rio_lo_ptr = NULL; 494 struct opt_rio_lo *opt_rio_lo_ptr = NULL;
517 struct rio_detail *rio_detail_ptr = NULL; 495 struct rio_detail *rio_detail_ptr = NULL;
518 struct list_head *list_head_ptr = NULL;
519 496
520 list_for_each (list_head_ptr, &rio_lo_head) { 497 list_for_each_entry (rio_detail_ptr, &rio_lo_head, rio_detail_list) {
521 rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list);
522 opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); 498 opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num);
523 if (!opt_rio_lo_ptr) { 499 if (!opt_rio_lo_ptr) {
524 opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); 500 opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL);
@@ -550,20 +526,17 @@ static int first_slot_num (u8 slot_num, u8 first_slot, u8 var)
550{ 526{
551 struct opt_rio *opt_vg_ptr = NULL; 527 struct opt_rio *opt_vg_ptr = NULL;
552 struct opt_rio_lo *opt_lo_ptr = NULL; 528 struct opt_rio_lo *opt_lo_ptr = NULL;
553 struct list_head *ptr = NULL;
554 int rc = 0; 529 int rc = 0;
555 530
556 if (!var) { 531 if (!var) {
557 list_for_each (ptr, &opt_vg_head) { 532 list_for_each_entry (opt_vg_ptr, &opt_vg_head, opt_rio_list) {
558 opt_vg_ptr = list_entry (ptr, struct opt_rio, opt_rio_list);
559 if ((first_slot < opt_vg_ptr->first_slot_num) && (slot_num >= opt_vg_ptr->first_slot_num)) { 533 if ((first_slot < opt_vg_ptr->first_slot_num) && (slot_num >= opt_vg_ptr->first_slot_num)) {
560 rc = -ENODEV; 534 rc = -ENODEV;
561 break; 535 break;
562 } 536 }
563 } 537 }
564 } else { 538 } else {
565 list_for_each (ptr, &opt_lo_head) { 539 list_for_each_entry (opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) {
566 opt_lo_ptr = list_entry (ptr, struct opt_rio_lo, opt_rio_lo_list);
567 if ((first_slot < opt_lo_ptr->first_slot_num) && (slot_num >= opt_lo_ptr->first_slot_num)) { 540 if ((first_slot < opt_lo_ptr->first_slot_num) && (slot_num >= opt_lo_ptr->first_slot_num)) {
568 rc = -ENODEV; 541 rc = -ENODEV;
569 break; 542 break;
@@ -576,10 +549,8 @@ static int first_slot_num (u8 slot_num, u8 first_slot, u8 var)
576static struct opt_rio_lo * find_rxe_num (u8 slot_num) 549static struct opt_rio_lo * find_rxe_num (u8 slot_num)
577{ 550{
578 struct opt_rio_lo *opt_lo_ptr; 551 struct opt_rio_lo *opt_lo_ptr;
579 struct list_head *ptr;
580 552
581 list_for_each (ptr, &opt_lo_head) { 553 list_for_each_entry (opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) {
582 opt_lo_ptr = list_entry (ptr, struct opt_rio_lo, opt_rio_lo_list);
583 //check to see if this slot_num belongs to expansion box 554 //check to see if this slot_num belongs to expansion box
584 if ((slot_num >= opt_lo_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_lo_ptr->first_slot_num, 1))) 555 if ((slot_num >= opt_lo_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_lo_ptr->first_slot_num, 1)))
585 return opt_lo_ptr; 556 return opt_lo_ptr;
@@ -590,10 +561,8 @@ static struct opt_rio_lo * find_rxe_num (u8 slot_num)
590static struct opt_rio * find_chassis_num (u8 slot_num) 561static struct opt_rio * find_chassis_num (u8 slot_num)
591{ 562{
592 struct opt_rio *opt_vg_ptr; 563 struct opt_rio *opt_vg_ptr;
593 struct list_head *ptr;
594 564
595 list_for_each (ptr, &opt_vg_head) { 565 list_for_each_entry (opt_vg_ptr, &opt_vg_head, opt_rio_list) {
596 opt_vg_ptr = list_entry (ptr, struct opt_rio, opt_rio_list);
597 //check to see if this slot_num belongs to chassis 566 //check to see if this slot_num belongs to chassis
598 if ((slot_num >= opt_vg_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_vg_ptr->first_slot_num, 0))) 567 if ((slot_num >= opt_vg_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_vg_ptr->first_slot_num, 0)))
599 return opt_vg_ptr; 568 return opt_vg_ptr;
@@ -607,11 +576,9 @@ static struct opt_rio * find_chassis_num (u8 slot_num)
607static u8 calculate_first_slot (u8 slot_num) 576static u8 calculate_first_slot (u8 slot_num)
608{ 577{
609 u8 first_slot = 1; 578 u8 first_slot = 1;
610 struct list_head * list;
611 struct slot * slot_cur; 579 struct slot * slot_cur;
612 580
613 list_for_each (list, &ibmphp_slot_head) { 581 list_for_each_entry (slot_cur, &ibmphp_slot_head, ibm_slot_list) {
614 slot_cur = list_entry (list, struct slot, ibm_slot_list);
615 if (slot_cur->ctrl) { 582 if (slot_cur->ctrl) {
616 if ((slot_cur->ctrl->ctlr_type != 4) && (slot_cur->ctrl->ending_slot_num > first_slot) && (slot_num > slot_cur->ctrl->ending_slot_num)) 583 if ((slot_cur->ctrl->ctlr_type != 4) && (slot_cur->ctrl->ending_slot_num > first_slot) && (slot_num > slot_cur->ctrl->ending_slot_num))
617 first_slot = slot_cur->ctrl->ending_slot_num; 584 first_slot = slot_cur->ctrl->ending_slot_num;
@@ -767,7 +734,6 @@ static int __init ebda_rsrc_controller (void)
767 struct bus_info *bus_info_ptr1, *bus_info_ptr2; 734 struct bus_info *bus_info_ptr1, *bus_info_ptr2;
768 int rc; 735 int rc;
769 struct slot *tmp_slot; 736 struct slot *tmp_slot;
770 struct list_head *list;
771 737
772 addr = hpc_list_ptr->phys_addr; 738 addr = hpc_list_ptr->phys_addr;
773 for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) { 739 for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) {
@@ -997,9 +963,7 @@ static int __init ebda_rsrc_controller (void)
997 963
998 } /* each hpc */ 964 } /* each hpc */
999 965
1000 list_for_each (list, &ibmphp_slot_head) { 966 list_for_each_entry (tmp_slot, &ibmphp_slot_head, ibm_slot_list) {
1001 tmp_slot = list_entry (list, struct slot, ibm_slot_list);
1002
1003 snprintf (tmp_slot->hotplug_slot->name, 30, "%s", create_file_name (tmp_slot)); 967 snprintf (tmp_slot->hotplug_slot->name, 30, "%s", create_file_name (tmp_slot));
1004 pci_hp_register(tmp_slot->hotplug_slot, 968 pci_hp_register(tmp_slot->hotplug_slot,
1005 pci_find_bus(0, tmp_slot->bus), tmp_slot->device); 969 pci_find_bus(0, tmp_slot->bus), tmp_slot->device);
@@ -1101,10 +1065,8 @@ u16 ibmphp_get_total_controllers (void)
1101struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num) 1065struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num)
1102{ 1066{
1103 struct slot *slot; 1067 struct slot *slot;
1104 struct list_head *list;
1105 1068
1106 list_for_each (list, &ibmphp_slot_head) { 1069 list_for_each_entry (slot, &ibmphp_slot_head, ibm_slot_list) {
1107 slot = list_entry (list, struct slot, ibm_slot_list);
1108 if (slot->number == physical_num) 1070 if (slot->number == physical_num)
1109 return slot; 1071 return slot;
1110 } 1072 }
@@ -1120,10 +1082,8 @@ struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num)
1120struct bus_info *ibmphp_find_same_bus_num (u32 num) 1082struct bus_info *ibmphp_find_same_bus_num (u32 num)
1121{ 1083{
1122 struct bus_info *ptr; 1084 struct bus_info *ptr;
1123 struct list_head *ptr1;
1124 1085
1125 list_for_each (ptr1, &bus_info_head) { 1086 list_for_each_entry (ptr, &bus_info_head, bus_info_list) {
1126 ptr = list_entry (ptr1, struct bus_info, bus_info_list);
1127 if (ptr->busno == num) 1087 if (ptr->busno == num)
1128 return ptr; 1088 return ptr;
1129 } 1089 }
@@ -1136,10 +1096,8 @@ struct bus_info *ibmphp_find_same_bus_num (u32 num)
1136int ibmphp_get_bus_index (u8 num) 1096int ibmphp_get_bus_index (u8 num)
1137{ 1097{
1138 struct bus_info *ptr; 1098 struct bus_info *ptr;
1139 struct list_head *ptr1;
1140 1099
1141 list_for_each (ptr1, &bus_info_head) { 1100 list_for_each_entry (ptr, &bus_info_head, bus_info_list) {
1142 ptr = list_entry (ptr1, struct bus_info, bus_info_list);
1143 if (ptr->busno == num) 1101 if (ptr->busno == num)
1144 return ptr->index; 1102 return ptr->index;
1145 } 1103 }
@@ -1212,11 +1170,9 @@ static struct pci_driver ibmphp_driver = {
1212int ibmphp_register_pci (void) 1170int ibmphp_register_pci (void)
1213{ 1171{
1214 struct controller *ctrl; 1172 struct controller *ctrl;
1215 struct list_head *tmp;
1216 int rc = 0; 1173 int rc = 0;
1217 1174
1218 list_for_each (tmp, &ebda_hpc_head) { 1175 list_for_each_entry (ctrl, &ebda_hpc_head, ebda_hpc_list) {
1219 ctrl = list_entry (tmp, struct controller, ebda_hpc_list);
1220 if (ctrl->ctlr_type == 1) { 1176 if (ctrl->ctlr_type == 1) {
1221 rc = pci_register_driver(&ibmphp_driver); 1177 rc = pci_register_driver(&ibmphp_driver);
1222 break; 1178 break;
@@ -1227,12 +1183,10 @@ int ibmphp_register_pci (void)
1227static int ibmphp_probe (struct pci_dev * dev, const struct pci_device_id *ids) 1183static int ibmphp_probe (struct pci_dev * dev, const struct pci_device_id *ids)
1228{ 1184{
1229 struct controller *ctrl; 1185 struct controller *ctrl;
1230 struct list_head *tmp;
1231 1186
1232 debug ("inside ibmphp_probe\n"); 1187 debug ("inside ibmphp_probe\n");
1233 1188
1234 list_for_each (tmp, &ebda_hpc_head) { 1189 list_for_each_entry (ctrl, &ebda_hpc_head, ebda_hpc_list) {
1235 ctrl = list_entry (tmp, struct controller, ebda_hpc_list);
1236 if (ctrl->ctlr_type == 1) { 1190 if (ctrl->ctlr_type == 1) {
1237 if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) { 1191 if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) {
1238 ctrl->ctrl_dev = dev; 1192 ctrl->ctrl_dev = dev;