提交 66455f54 编写于 作者: B Bjorn Helgaas

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: NYijing Wang <wangyijing@huawei.com>
Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
Acked-by: NYinghai Lu <yinghai@kernel.org>
上级 125e14bb
...@@ -114,16 +114,17 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev) ...@@ -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,10 +134,8 @@ static void pci_stop_bus_devices(struct pci_bus *bus) ...@@ -133,10 +134,8 @@ 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);
}
} }
/** /**
......
...@@ -130,16 +130,14 @@ pci_find_next_bus(const struct pci_bus *from) ...@@ -130,16 +130,14 @@ pci_find_next_bus(const struct pci_bus *from)
* decrement the reference count by calling pci_dev_put(). * decrement the reference count by calling pci_dev_put().
* If no device is found, %NULL is returned. * If no device is found, %NULL is returned.
*/ */
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;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册