Skip to content

Commit

Permalink
Merge branch 'pci/list-for-each-entry' into next
Browse files Browse the repository at this point in the history
* pci/list-for-each-entry:
  PCI: Remove pci_bus_b() and use list_for_each_entry() directly
  pcmcia: Use list_for_each_entry() for bus traversal
  powerpc/PCI: Use list_for_each_entry() for bus traversal
  drm: Use list_for_each_entry() for bus traversal
  ARM/PCI: Use list_for_each_entry() for bus traversal
  ACPI / hotplug / PCI: Use list_for_each_entry() for bus traversal
  • Loading branch information
Bjorn Helgaas committed Feb 18, 2014
2 parents c128856 + 94e6a9b commit 6354647
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 33 deletions.
7 changes: 2 additions & 5 deletions arch/arm/kernel/bios32.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in

void pcibios_report_status(u_int status_mask, int warn)
{
struct list_head *l;

list_for_each(l, &pci_root_buses) {
struct pci_bus *bus = pci_bus_b(l);
struct pci_bus *bus;

list_for_each_entry(bus, &pci_root_buses, node)
pcibios_bus_report_status(bus, status_mask, warn);
}
}

/*
Expand Down
4 changes: 1 addition & 3 deletions arch/powerpc/kernel/pci_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
unsigned long in_devfn)
{
struct pci_controller* hose;
struct list_head *ln;
struct pci_bus *bus = NULL;
struct device_node *hose_node;

Expand All @@ -230,8 +229,7 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
* used on pre-domains setup. We return the first match
*/

for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
bus = pci_bus_b(ln);
list_for_each_entry(bus, &pci_root_buses, node) {
if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
break;
bus = NULL;
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/platforms/pseries/pci_dlpar.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ find_bus_among_children(struct pci_bus *bus,
struct device_node *dn)
{
struct pci_bus *child = NULL;
struct list_head *tmp;
struct pci_bus *tmp;
struct device_node *busdn;

busdn = pci_bus_to_OF_node(bus);
if (busdn == dn)
return bus;

list_for_each(tmp, &bus->children) {
child = find_bus_among_children(pci_bus_b(tmp), dn);
list_for_each_entry(tmp, &bus->children, node) {
child = find_bus_among_children(tmp, dn);
if (child)
break;
};
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/drm_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
pci_dev_put(pci_dev);
}
if (!dev->hose) {
struct pci_bus *b = pci_bus_b(pci_root_buses.next);
struct pci_bus *b = list_entry(pci_root_buses.next,
struct pci_bus, node);
if (b)
dev->hose = b->sysdata;
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/pci/hotplug/acpiphp_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
*/
static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
{
struct list_head *tmp;
struct pci_bus *tmp;
unsigned char max, n;

/*
Expand All @@ -463,8 +463,8 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
*/
max = bus->busn_res.start;

list_for_each(tmp, &bus->children) {
n = pci_bus_max_busnr(pci_bus_b(tmp));
list_for_each_entry(tmp, &bus->children, node) {
n = pci_bus_max_busnr(tmp);
if (n > max)
max = n;
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ static bool pcie_ari_disabled;
*/
unsigned char pci_bus_max_busnr(struct pci_bus* bus)
{
struct list_head *tmp;
struct pci_bus *tmp;
unsigned char max, n;

max = bus->busn_res.end;
list_for_each(tmp, &bus->children) {
n = pci_bus_max_busnr(pci_bus_b(tmp));
list_for_each_entry(tmp, &bus->children, node) {
n = pci_bus_max_busnr(tmp);
if(n > max)
max = n;
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/pci/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ pci_find_upstream_pcie_bridge(struct pci_dev *pdev)

static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
{
struct pci_bus* child;
struct list_head *tmp;
struct pci_bus *child;
struct pci_bus *tmp;

if(bus->number == busnr)
return bus;

list_for_each(tmp, &bus->children) {
child = pci_do_find_bus(pci_bus_b(tmp), busnr);
list_for_each_entry(tmp, &bus->children, node) {
child = pci_do_find_bus(tmp, busnr);
if(child)
return child;
}
Expand Down Expand Up @@ -111,7 +111,7 @@ pci_find_next_bus(const struct pci_bus *from)
down_read(&pci_bus_sem);
n = from ? from->node.next : pci_root_buses.next;
if (n != &pci_root_buses)
b = pci_bus_b(n);
b = list_entry(n, struct pci_bus, node);
up_read(&pci_bus_sem);
return b;
}
Expand Down
18 changes: 9 additions & 9 deletions drivers/pcmcia/yenta_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ static void yenta_config_init(struct yenta_socket *socket)
*/
static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
{
struct list_head *tmp;
struct pci_bus *sibling;
unsigned char upper_limit;
/*
* We only check and fix the parent bridge: All systems which need
Expand All @@ -1095,18 +1095,18 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
/* stay within the limits of the bus range of the parent: */
upper_limit = bridge_to_fix->parent->busn_res.end;

/* check the bus ranges of all silbling bridges to prevent overlap */
list_for_each(tmp, &bridge_to_fix->parent->children) {
struct pci_bus *silbling = pci_bus_b(tmp);
/* check the bus ranges of all sibling bridges to prevent overlap */
list_for_each_entry(sibling, &bridge_to_fix->parent->children,
node) {
/*
* If the silbling has a higher secondary bus number
* If the sibling has a higher secondary bus number
* and it's secondary is equal or smaller than our
* current upper limit, set the new upper limit to
* the bus number below the silbling's range:
* the bus number below the sibling's range:
*/
if (silbling->busn_res.start > bridge_to_fix->busn_res.end
&& silbling->busn_res.start <= upper_limit)
upper_limit = silbling->busn_res.start - 1;
if (sibling->busn_res.start > bridge_to_fix->busn_res.end
&& sibling->busn_res.start <= upper_limit)
upper_limit = sibling->busn_res.start - 1;
}

/* Show that the wanted subordinate number is not possible: */
Expand Down
1 change: 0 additions & 1 deletion include/linux/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ struct pci_bus {
unsigned int is_added:1;
};

#define pci_bus_b(n) list_entry(n, struct pci_bus, node)
#define to_pci_bus(n) container_of(n, struct pci_bus, dev)

/*
Expand Down

0 comments on commit 6354647

Please sign in to comment.