* [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal
@ 2012-08-16 23:26 Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 2/6] frv/PCI: " Bjorn Helgaas
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2012-08-16 23:26 UTC (permalink / raw)
To: linux-pci
Replace list_for_each() + pci_dev_b() with the simpler
list_for_each_entry().
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/remove.c | 28 ++++++++++++++--------------
drivers/pci/search.c | 4 +---
2 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 04a4861..d867056 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -111,22 +111,24 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev)
__pci_remove_bus_device(dev);
}
-static void __pci_remove_behind_bridge(struct pci_dev *dev)
+static void __pci_remove_behind_bridge(struct pci_dev *bridge)
{
- struct list_head *l, *n;
+ struct pci_bus *bus = bridge->subordinate;
+ struct pci_dev *dev, *tmp;
- if (dev->subordinate)
- list_for_each_safe(l, n, &dev->subordinate->devices)
- __pci_remove_bus_device(pci_dev_b(l));
+ if (bus)
+ list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list)
+ __pci_remove_bus_device(dev);
}
-static void pci_stop_behind_bridge(struct pci_dev *dev)
+static void pci_stop_behind_bridge(struct pci_dev *bridge)
{
- struct list_head *l, *n;
+ struct pci_bus *bus = bridge->subordinate;
+ struct pci_dev *dev, *tmp;
- if (dev->subordinate)
- list_for_each_safe(l, n, &dev->subordinate->devices)
- pci_stop_bus_device(pci_dev_b(l));
+ if (bus)
+ list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list)
+ pci_stop_bus_device(dev);
}
/**
@@ -146,7 +148,7 @@ void pci_stop_and_remove_behind_bridge(struct pci_dev *dev)
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
@@ -156,10 +158,8 @@ static void pci_stop_bus_devices(struct pci_bus *bus)
* We can iterate the list backwards to get prev valid PF instead
* of removed VF.
*/
- list_for_each_prev_safe(l, n, &bus->devices) {
- struct pci_dev *dev = pci_dev_b(l);
+ list_for_each_entry_safe_reverse(dev, tmp, &bus->devices, bus_list)
pci_stop_bus_device(dev);
- }
}
/**
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 993d4a0..b169390 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -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 list_head *tmp;
struct pci_dev *dev;
WARN_ON(in_interrupt());
down_read(&pci_bus_sem);
- list_for_each(tmp, &bus->devices) {
- dev = pci_dev_b(tmp);
+ list_for_each_entry(dev, &bus->devices, bus_list) {
if (dev->devfn == devfn)
goto out;
}
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/6] frv/PCI: Use list_for_each_entry() for bus->devices traversal
2012-08-16 23:26 [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
@ 2012-08-16 23:26 ` Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 3/6] parisc/PCI: Enable PERR/SERR on all devices Bjorn Helgaas
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2012-08-16 23:26 UTC (permalink / raw)
To: linux-pci; +Cc: David Howells
Replace open-coded list traversal with list_for_each_entry().
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: David Howells <dhowells@redhat.com>
---
arch/frv/mb93090-mb00/pci-vdk.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index d04ed14..71e9bcf 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -330,10 +330,8 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
pci_read_bridge_bases(bus);
if (bus->number == 0) {
- struct list_head *ln;
struct pci_dev *dev;
- for (ln=bus->devices.next; ln != &bus->devices; ln=ln->next) {
- dev = pci_dev_b(ln);
+ list_for_each_entry(dev, &bus->devices, bus_list) {
if (dev->devfn == 0) {
dev->resource[0].start = 0;
dev->resource[0].end = 0;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] parisc/PCI: Enable PERR/SERR on all devices
2012-08-16 23:26 [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 2/6] frv/PCI: " Bjorn Helgaas
@ 2012-08-16 23:26 ` Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 4/6] parisc/PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2012-08-16 23:26 UTC (permalink / raw)
To: linux-pci; +Cc: linux-parisc
Previously, we enabled PERR & SERR for the first device on the bus, but
left other devices alone.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: linux-parisc@vger.kernel.org
---
drivers/parisc/lba_pci.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 4f9cf24..4ce57c9 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -630,6 +630,7 @@ static void
lba_fixup_bus(struct pci_bus *bus)
{
struct list_head *ln;
+ struct pci_dev *dev;
#ifdef FBB_SUPPORT
u16 status;
#endif
@@ -712,8 +713,8 @@ lba_fixup_bus(struct pci_bus *bus)
list_for_each(ln, &bus->devices) {
int i;
- struct pci_dev *dev = pci_dev_b(ln);
+ dev = pci_dev_b(ln);
DBG("lba_fixup_bus() %s\n", pci_name(dev));
/* Virtualize Device/Bridge Resources. */
@@ -771,6 +772,7 @@ lba_fixup_bus(struct pci_bus *bus)
/* Lastly enable FBB/PERR/SERR on all devices too */
list_for_each(ln, &bus->devices) {
+ dev = pci_dev_b(ln);
(void) pci_read_config_word(dev, PCI_COMMAND, &status);
status |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR | fbb_enable;
(void) pci_write_config_word(dev, PCI_COMMAND, status);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] parisc/PCI: Use list_for_each_entry() for bus->devices traversal
2012-08-16 23:26 [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 2/6] frv/PCI: " Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 3/6] parisc/PCI: Enable PERR/SERR on all devices Bjorn Helgaas
@ 2012-08-16 23:26 ` Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 5/6] sgi-agp: " Bjorn Helgaas
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2012-08-16 23:26 UTC (permalink / raw)
To: linux-pci; +Cc: linux-parisc
Replace list_for_each() + pci_dev_b() with the simpler
list_for_each_entry().
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: linux-parisc@vger.kernel.org
---
drivers/parisc/dino.c | 6 ++----
drivers/parisc/lba_pci.c | 7 ++-----
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index ffddc4f..4581ee0 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -477,14 +477,12 @@ dino_card_setup(struct pci_bus *bus, void __iomem *base_addr)
if (ccio_allocate_resource(dino_dev->hba.dev, res, _8MB,
F_EXTEND(0xf0000000UL) | _8MB,
F_EXTEND(0xffffffffUL) &~ _8MB, _8MB) < 0) {
- struct list_head *ln, *tmp_ln;
+ struct pci_dev *dev, *tmp;
printk(KERN_ERR "Dino: cannot attach bus %s\n",
dev_name(bus->bridge));
/* kill the bus, we can't do anything with it */
- list_for_each_safe(ln, tmp_ln, &bus->devices) {
- struct pci_dev *dev = pci_dev_b(ln);
-
+ list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
list_del(&dev->bus_list);
}
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 4ce57c9..fdd63a6 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -629,7 +629,6 @@ truncate_pat_collision(struct resource *root, struct resource *new)
static void
lba_fixup_bus(struct pci_bus *bus)
{
- struct list_head *ln;
struct pci_dev *dev;
#ifdef FBB_SUPPORT
u16 status;
@@ -711,10 +710,9 @@ lba_fixup_bus(struct pci_bus *bus)
}
- list_for_each(ln, &bus->devices) {
+ list_for_each_entry(dev, &bus->devices, bus_list) {
int i;
- dev = pci_dev_b(ln);
DBG("lba_fixup_bus() %s\n", pci_name(dev));
/* Virtualize Device/Bridge Resources. */
@@ -771,8 +769,7 @@ lba_fixup_bus(struct pci_bus *bus)
}
/* Lastly enable FBB/PERR/SERR on all devices too */
- list_for_each(ln, &bus->devices) {
- dev = pci_dev_b(ln);
+ list_for_each_entry(dev, &bus->devices, bus_list) {
(void) pci_read_config_word(dev, PCI_COMMAND, &status);
status |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR | fbb_enable;
(void) pci_write_config_word(dev, PCI_COMMAND, status);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] sgi-agp: Use list_for_each_entry() for bus->devices traversal
2012-08-16 23:26 [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
` (2 preceding siblings ...)
2012-08-16 23:26 ` [PATCH 4/6] parisc/PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
@ 2012-08-16 23:26 ` Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 6/6] PCI: Remove unused pci_dev_b() Bjorn Helgaas
2012-08-17 23:37 ` [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
5 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2012-08-16 23:26 UTC (permalink / raw)
To: linux-pci; +Cc: David Airlie
Replace list_for_each() + pci_dev_b() with the simpler
list_for_each_entry().
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: David Airlie <airlied@linux.ie>
---
drivers/char/agp/sgi-agp.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index 1920003..3a5af2f 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -289,12 +289,11 @@ static int __devinit agp_sgi_init(void)
j = 0;
list_for_each_entry(info, &tioca_list, ca_list) {
- struct list_head *tmp;
if (list_empty(info->ca_devices))
continue;
- list_for_each(tmp, info->ca_devices) {
+ list_for_each_entry(pdev, info->ca_devices, bus_list) {
u8 cap_ptr;
- pdev = pci_dev_b(tmp);
+
if (pdev->class != (PCI_CLASS_DISPLAY_VGA << 8))
continue;
cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] PCI: Remove unused pci_dev_b()
2012-08-16 23:26 [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
` (3 preceding siblings ...)
2012-08-16 23:26 ` [PATCH 5/6] sgi-agp: " Bjorn Helgaas
@ 2012-08-16 23:26 ` Bjorn Helgaas
2012-08-17 23:37 ` [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
5 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2012-08-16 23:26 UTC (permalink / raw)
To: linux-pci
All uses of pci_dev_b() have been replaced by list_for_each_entry(), so
remove it.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
include/linux/pci.h | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5faa831..12053de 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -369,7 +369,6 @@ static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
extern struct pci_dev *alloc_pci_dev(void);
-#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)
#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal
2012-08-16 23:26 [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
` (4 preceding siblings ...)
2012-08-16 23:26 ` [PATCH 6/6] PCI: Remove unused pci_dev_b() Bjorn Helgaas
@ 2012-08-17 23:37 ` Bjorn Helgaas
5 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2012-08-17 23:37 UTC (permalink / raw)
To: linux-pci
On Thu, Aug 16, 2012 at 5:26 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> Replace list_for_each() + pci_dev_b() with the simpler
> list_for_each_entry().
This series of 6 patches is obsoleted by "[PATCH v2 00/16] Clean up
drivers/pci/remove.c", posted 8/17.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-08-17 23:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-16 23:26 [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 2/6] frv/PCI: " Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 3/6] parisc/PCI: Enable PERR/SERR on all devices Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 4/6] parisc/PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 5/6] sgi-agp: " Bjorn Helgaas
2012-08-16 23:26 ` [PATCH 6/6] PCI: Remove unused pci_dev_b() Bjorn Helgaas
2012-08-17 23:37 ` [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).