diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2012-08-17 17:53:27 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-08-22 13:31:37 -0400 |
commit | 66455f5472383df3632140e04f0852215e5c9ce8 (patch) | |
tree | 647bff405ef4cbdd01b1dba594e632b715029e54 /drivers/pci | |
parent | 125e14bb35e65b1ddfb7252fa8f6e3c50dbb6db2 (diff) |
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: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/remove.c | 13 | ||||
-rw-r--r-- | drivers/pci/search.c | 6 |
2 files changed, 8 insertions, 11 deletions
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index b18dc2ef09f2..f17a02781e67 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c | |||
@@ -114,16 +114,17 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev) | |||
114 | 114 | ||
115 | static void __pci_remove_behind_bridge(struct pci_dev *dev) | 115 | static void __pci_remove_behind_bridge(struct pci_dev *dev) |
116 | { | 116 | { |
117 | struct list_head *l, *n; | 117 | struct pci_dev *child, *tmp; |
118 | 118 | ||
119 | if (dev->subordinate) | 119 | if (dev->subordinate) |
120 | list_for_each_safe(l, n, &dev->subordinate->devices) | 120 | list_for_each_entry_safe(child, tmp, |
121 | __pci_remove_bus_device(pci_dev_b(l)); | 121 | &dev->subordinate->devices, bus_list) |
122 | __pci_remove_bus_device(child); | ||
122 | } | 123 | } |
123 | 124 | ||
124 | static void pci_stop_bus_devices(struct pci_bus *bus) | 125 | static void pci_stop_bus_devices(struct pci_bus *bus) |
125 | { | 126 | { |
126 | struct list_head *l, *n; | 127 | struct pci_dev *dev, *tmp; |
127 | 128 | ||
128 | /* | 129 | /* |
129 | * VFs could be removed by pci_stop_and_remove_bus_device() in the | 130 | * 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 | * We can iterate the list backwards to get prev valid PF instead | 134 | * We can iterate the list backwards to get prev valid PF instead |
134 | * of removed VF. | 135 | * of removed VF. |
135 | */ | 136 | */ |
136 | list_for_each_prev_safe(l, n, &bus->devices) { | 137 | list_for_each_entry_safe_reverse(dev, tmp, &bus->devices, bus_list) |
137 | struct pci_dev *dev = pci_dev_b(l); | ||
138 | pci_stop_bus_device(dev); | 138 | pci_stop_bus_device(dev); |
139 | } | ||
140 | } | 139 | } |
141 | 140 | ||
142 | /** | 141 | /** |
diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 993d4a0a2469..f56b2377cc01 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c | |||
@@ -130,16 +130,14 @@ pci_find_next_bus(const struct pci_bus *from) | |||
130 | * decrement the reference count by calling pci_dev_put(). | 130 | * decrement the reference count by calling pci_dev_put(). |
131 | * If no device is found, %NULL is returned. | 131 | * If no device is found, %NULL is returned. |
132 | */ | 132 | */ |
133 | struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn) | 133 | struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn) |
134 | { | 134 | { |
135 | struct list_head *tmp; | ||
136 | struct pci_dev *dev; | 135 | struct pci_dev *dev; |
137 | 136 | ||
138 | WARN_ON(in_interrupt()); | 137 | WARN_ON(in_interrupt()); |
139 | down_read(&pci_bus_sem); | 138 | down_read(&pci_bus_sem); |
140 | 139 | ||
141 | list_for_each(tmp, &bus->devices) { | 140 | list_for_each_entry(dev, &bus->devices, bus_list) { |
142 | dev = pci_dev_b(tmp); | ||
143 | if (dev->devfn == devfn) | 141 | if (dev->devfn == devfn) |
144 | goto out; | 142 | goto out; |
145 | } | 143 | } |