linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yijing Wang <wangyijing@huawei.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	<linuxppc-dev@lists.ozlabs.org>, <linux-pci@vger.kernel.org>,
	Tony Luck <tony.luck@intel.com>, <linux-ia64@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	<sparclinux@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>, <x86@kernel.org>,
	Yijing Wang <wangyijing@huawei.com>
Subject: [PATCH v2 03/13] PCI: Use new pci_is_bridge() to simplify code
Date: Sun, 4 May 2014 12:23:38 +0800	[thread overview]
Message-ID: <1399177428-3784-4-git-send-email-wangyijing@huawei.com> (raw)
In-Reply-To: <1399177428-3784-1-git-send-email-wangyijing@huawei.com>

Now we can use new pci_is_bridge() helper function
to simplify code.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/pci-acpi.c  |    8 +-------
 drivers/pci/probe.c     |    3 +--
 drivers/pci/setup-bus.c |    4 +---
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index f49abef..ca4927b 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -309,13 +309,7 @@ static struct acpi_device *acpi_pci_find_companion(struct device *dev)
 	bool check_children;
 	u64 addr;
 
-	/*
-	 * pci_is_bridge() is not suitable here, because pci_dev->subordinate
-	 * is set only after acpi_pci_find_device() has been called for the
-	 * given device.
-	 */
-	check_children = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE
-			|| pci_dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
+	check_children = pci_is_bridge(pci_dev);
 	/* Please ref to ACPI spec for the syntax of _ADR */
 	addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
 	return acpi_find_child_device(ACPI_COMPANION(dev->parent), addr,
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index ef09f5f..f831dd8 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1670,8 +1670,7 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
 
 	for (pass=0; pass < 2; pass++)
 		list_for_each_entry(dev, &bus->devices, bus_list) {
-			if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-			    dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
+			if (pci_is_bridge(dev))
 				max = pci_scan_bridge(bus, dev, max, pass);
 		}
 
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 138bdd6..e399d00 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1629,9 +1629,7 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus)
 
 	down_read(&pci_bus_sem);
 	list_for_each_entry(dev, &bus->devices, bus_list)
-		if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-		    dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
-			if (dev->subordinate)
+		if (pci_is_bridge(dev) && pci_has_subordinate(dev))
 				__pci_bus_size_bridges(dev->subordinate,
 							 &add_list);
 	up_read(&pci_bus_sem);
-- 
1.7.1



  parent reply	other threads:[~2014-05-04  4:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
2014-05-04  4:23 ` [PATCH v2 01/13] PCI: rename pci_is_bridge() to pci_has_subordinate() Yijing Wang
2014-05-04  4:23 ` [PATCH v2 02/13] PCI: Introduce new pci_is_bridge() helper function Yijing Wang
2014-05-04  4:23 ` Yijing Wang [this message]
2014-05-04  4:23 ` [PATCH v2 04/13] x86/PCI: Use new pci_is_bridge() to simplify code Yijing Wang
2014-05-04  4:23 ` [PATCH v2 05/13] IA64/PCI: " Yijing Wang
2014-05-04  4:23 ` [PATCH v2 06/13] powerpc/PCI: " Yijing Wang
2014-05-04  4:23 ` [PATCH v2 07/13] sparc/PCI: " Yijing Wang
2014-05-04  4:23 ` [PATCH v2 08/13] PCI, rpaphp: " Yijing Wang
2014-05-04  4:23 ` [PATCH v2 09/13] PCI, shpchp: " Yijing Wang
2014-05-04  4:23 ` [PATCH v2 10/13] PCI, cpcihp: " Yijing Wang
2014-05-04  4:23 ` [PATCH v2 11/13] PCI, acpiphp: " Yijing Wang
2014-05-04  4:23 ` [PATCH v2 12/13] PCI, pcmcia: " Yijing Wang
2014-05-04  4:23 ` [PATCH v2 13/13] PCI, pciehp: " Yijing Wang
2014-05-27 21:05 ` [PATCH v2 00/13] Refactor pci_is_brdige() " 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=1399177428-3784-4-git-send-email-wangyijing@huawei.com \
    --to=wangyijing@huawei.com \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=davem@davemloft.net \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@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).