Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66455f54 authored by Bjorn Helgaas's avatar Bjorn Helgaas
Browse files

PCI: Use list_for_each_entry() for bus->devices traversal



Replace list_for_each() + pci_dev_b() with the simpler
list_for_each_entry().

Tested-by: default avatarYijing Wang <wangyijing@huawei.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Acked-by: default avatarYinghai Lu <yinghai@kernel.org>
parent 125e14bb
Loading
Loading
Loading
Loading
+6 −7
Original line number Original line Diff line number Diff line
@@ -114,16 +114,17 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev)


static void __pci_remove_behind_bridge(struct pci_dev *dev)
static void __pci_remove_behind_bridge(struct pci_dev *dev)
{
{
	struct list_head *l, *n;
	struct pci_dev *child, *tmp;


	if (dev->subordinate)
	if (dev->subordinate)
		list_for_each_safe(l, n, &dev->subordinate->devices)
		list_for_each_entry_safe(child, tmp,
			__pci_remove_bus_device(pci_dev_b(l));
					 &dev->subordinate->devices, bus_list)
			__pci_remove_bus_device(child);
}
}


static void pci_stop_bus_devices(struct pci_bus *bus)
static void pci_stop_bus_devices(struct pci_bus *bus)
{
{
	struct list_head *l, *n;
	struct pci_dev *dev, *tmp;


	/*
	/*
	 * VFs could be removed by pci_stop_and_remove_bus_device() in the
	 * VFs could be removed by pci_stop_and_remove_bus_device() in the
@@ -133,11 +134,9 @@ static void pci_stop_bus_devices(struct pci_bus *bus)
	 * We can iterate the list backwards to get prev valid PF instead
	 * We can iterate the list backwards to get prev valid PF instead
	 *  of removed VF.
	 *  of removed VF.
	 */
	 */
	list_for_each_prev_safe(l, n, &bus->devices) {
	list_for_each_entry_safe_reverse(dev, tmp, &bus->devices, bus_list)
		struct pci_dev *dev = pci_dev_b(l);
		pci_stop_bus_device(dev);
		pci_stop_bus_device(dev);
}
}
}


/**
/**
 * pci_stop_bus_device - stop a PCI device and any children
 * pci_stop_bus_device - stop a PCI device and any children
+2 −4
Original line number Original line Diff line number Diff line
@@ -132,14 +132,12 @@ pci_find_next_bus(const struct pci_bus *from)
 */
 */
struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn)
struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn)
{
{
	struct list_head *tmp;
	struct pci_dev *dev;
	struct pci_dev *dev;


	WARN_ON(in_interrupt());
	WARN_ON(in_interrupt());
	down_read(&pci_bus_sem);
	down_read(&pci_bus_sem);


	list_for_each(tmp, &bus->devices) {
	list_for_each_entry(dev, &bus->devices, bus_list) {
		dev = pci_dev_b(tmp);
		if (dev->devfn == devfn)
		if (dev->devfn == devfn)
			goto out;
			goto out;
	}
	}