Skip to content

Commit a8d2dbd

Browse files
akpm00jbarnes993
authored andcommitted
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>
1 parent 34a2e15 commit a8d2dbd

1 file changed

Lines changed: 23 additions & 69 deletions

File tree

‎drivers/pci/hotplug/ibmphp_ebda.c‎

Lines changed: 23 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,8 @@ static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void)
123123
static void __init print_bus_info (void)
124124
{
125125
struct bus_info *ptr;
126-
struct list_head *ptr1;
127126

128-
list_for_each (ptr1, &bus_info_head) {
129-
ptr = list_entry (ptr1, struct bus_info, bus_info_list);
127+
list_for_each_entry (ptr, &bus_info_head, bus_info_list) {
130128
debug ("%s - slot_min = %x\n", __func__, ptr->slot_min);
131129
debug ("%s - slot_max = %x\n", __func__, ptr->slot_max);
132130
debug ("%s - slot_count = %x\n", __func__, ptr->slot_count);
@@ -146,10 +144,8 @@ static void __init print_bus_info (void)
146144
static void print_lo_info (void)
147145
{
148146
struct rio_detail *ptr;
149-
struct list_head *ptr1;
150147
debug ("print_lo_info ----\n");
151-
list_for_each (ptr1, &rio_lo_head) {
152-
ptr = list_entry (ptr1, struct rio_detail, rio_detail_list);
148+
list_for_each_entry (ptr, &rio_lo_head, rio_detail_list) {
153149
debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id);
154150
debug ("%s - rio_type = %x\n", __func__, ptr->rio_type);
155151
debug ("%s - owner_id = %x\n", __func__, ptr->owner_id);
@@ -163,10 +159,8 @@ static void print_lo_info (void)
163159
static void print_vg_info (void)
164160
{
165161
struct rio_detail *ptr;
166-
struct list_head *ptr1;
167162
debug ("%s ---\n", __func__);
168-
list_for_each (ptr1, &rio_vg_head) {
169-
ptr = list_entry (ptr1, struct rio_detail, rio_detail_list);
163+
list_for_each_entry (ptr, &rio_vg_head, rio_detail_list) {
170164
debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id);
171165
debug ("%s - rio_type = %x\n", __func__, ptr->rio_type);
172166
debug ("%s - owner_id = %x\n", __func__, ptr->owner_id);
@@ -180,10 +174,8 @@ static void print_vg_info (void)
180174
static void __init print_ebda_pci_rsrc (void)
181175
{
182176
struct ebda_pci_rsrc *ptr;
183-
struct list_head *ptr1;
184177

185-
list_for_each (ptr1, &ibmphp_ebda_pci_rsrc_head) {
186-
ptr = list_entry (ptr1, struct ebda_pci_rsrc, ebda_pci_rsrc_list);
178+
list_for_each_entry (ptr, &ibmphp_ebda_pci_rsrc_head, ebda_pci_rsrc_list) {
187179
debug ("%s - rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n",
188180
__func__, ptr->rsrc_type ,ptr->bus_num, ptr->dev_fun,ptr->start_addr, ptr->end_addr);
189181
}
@@ -192,21 +184,17 @@ static void __init print_ebda_pci_rsrc (void)
192184
static void __init print_ibm_slot (void)
193185
{
194186
struct slot *ptr;
195-
struct list_head *ptr1;
196187

197-
list_for_each (ptr1, &ibmphp_slot_head) {
198-
ptr = list_entry (ptr1, struct slot, ibm_slot_list);
188+
list_for_each_entry (ptr, &ibmphp_slot_head, ibm_slot_list) {
199189
debug ("%s - slot_number: %x\n", __func__, ptr->number);
200190
}
201191
}
202192

203193
static void __init print_opt_vg (void)
204194
{
205195
struct opt_rio *ptr;
206-
struct list_head *ptr1;
207196
debug ("%s ---\n", __func__);
208-
list_for_each (ptr1, &opt_vg_head) {
209-
ptr = list_entry (ptr1, struct opt_rio, opt_rio_list);
197+
list_for_each_entry (ptr, &opt_vg_head, opt_rio_list) {
210198
debug ("%s - rio_type %x\n", __func__, ptr->rio_type);
211199
debug ("%s - chassis_num: %x\n", __func__, ptr->chassis_num);
212200
debug ("%s - first_slot_num: %x\n", __func__, ptr->first_slot_num);
@@ -217,13 +205,9 @@ static void __init print_opt_vg (void)
217205
static void __init print_ebda_hpc (void)
218206
{
219207
struct controller *hpc_ptr;
220-
struct list_head *ptr1;
221208
u16 index;
222209

223-
list_for_each (ptr1, &ebda_hpc_head) {
224-
225-
hpc_ptr = list_entry (ptr1, struct controller, ebda_hpc_list);
226-
210+
list_for_each_entry (hpc_ptr, &ebda_hpc_head, ebda_hpc_list) {
227211
for (index = 0; index < hpc_ptr->slot_count; index++) {
228212
debug ("%s - physical slot#: %x\n", __func__, hpc_ptr->slots[index].slot_num);
229213
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)
460444
static struct opt_rio *search_opt_vg (u8 chassis_num)
461445
{
462446
struct opt_rio *ptr;
463-
struct list_head *ptr1;
464-
list_for_each (ptr1, &opt_vg_head) {
465-
ptr = list_entry (ptr1, struct opt_rio, opt_rio_list);
447+
list_for_each_entry (ptr, &opt_vg_head, opt_rio_list) {
466448
if (ptr->chassis_num == chassis_num)
467449
return ptr;
468450
}
@@ -473,10 +455,8 @@ static int __init combine_wpg_for_chassis (void)
473455
{
474456
struct opt_rio *opt_rio_ptr = NULL;
475457
struct rio_detail *rio_detail_ptr = NULL;
476-
struct list_head *list_head_ptr = NULL;
477458

478-
list_for_each (list_head_ptr, &rio_vg_head) {
479-
rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list);
459+
list_for_each_entry (rio_detail_ptr, &rio_vg_head, rio_detail_list) {
480460
opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num);
481461
if (!opt_rio_ptr) {
482462
opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL);
@@ -497,14 +477,12 @@ static int __init combine_wpg_for_chassis (void)
497477
}
498478

499479
/*
500-
* reorgnizing linked list of expansion box
480+
* reorganizing linked list of expansion box
501481
*/
502482
static struct opt_rio_lo *search_opt_lo (u8 chassis_num)
503483
{
504484
struct opt_rio_lo *ptr;
505-
struct list_head *ptr1;
506-
list_for_each (ptr1, &opt_lo_head) {
507-
ptr = list_entry (ptr1, struct opt_rio_lo, opt_rio_lo_list);
485+
list_for_each_entry (ptr, &opt_lo_head, opt_rio_lo_list) {
508486
if (ptr->chassis_num == chassis_num)
509487
return ptr;
510488
}
@@ -515,10 +493,8 @@ static int combine_wpg_for_expansion (void)
515493
{
516494
struct opt_rio_lo *opt_rio_lo_ptr = NULL;
517495
struct rio_detail *rio_detail_ptr = NULL;
518-
struct list_head *list_head_ptr = NULL;
519496

520-
list_for_each (list_head_ptr, &rio_lo_head) {
521-
rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list);
497+
list_for_each_entry (rio_detail_ptr, &rio_lo_head, rio_detail_list) {
522498
opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num);
523499
if (!opt_rio_lo_ptr) {
524500
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)
550526
{
551527
struct opt_rio *opt_vg_ptr = NULL;
552528
struct opt_rio_lo *opt_lo_ptr = NULL;
553-
struct list_head *ptr = NULL;
554529
int rc = 0;
555530

556531
if (!var) {
557-
list_for_each (ptr, &opt_vg_head) {
558-
opt_vg_ptr = list_entry (ptr, struct opt_rio, opt_rio_list);
532+
list_for_each_entry (opt_vg_ptr, &opt_vg_head, opt_rio_list) {
559533
if ((first_slot < opt_vg_ptr->first_slot_num) && (slot_num >= opt_vg_ptr->first_slot_num)) {
560534
rc = -ENODEV;
561535
break;
562536
}
563537
}
564538
} else {
565-
list_for_each (ptr, &opt_lo_head) {
566-
opt_lo_ptr = list_entry (ptr, struct opt_rio_lo, opt_rio_lo_list);
539+
list_for_each_entry (opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) {
567540
if ((first_slot < opt_lo_ptr->first_slot_num) && (slot_num >= opt_lo_ptr->first_slot_num)) {
568541
rc = -ENODEV;
569542
break;
@@ -576,10 +549,8 @@ static int first_slot_num (u8 slot_num, u8 first_slot, u8 var)
576549
static struct opt_rio_lo * find_rxe_num (u8 slot_num)
577550
{
578551
struct opt_rio_lo *opt_lo_ptr;
579-
struct list_head *ptr;
580552

581-
list_for_each (ptr, &opt_lo_head) {
582-
opt_lo_ptr = list_entry (ptr, struct opt_rio_lo, opt_rio_lo_list);
553+
list_for_each_entry (opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) {
583554
//check to see if this slot_num belongs to expansion box
584555
if ((slot_num >= opt_lo_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_lo_ptr->first_slot_num, 1)))
585556
return opt_lo_ptr;
@@ -590,10 +561,8 @@ static struct opt_rio_lo * find_rxe_num (u8 slot_num)
590561
static struct opt_rio * find_chassis_num (u8 slot_num)
591562
{
592563
struct opt_rio *opt_vg_ptr;
593-
struct list_head *ptr;
594564

595-
list_for_each (ptr, &opt_vg_head) {
596-
opt_vg_ptr = list_entry (ptr, struct opt_rio, opt_rio_list);
565+
list_for_each_entry (opt_vg_ptr, &opt_vg_head, opt_rio_list) {
597566
//check to see if this slot_num belongs to chassis
598567
if ((slot_num >= opt_vg_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_vg_ptr->first_slot_num, 0)))
599568
return opt_vg_ptr;
@@ -607,11 +576,9 @@ static struct opt_rio * find_chassis_num (u8 slot_num)
607576
static u8 calculate_first_slot (u8 slot_num)
608577
{
609578
u8 first_slot = 1;
610-
struct list_head * list;
611579
struct slot * slot_cur;
612580

613-
list_for_each (list, &ibmphp_slot_head) {
614-
slot_cur = list_entry (list, struct slot, ibm_slot_list);
581+
list_for_each_entry (slot_cur, &ibmphp_slot_head, ibm_slot_list) {
615582
if (slot_cur->ctrl) {
616583
if ((slot_cur->ctrl->ctlr_type != 4) && (slot_cur->ctrl->ending_slot_num > first_slot) && (slot_num > slot_cur->ctrl->ending_slot_num))
617584
first_slot = slot_cur->ctrl->ending_slot_num;
@@ -767,7 +734,6 @@ static int __init ebda_rsrc_controller (void)
767734
struct bus_info *bus_info_ptr1, *bus_info_ptr2;
768735
int rc;
769736
struct slot *tmp_slot;
770-
struct list_head *list;
771737

772738
addr = hpc_list_ptr->phys_addr;
773739
for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) {
@@ -997,9 +963,7 @@ static int __init ebda_rsrc_controller (void)
997963

998964
} /* each hpc */
999965

1000-
list_for_each (list, &ibmphp_slot_head) {
1001-
tmp_slot = list_entry (list, struct slot, ibm_slot_list);
1002-
966+
list_for_each_entry (tmp_slot, &ibmphp_slot_head, ibm_slot_list) {
1003967
snprintf (tmp_slot->hotplug_slot->name, 30, "%s", create_file_name (tmp_slot));
1004968
pci_hp_register(tmp_slot->hotplug_slot,
1005969
pci_find_bus(0, tmp_slot->bus), tmp_slot->device);
@@ -1101,10 +1065,8 @@ u16 ibmphp_get_total_controllers (void)
11011065
struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num)
11021066
{
11031067
struct slot *slot;
1104-
struct list_head *list;
11051068

1106-
list_for_each (list, &ibmphp_slot_head) {
1107-
slot = list_entry (list, struct slot, ibm_slot_list);
1069+
list_for_each_entry (slot, &ibmphp_slot_head, ibm_slot_list) {
11081070
if (slot->number == physical_num)
11091071
return slot;
11101072
}
@@ -1120,10 +1082,8 @@ struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num)
11201082
struct bus_info *ibmphp_find_same_bus_num (u32 num)
11211083
{
11221084
struct bus_info *ptr;
1123-
struct list_head *ptr1;
11241085

1125-
list_for_each (ptr1, &bus_info_head) {
1126-
ptr = list_entry (ptr1, struct bus_info, bus_info_list);
1086+
list_for_each_entry (ptr, &bus_info_head, bus_info_list) {
11271087
if (ptr->busno == num)
11281088
return ptr;
11291089
}
@@ -1136,10 +1096,8 @@ struct bus_info *ibmphp_find_same_bus_num (u32 num)
11361096
int ibmphp_get_bus_index (u8 num)
11371097
{
11381098
struct bus_info *ptr;
1139-
struct list_head *ptr1;
11401099

1141-
list_for_each (ptr1, &bus_info_head) {
1142-
ptr = list_entry (ptr1, struct bus_info, bus_info_list);
1100+
list_for_each_entry (ptr, &bus_info_head, bus_info_list) {
11431101
if (ptr->busno == num)
11441102
return ptr->index;
11451103
}
@@ -1212,11 +1170,9 @@ static struct pci_driver ibmphp_driver = {
12121170
int ibmphp_register_pci (void)
12131171
{
12141172
struct controller *ctrl;
1215-
struct list_head *tmp;
12161173
int rc = 0;
12171174

1218-
list_for_each (tmp, &ebda_hpc_head) {
1219-
ctrl = list_entry (tmp, struct controller, ebda_hpc_list);
1175+
list_for_each_entry (ctrl, &ebda_hpc_head, ebda_hpc_list) {
12201176
if (ctrl->ctlr_type == 1) {
12211177
rc = pci_register_driver(&ibmphp_driver);
12221178
break;
@@ -1227,12 +1183,10 @@ int ibmphp_register_pci (void)
12271183
static int ibmphp_probe (struct pci_dev * dev, const struct pci_device_id *ids)
12281184
{
12291185
struct controller *ctrl;
1230-
struct list_head *tmp;
12311186

12321187
debug ("inside ibmphp_probe\n");
12331188

1234-
list_for_each (tmp, &ebda_hpc_head) {
1235-
ctrl = list_entry (tmp, struct controller, ebda_hpc_list);
1189+
list_for_each_entry (ctrl, &ebda_hpc_head, ebda_hpc_list) {
12361190
if (ctrl->ctlr_type == 1) {
12371191
if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) {
12381192
ctrl->ctrl_dev = dev;

0 commit comments

Comments
 (0)