Skip to content

Commit 9e8bf93

Browse files
Ram Paijbarnes993
authored andcommitted
PCI: code and comments cleanup
a) adjust_resource_sorted() is now called reassign_resource_sorted() b) nice-to-have is now called optional c) add_list is now called realloc_list. Signed-off-by: Ram Pai <[email protected]> Signed-off-by: Jesse Barnes <[email protected]>
1 parent 0a2daa1 commit 9e8bf93

File tree

1 file changed

+55
-55
lines changed

1 file changed

+55
-55
lines changed

drivers/pci/setup-bus.c

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,18 @@ static inline void reset_resource(struct resource *res)
125125
}
126126

127127
/**
128-
* adjust_resources_sorted() - satisfy any additional resource requests
128+
* reassign_resources_sorted() - satisfy any additional resource requests
129129
*
130-
* @add_head : head of the list tracking requests requiring additional
130+
* @realloc_head : head of the list tracking requests requiring additional
131131
* resources
132132
* @head : head of the list tracking requests with allocated
133133
* resources
134134
*
135-
* Walk through each element of the add_head and try to procure
135+
* Walk through each element of the realloc_head and try to procure
136136
* additional resources for the element, provided the element
137137
* is in the head list.
138138
*/
139-
static void adjust_resources_sorted(struct resource_list_x *add_head,
139+
static void reassign_resources_sorted(struct resource_list_x *realloc_head,
140140
struct resource_list *head)
141141
{
142142
struct resource *res;
@@ -145,8 +145,8 @@ static void adjust_resources_sorted(struct resource_list_x *add_head,
145145
resource_size_t add_size;
146146
int idx;
147147

148-
prev = add_head;
149-
for (list = add_head->next; list;) {
148+
prev = realloc_head;
149+
for (list = realloc_head->next; list;) {
150150
res = list->res;
151151
/* skip resource that has been reset */
152152
if (!res->flags)
@@ -218,16 +218,16 @@ static void assign_requested_resources_sorted(struct resource_list *head,
218218
}
219219

220220
static void __assign_resources_sorted(struct resource_list *head,
221-
struct resource_list_x *add_head,
221+
struct resource_list_x *realloc_head,
222222
struct resource_list_x *fail_head)
223223
{
224224
/* Satisfy the must-have resource requests */
225225
assign_requested_resources_sorted(head, fail_head);
226226

227227
/* Try to satisfy any additional optional resource
228228
requests */
229-
if (add_head)
230-
adjust_resources_sorted(add_head, head);
229+
if (realloc_head)
230+
reassign_resources_sorted(realloc_head, head);
231231
free_list(resource_list, head);
232232
}
233233

@@ -243,7 +243,7 @@ static void pdev_assign_resources_sorted(struct pci_dev *dev,
243243
}
244244

245245
static void pbus_assign_resources_sorted(const struct pci_bus *bus,
246-
struct resource_list_x *add_head,
246+
struct resource_list_x *realloc_head,
247247
struct resource_list_x *fail_head)
248248
{
249249
struct pci_dev *dev;
@@ -253,7 +253,7 @@ static void pbus_assign_resources_sorted(const struct pci_bus *bus,
253253
list_for_each_entry(dev, &bus->devices, bus_list)
254254
__dev_sort_resources(dev, &head);
255255

256-
__assign_resources_sorted(&head, add_head, fail_head);
256+
__assign_resources_sorted(&head, realloc_head, fail_head);
257257
}
258258

259259
void pci_setup_cardbus(struct pci_bus *bus)
@@ -548,13 +548,13 @@ static resource_size_t calculate_memsize(resource_size_t size,
548548
return size;
549549
}
550550

551-
static resource_size_t get_res_add_size(struct resource_list_x *add_head,
551+
static resource_size_t get_res_add_size(struct resource_list_x *realloc_head,
552552
struct resource *res)
553553
{
554554
struct resource_list_x *list;
555555

556-
/* check if it is in add_head list */
557-
for (list = add_head->next; list && list->res != res;
556+
/* check if it is in realloc_head list */
557+
for (list = realloc_head->next; list && list->res != res;
558558
list = list->next);
559559
if (list)
560560
return list->add_size;
@@ -568,15 +568,15 @@ static resource_size_t get_res_add_size(struct resource_list_x *add_head,
568568
* @bus : the bus
569569
* @min_size : the minimum io window that must to be allocated
570570
* @add_size : additional optional io window
571-
* @add_head : track the additional io window on this list
571+
* @realloc_head : track the additional io window on this list
572572
*
573573
* Sizing the IO windows of the PCI-PCI bridge is trivial,
574574
* since these windows have 4K granularity and the IO ranges
575575
* of non-bridge PCI devices are limited to 256 bytes.
576576
* We must be careful with the ISA aliasing though.
577577
*/
578578
static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
579-
resource_size_t add_size, struct resource_list_x *add_head)
579+
resource_size_t add_size, struct resource_list_x *realloc_head)
580580
{
581581
struct pci_dev *dev;
582582
struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO);
@@ -603,15 +603,15 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
603603
else
604604
size1 += r_size;
605605

606-
if (add_head)
607-
children_add_size += get_res_add_size(add_head, r);
606+
if (realloc_head)
607+
children_add_size += get_res_add_size(realloc_head, r);
608608
}
609609
}
610610
size0 = calculate_iosize(size, min_size, size1,
611611
resource_size(b_res), 4096);
612612
if (children_add_size > add_size)
613613
add_size = children_add_size;
614-
size1 = (!add_head || (add_head && !add_size)) ? size0 :
614+
size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 :
615615
calculate_iosize(size, min_size+add_size, size1,
616616
resource_size(b_res), 4096);
617617
if (!size0 && !size1) {
@@ -626,8 +626,8 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
626626
b_res->start = 4096;
627627
b_res->end = b_res->start + size0 - 1;
628628
b_res->flags |= IORESOURCE_STARTALIGN;
629-
if (size1 > size0 && add_head)
630-
add_to_list(add_head, bus->self, b_res, size1-size0, 4096);
629+
if (size1 > size0 && realloc_head)
630+
add_to_list(realloc_head, bus->self, b_res, size1-size0, 4096);
631631
}
632632

633633
/**
@@ -636,15 +636,15 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
636636
* @bus : the bus
637637
* @min_size : the minimum memory window that must to be allocated
638638
* @add_size : additional optional memory window
639-
* @add_head : track the additional memory window on this list
639+
* @realloc_head : track the additional memory window on this list
640640
*
641641
* Calculate the size of the bus and minimal alignment which
642642
* guarantees that all child resources fit in this size.
643643
*/
644644
static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
645645
unsigned long type, resource_size_t min_size,
646646
resource_size_t add_size,
647-
struct resource_list_x *add_head)
647+
struct resource_list_x *realloc_head)
648648
{
649649
struct pci_dev *dev;
650650
resource_size_t min_align, align, size, size0, size1;
@@ -676,10 +676,10 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
676676
r_size = resource_size(r);
677677
#ifdef CONFIG_PCI_IOV
678678
/* put SRIOV requested res to the optional list */
679-
if (add_head && i >= PCI_IOV_RESOURCES &&
679+
if (realloc_head && i >= PCI_IOV_RESOURCES &&
680680
i <= PCI_IOV_RESOURCE_END) {
681681
r->end = r->start - 1;
682-
add_to_list(add_head, dev, r, r_size, 0/* dont' care */);
682+
add_to_list(realloc_head, dev, r, r_size, 0/* dont' care */);
683683
children_add_size += r_size;
684684
continue;
685685
}
@@ -705,8 +705,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
705705
max_order = order;
706706
mem64_mask &= r->flags & IORESOURCE_MEM_64;
707707

708-
if (add_head)
709-
children_add_size += get_res_add_size(add_head, r);
708+
if (realloc_head)
709+
children_add_size += get_res_add_size(realloc_head, r);
710710
}
711711
}
712712
align = 0;
@@ -725,7 +725,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
725725
size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align);
726726
if (children_add_size > add_size)
727727
add_size = children_add_size;
728-
size1 = (!add_head || (add_head && !add_size)) ? size0 :
728+
size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 :
729729
calculate_memsize(size, min_size+add_size, 0,
730730
resource_size(b_res), min_align);
731731
if (!size0 && !size1) {
@@ -739,8 +739,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
739739
b_res->start = min_align;
740740
b_res->end = size0 + min_align - 1;
741741
b_res->flags |= IORESOURCE_STARTALIGN | mem64_mask;
742-
if (size1 > size0 && add_head)
743-
add_to_list(add_head, bus->self, b_res, size1-size0, min_align);
742+
if (size1 > size0 && realloc_head)
743+
add_to_list(realloc_head, bus->self, b_res, size1-size0, min_align);
744744
return 1;
745745
}
746746

@@ -754,7 +754,7 @@ unsigned long pci_cardbus_resource_alignment(struct resource *res)
754754
}
755755

756756
static void pci_bus_size_cardbus(struct pci_bus *bus,
757-
struct resource_list_x *add_head)
757+
struct resource_list_x *realloc_head)
758758
{
759759
struct pci_dev *bridge = bus->self;
760760
struct resource *b_res = &bridge->resource[PCI_BRIDGE_RESOURCES];
@@ -766,13 +766,13 @@ static void pci_bus_size_cardbus(struct pci_bus *bus,
766766
*/
767767
b_res[0].start = 0;
768768
b_res[0].flags |= IORESOURCE_IO | IORESOURCE_SIZEALIGN;
769-
if (add_head)
770-
add_to_list(add_head, bridge, b_res, pci_cardbus_io_size, 0 /* dont care */);
769+
if (realloc_head)
770+
add_to_list(realloc_head, bridge, b_res, pci_cardbus_io_size, 0 /* dont care */);
771771

772772
b_res[1].start = 0;
773773
b_res[1].flags |= IORESOURCE_IO | IORESOURCE_SIZEALIGN;
774-
if (add_head)
775-
add_to_list(add_head, bridge, b_res+1, pci_cardbus_io_size, 0 /* dont care */);
774+
if (realloc_head)
775+
add_to_list(realloc_head, bridge, b_res+1, pci_cardbus_io_size, 0 /* dont care */);
776776

777777
/*
778778
* Check whether prefetchable memory is supported
@@ -793,18 +793,18 @@ static void pci_bus_size_cardbus(struct pci_bus *bus,
793793
if (ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM0) {
794794
b_res[2].start = 0;
795795
b_res[2].flags |= IORESOURCE_MEM | IORESOURCE_PREFETCH | IORESOURCE_SIZEALIGN;
796-
if (add_head)
797-
add_to_list(add_head, bridge, b_res+2, pci_cardbus_mem_size, 0 /* dont care */);
796+
if (realloc_head)
797+
add_to_list(realloc_head, bridge, b_res+2, pci_cardbus_mem_size, 0 /* dont care */);
798798

799799
b_res[3].start = 0;
800800
b_res[3].flags |= IORESOURCE_MEM | IORESOURCE_SIZEALIGN;
801-
if (add_head)
802-
add_to_list(add_head, bridge, b_res+3, pci_cardbus_mem_size, 0 /* dont care */);
801+
if (realloc_head)
802+
add_to_list(realloc_head, bridge, b_res+3, pci_cardbus_mem_size, 0 /* dont care */);
803803
} else {
804804
b_res[3].start = 0;
805805
b_res[3].flags |= IORESOURCE_MEM | IORESOURCE_SIZEALIGN;
806-
if (add_head)
807-
add_to_list(add_head, bridge, b_res+3, pci_cardbus_mem_size * 2, 0 /* dont care */);
806+
if (realloc_head)
807+
add_to_list(realloc_head, bridge, b_res+3, pci_cardbus_mem_size * 2, 0 /* dont care */);
808808
}
809809

810810
/* set the size of the resource to zero, so that the resource does not
@@ -816,7 +816,7 @@ static void pci_bus_size_cardbus(struct pci_bus *bus,
816816
}
817817

818818
void __ref __pci_bus_size_bridges(struct pci_bus *bus,
819-
struct resource_list_x *add_head)
819+
struct resource_list_x *realloc_head)
820820
{
821821
struct pci_dev *dev;
822822
unsigned long mask, prefmask;
@@ -829,12 +829,12 @@ void __ref __pci_bus_size_bridges(struct pci_bus *bus,
829829

830830
switch (dev->class >> 8) {
831831
case PCI_CLASS_BRIDGE_CARDBUS:
832-
pci_bus_size_cardbus(b, add_head);
832+
pci_bus_size_cardbus(b, realloc_head);
833833
break;
834834

835835
case PCI_CLASS_BRIDGE_PCI:
836836
default:
837-
__pci_bus_size_bridges(b, add_head);
837+
__pci_bus_size_bridges(b, realloc_head);
838838
break;
839839
}
840840
}
@@ -858,19 +858,19 @@ void __ref __pci_bus_size_bridges(struct pci_bus *bus,
858858
* Follow thru
859859
*/
860860
default:
861-
pbus_size_io(bus, 0, additional_io_size, add_head);
861+
pbus_size_io(bus, 0, additional_io_size, realloc_head);
862862
/* If the bridge supports prefetchable range, size it
863863
separately. If it doesn't, or its prefetchable window
864864
has already been allocated by arch code, try
865865
non-prefetchable range for both types of PCI memory
866866
resources. */
867867
mask = IORESOURCE_MEM;
868868
prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH;
869-
if (pbus_size_mem(bus, prefmask, prefmask, 0, additional_mem_size, add_head))
869+
if (pbus_size_mem(bus, prefmask, prefmask, 0, additional_mem_size, realloc_head))
870870
mask = prefmask; /* Success, size non-prefetch only. */
871871
else
872872
additional_mem_size += additional_mem_size;
873-
pbus_size_mem(bus, mask, IORESOURCE_MEM, 0, additional_mem_size, add_head);
873+
pbus_size_mem(bus, mask, IORESOURCE_MEM, 0, additional_mem_size, realloc_head);
874874
break;
875875
}
876876
}
@@ -882,20 +882,20 @@ void __ref pci_bus_size_bridges(struct pci_bus *bus)
882882
EXPORT_SYMBOL(pci_bus_size_bridges);
883883

884884
static void __ref __pci_bus_assign_resources(const struct pci_bus *bus,
885-
struct resource_list_x *add_head,
885+
struct resource_list_x *realloc_head,
886886
struct resource_list_x *fail_head)
887887
{
888888
struct pci_bus *b;
889889
struct pci_dev *dev;
890890

891-
pbus_assign_resources_sorted(bus, add_head, fail_head);
891+
pbus_assign_resources_sorted(bus, realloc_head, fail_head);
892892

893893
list_for_each_entry(dev, &bus->devices, bus_list) {
894894
b = dev->subordinate;
895895
if (!b)
896896
continue;
897897

898-
__pci_bus_assign_resources(b, add_head, fail_head);
898+
__pci_bus_assign_resources(b, realloc_head, fail_head);
899899

900900
switch (dev->class >> 8) {
901901
case PCI_CLASS_BRIDGE_PCI:
@@ -1105,7 +1105,7 @@ void __init
11051105
pci_assign_unassigned_resources(void)
11061106
{
11071107
struct pci_bus *bus;
1108-
struct resource_list_x add_list; /* list of resources that
1108+
struct resource_list_x realloc_list; /* list of resources that
11091109
want additional resources */
11101110
int tried_times = 0;
11111111
enum release_type rel_type = leaf_only;
@@ -1118,7 +1118,7 @@ pci_assign_unassigned_resources(void)
11181118

11191119

11201120
head.next = NULL;
1121-
add_list.next = NULL;
1121+
realloc_list.next = NULL;
11221122

11231123
pci_try_num = max_depth + 1;
11241124
printk(KERN_DEBUG "PCI: max bus depth: %d pci_try_num: %d\n",
@@ -1128,12 +1128,12 @@ pci_assign_unassigned_resources(void)
11281128
/* Depth first, calculate sizes and alignments of all
11291129
subordinate buses. */
11301130
list_for_each_entry(bus, &pci_root_buses, node)
1131-
__pci_bus_size_bridges(bus, &add_list);
1131+
__pci_bus_size_bridges(bus, &realloc_list);
11321132

11331133
/* Depth last, allocate resources and update the hardware. */
11341134
list_for_each_entry(bus, &pci_root_buses, node)
1135-
__pci_bus_assign_resources(bus, &add_list, &head);
1136-
BUG_ON(add_list.next);
1135+
__pci_bus_assign_resources(bus, &realloc_list, &head);
1136+
BUG_ON(realloc_list.next);
11371137
tried_times++;
11381138

11391139
/* any device complain? */

0 commit comments

Comments
 (0)