linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: linux-pci@vger.kernel.org
Subject: [PATCH 1/6] PCI: Use list_for_each_entry() for bus->devices traversal
Date: Thu, 16 Aug 2012 17:26:20 -0600	[thread overview]
Message-ID: <20120816232620.3662.90438.stgit@bhelgaas.mtv.corp.google.com> (raw)

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;
 	}


             reply	other threads:[~2012-08-16 23:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-16 23:26 Bjorn Helgaas [this message]
2012-08-16 23:26 ` [PATCH 2/6] frv/PCI: Use list_for_each_entry() for bus->devices traversal 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120816232620.3662.90438.stgit@bhelgaas.mtv.corp.google.com \
    --to=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).