linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code
@ 2014-05-04  4:23 Yijing Wang
  2014-05-04  4:23 ` [PATCH v2 01/13] PCI: rename pci_is_bridge() to pci_has_subordinate() Yijing Wang
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

v1->v2: Add comments for new pci_is_bridge().

This patchset rename the current pci_is_bridge() to pci_has_subordinate(), 
and introduce a new pci_is_bridge() which determine pci bridge by check
dev->hdr_type. The new one is more accurate. PCI Spec define the pci
device is a bridge by the dev->hdr_type = 0x01 || 0x02.

There is no guarantee that a PCI bridge must attached a subordinate bus.
When PCI bridge is created but before the scan child bus, it has no 
subordinate bus. Also users can remove the pci bus using
interface pci_remove_bus() in remove.c. 

So use new pci_is_bridge() check if the PCI device is bridge is better
choice. If user want check PCI bridge whether has a subordinate bus,
pci_has_subordinate() is a candidate.


Yijing Wang (13):
  PCI: rename pci_is_bridge() to pci_has_subordinate()
  PCI: Introduce new pci_is_bridge() helper function
  PCI: Use new pci_is_bridge() to simplify code
  x86/PCI: Use new pci_is_bridge() to simplify code
  IA64/PCI: Use new pci_is_bridge() to simplify code
  powerpc/PCI: Use new pci_is_bridge() to simplify code
  sparc/PCI: Use new pci_is_bridge() to simplify code
  PCI, rpaphp: Use new pci_is_bridge() to simplify code
  PCI, shpchp: Use new pci_is_bridge() to simplify code
  PCI, cpcihp: Use new pci_is_bridge() to simplify code
  PCI, acpiphp: Use new pci_is_bridge() to simplify code
  PCI, pcmcia: Use new pci_is_bridge() to simplify code
  PCI, pciehp: Use new pci_is_bridge() to simplify code

 arch/ia64/pci/fixup.c                  |    4 +---
 arch/powerpc/kernel/pci-hotplug.c      |    3 +--
 arch/powerpc/kernel/pci_of_scan.c      |    3 +--
 arch/sparc/kernel/pci.c                |    3 +--
 arch/x86/pci/fixup.c                   |    4 +---
 drivers/pci/hotplug/acpiphp_glue.c     |    3 +--
 drivers/pci/hotplug/cpci_hotplug_pci.c |    3 +--
 drivers/pci/hotplug/pciehp_pci.c       |    3 +--
 drivers/pci/hotplug/rpadlpar_core.c    |    3 +--
 drivers/pci/hotplug/shpchp_pci.c       |    3 +--
 drivers/pci/pci-acpi.c                 |    8 +-------
 drivers/pci/pci-driver.c               |    8 ++++----
 drivers/pci/pci.h                      |    2 +-
 drivers/pci/probe.c                    |    3 +--
 drivers/pci/setup-bus.c                |    4 +---
 drivers/pcmcia/cardbus.c               |    3 +--
 include/linux/pci.h                    |   13 +++++++++++++
 17 files changed, 32 insertions(+), 41 deletions(-)



^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2 01/13] PCI: rename pci_is_bridge() to pci_has_subordinate()
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
@ 2014-05-04  4:23 ` Yijing Wang
  2014-05-04  4:23 ` [PATCH v2 02/13] PCI: Introduce new pci_is_bridge() helper function Yijing Wang
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

pci_is_bridge() which seems to determine whether device is a bridge,
returns true only when the subordinate bus exists. This confuses
people. PCI device is a bridge means its header type(bit 0 through 6)
is 0x1(PCI bridge) or 0x2(CardBus bridge). Rename the current
pci_is_bridge() helper function to pci_has_subordinate().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/pci-driver.c |    8 ++++----
 drivers/pci/pci.h        |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index d911e0c..b7850cb 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -580,14 +580,14 @@ static void pci_pm_default_resume(struct pci_dev *pci_dev)
 {
 	pci_fixup_device(pci_fixup_resume, pci_dev);
 
-	if (!pci_is_bridge(pci_dev))
+	if (!pci_has_subordinate(pci_dev))
 		pci_enable_wake(pci_dev, PCI_D0, false);
 }
 
 static void pci_pm_default_suspend(struct pci_dev *pci_dev)
 {
 	/* Disable non-bridge devices without PM support */
-	if (!pci_is_bridge(pci_dev))
+	if (!pci_has_subordinate(pci_dev))
 		pci_disable_enabled_device(pci_dev);
 }
 
@@ -717,7 +717,7 @@ static int pci_pm_suspend_noirq(struct device *dev)
 
 	if (!pci_dev->state_saved) {
 		pci_save_state(pci_dev);
-		if (!pci_is_bridge(pci_dev))
+		if (!pci_has_subordinate(pci_dev))
 			pci_prepare_to_sleep(pci_dev);
 	}
 
@@ -971,7 +971,7 @@ static int pci_pm_poweroff_noirq(struct device *dev)
 			return error;
 	}
 
-	if (!pci_dev->state_saved && !pci_is_bridge(pci_dev))
+	if (!pci_dev->state_saved && !pci_has_subordinate(pci_dev))
 		pci_prepare_to_sleep(pci_dev);
 
 	/*
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 6bd0822..65108fc 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -77,7 +77,7 @@ static inline void pci_wakeup_event(struct pci_dev *dev)
 	pm_wakeup_event(&dev->dev, 100);
 }
 
-static inline bool pci_is_bridge(struct pci_dev *pci_dev)
+static inline bool pci_has_subordinate(struct pci_dev *pci_dev)
 {
 	return !!(pci_dev->subordinate);
 }
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 02/13] PCI: Introduce new pci_is_bridge() helper function
  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 ` Yijing Wang
  2014-05-04  4:23 ` [PATCH v2 03/13] PCI: Use new pci_is_bridge() to simplify code Yijing Wang
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

PCIe Spec define the PCI bridge is the PCI device
which header type(bit 0 through 6) is 0x1(PCI bridge)
or 0x2(CardBus bridge).

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 include/linux/pci.h |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index aab57b4..9f5f89e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -477,6 +477,19 @@ static inline bool pci_is_root_bus(struct pci_bus *pbus)
 	return !(pbus->parent);
 }
 
+/**
+ * pci_is_bridge - check if the PCI device is a bridge
+ * @dev: PCI device
+ *
+ * Return true if the PCI device is bridge whether it has subordinate
+ * or not.
+ */
+static inline bool pci_is_bridge(struct pci_dev *dev)
+{
+	return dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
+		dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
+}
+
 static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev)
 {
 	dev = pci_physfn(dev);
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 03/13] PCI: Use new pci_is_bridge() to simplify code
  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
  2014-05-04  4:23 ` [PATCH v2 04/13] x86/PCI: " Yijing Wang
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

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



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 04/13] x86/PCI: Use new pci_is_bridge() to simplify code
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
                   ` (2 preceding siblings ...)
  2014-05-04  4:23 ` [PATCH v2 03/13] PCI: Use new pci_is_bridge() to simplify code Yijing Wang
@ 2014-05-04  4:23 ` Yijing Wang
  2014-05-04  4:23 ` [PATCH v2 05/13] IA64/PCI: " Yijing Wang
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

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

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 arch/x86/pci/fixup.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
index 94ae9ae..e5f000c 100644
--- a/arch/x86/pci/fixup.c
+++ b/arch/x86/pci/fixup.c
@@ -337,9 +337,7 @@ static void pci_fixup_video(struct pci_dev *pdev)
 		 * type BRIDGE, or CARDBUS. Host to PCI controllers use
 		 * PCI header type NORMAL.
 		 */
-		if (bridge
-		    && ((bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE)
-		       || (bridge->hdr_type == PCI_HEADER_TYPE_CARDBUS))) {
+		if (bridge && (pci_is_bridge(bridge))) {
 			pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
 						&config);
 			if (!(config & PCI_BRIDGE_CTL_VGA))
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 05/13] IA64/PCI: Use new pci_is_bridge() to simplify code
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
                   ` (3 preceding siblings ...)
  2014-05-04  4:23 ` [PATCH v2 04/13] x86/PCI: " Yijing Wang
@ 2014-05-04  4:23 ` Yijing Wang
  2014-05-04  4:23 ` [PATCH v2 06/13] powerpc/PCI: " Yijing Wang
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

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

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 arch/ia64/pci/fixup.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/ia64/pci/fixup.c b/arch/ia64/pci/fixup.c
index eee069a..1fe9aa5 100644
--- a/arch/ia64/pci/fixup.c
+++ b/arch/ia64/pci/fixup.c
@@ -49,9 +49,7 @@ static void pci_fixup_video(struct pci_dev *pdev)
 		 * type BRIDGE, or CARDBUS. Host to PCI controllers use
 		 * PCI header type NORMAL.
 		 */
-		if (bridge
-		    &&((bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE)
-		       ||(bridge->hdr_type == PCI_HEADER_TYPE_CARDBUS))) {
+		if (bridge && (pci_is_bridge(bridge))) {
 			pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
 						&config);
 			if (!(config & PCI_BRIDGE_CTL_VGA))
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 06/13] powerpc/PCI: Use new pci_is_bridge() to simplify code
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
                   ` (4 preceding siblings ...)
  2014-05-04  4:23 ` [PATCH v2 05/13] IA64/PCI: " Yijing Wang
@ 2014-05-04  4:23 ` Yijing Wang
  2014-05-04  4:23 ` [PATCH v2 07/13] sparc/PCI: " Yijing Wang
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

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

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 arch/powerpc/kernel/pci-hotplug.c |    3 +--
 arch/powerpc/kernel/pci_of_scan.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/pci-hotplug.c b/arch/powerpc/kernel/pci-hotplug.c
index c1e17ae..5b78917 100644
--- a/arch/powerpc/kernel/pci-hotplug.c
+++ b/arch/powerpc/kernel/pci-hotplug.c
@@ -98,8 +98,7 @@ void pcibios_add_pci_devices(struct pci_bus * bus)
 		max = bus->busn_res.start;
 		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/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 83c26d8..059e244 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -362,8 +362,7 @@ static void __of_scan_bus(struct device_node *node, struct pci_bus *bus,
 
 	/* Now scan child busses */
 	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)) {
 			of_scan_pci_bridge(dev);
 		}
 	}
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 07/13] sparc/PCI: Use new pci_is_bridge() to simplify code
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
                   ` (5 preceding siblings ...)
  2014-05-04  4:23 ` [PATCH v2 06/13] powerpc/PCI: " Yijing Wang
@ 2014-05-04  4:23 ` Yijing Wang
  2014-05-04  4:23 ` [PATCH v2 08/13] PCI, rpaphp: " Yijing Wang
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

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

Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 arch/sparc/kernel/pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 1555bbc..857ad77 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -543,8 +543,7 @@ static void pci_of_scan_bus(struct pci_pbm_info *pbm,
 			printk("PCI: dev header type: %x\n",
 			       dev->hdr_type);
 
-		if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-		    dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
+		if (pci_is_bridge(dev))
 			of_scan_pci_bridge(pbm, child, dev);
 	}
 }
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 08/13] PCI, rpaphp: Use new pci_is_bridge() to simplify code
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
                   ` (6 preceding siblings ...)
  2014-05-04  4:23 ` [PATCH v2 07/13] sparc/PCI: " Yijing Wang
@ 2014-05-04  4:23 ` Yijing Wang
  2014-05-04  4:23 ` [PATCH v2 09/13] PCI, shpchp: " Yijing Wang
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

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

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/hotplug/rpadlpar_core.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index 4fcdeed..7660232 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -157,8 +157,7 @@ static void dlpar_pci_add_bus(struct device_node *dn)
 	}
 
 	/* Scan below the new bridge */
-	if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-	    dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
+	if (pci_is_bridge(dev))
 		of_scan_pci_bridge(dev);
 
 	/* Map IO space for child bus, which may or may not succeed */
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 09/13] PCI, shpchp: Use new pci_is_bridge() to simplify code
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
                   ` (7 preceding siblings ...)
  2014-05-04  4:23 ` [PATCH v2 08/13] PCI, rpaphp: " Yijing Wang
@ 2014-05-04  4:23 ` Yijing Wang
  2014-05-04  4:23 ` [PATCH v2 10/13] PCI, cpcihp: " Yijing Wang
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

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

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/hotplug/shpchp_pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index 2bf69fe..ea8ad31 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -64,8 +64,7 @@ int __ref shpchp_configure_device(struct slot *p_slot)
 	list_for_each_entry(dev, &parent->devices, bus_list) {
 		if (PCI_SLOT(dev->devfn) != p_slot->device)
 			continue;
-		if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
-		    (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS))
+		if (pci_is_bridge(dev))
 			pci_hp_add_bridge(dev);
 	}
 
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 10/13] PCI, cpcihp: Use new pci_is_bridge() to simplify code
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
                   ` (8 preceding siblings ...)
  2014-05-04  4:23 ` [PATCH v2 09/13] PCI, shpchp: " Yijing Wang
@ 2014-05-04  4:23 ` Yijing Wang
  2014-05-04  4:23 ` [PATCH v2 11/13] PCI, acpiphp: " Yijing Wang
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

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

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/hotplug/cpci_hotplug_pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index 8c14648..9843371 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -289,8 +289,7 @@ int __ref cpci_configure_slot(struct slot *slot)
 	list_for_each_entry(dev, &parent->devices, bus_list)
 		if (PCI_SLOT(dev->devfn) != PCI_SLOT(slot->devfn))
 			continue;
-		if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
-		    (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS))
+		if (pci_is_bridge(dev))
 			pci_hp_add_bridge(dev);
 
 
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 11/13] PCI, acpiphp: Use new pci_is_bridge() to simplify code
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
                   ` (9 preceding siblings ...)
  2014-05-04  4:23 ` [PATCH v2 10/13] PCI, cpcihp: " Yijing Wang
@ 2014-05-04  4:23 ` Yijing Wang
  2014-05-04  4:23 ` [PATCH v2 12/13] PCI, pcmcia: " Yijing Wang
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

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

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/hotplug/acpiphp_glue.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index bccc27e..f1f9bd1 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -516,8 +516,7 @@ static void __ref enable_slot(struct acpiphp_slot *slot)
 			if (PCI_SLOT(dev->devfn) != slot->device)
 				continue;
 
-			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);
 				if (pass && dev->subordinate) {
 					check_hotplug_bridge(slot, dev);
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 12/13] PCI, pcmcia: Use new pci_is_bridge() to simplify code
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
                   ` (10 preceding siblings ...)
  2014-05-04  4:23 ` [PATCH v2 11/13] PCI, acpiphp: " Yijing Wang
@ 2014-05-04  4:23 ` 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
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

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

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pcmcia/cardbus.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
index 8bde619..4fe4cc4 100644
--- a/drivers/pcmcia/cardbus.c
+++ b/drivers/pcmcia/cardbus.c
@@ -78,8 +78,7 @@ int __ref cb_alloc(struct pcmcia_socket *s)
 	max = bus->busn_res.start;
 	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);
 
 	/*
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 13/13] PCI, pciehp: Use new pci_is_bridge() to simplify code
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
                   ` (11 preceding siblings ...)
  2014-05-04  4:23 ` [PATCH v2 12/13] PCI, pcmcia: " Yijing Wang
@ 2014-05-04  4:23 ` Yijing Wang
  2014-05-27 21:05 ` [PATCH v2 00/13] Refactor pci_is_brdige() " Bjorn Helgaas
  13 siblings, 0 replies; 15+ messages in thread
From: Yijing Wang @ 2014-05-04  4:23 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86,
	Yijing Wang

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

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/hotplug/pciehp_pci.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index 1b53306..b6cb1df 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -62,8 +62,7 @@ int pciehp_configure_device(struct slot *p_slot)
 	}
 
 	list_for_each_entry(dev, &parent->devices, bus_list)
-		if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
-				(dev->hdr_type == PCI_HEADER_TYPE_CARDBUS))
+		if (pci_is_bridge(dev))
 			pci_hp_add_bridge(dev);
 
 	pci_assign_unassigned_bridge_resources(bridge);
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code
  2014-05-04  4:23 [PATCH v2 00/13] Refactor pci_is_brdige() to simplify code Yijing Wang
                   ` (12 preceding siblings ...)
  2014-05-04  4:23 ` [PATCH v2 13/13] PCI, pciehp: " Yijing Wang
@ 2014-05-27 21:05 ` Bjorn Helgaas
  13 siblings, 0 replies; 15+ messages in thread
From: Bjorn Helgaas @ 2014-05-27 21:05 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-pci, Tony Luck,
	linux-ia64, David S. Miller, sparclinux, Thomas Gleixner, x86

On Sun, May 04, 2014 at 12:23:35PM +0800, Yijing Wang wrote:
> v1->v2: Add comments for new pci_is_bridge().
> 
> This patchset rename the current pci_is_bridge() to pci_has_subordinate(), 
> and introduce a new pci_is_bridge() which determine pci bridge by check
> dev->hdr_type. The new one is more accurate. PCI Spec define the pci
> device is a bridge by the dev->hdr_type = 0x01 || 0x02.
> 
> There is no guarantee that a PCI bridge must attached a subordinate bus.
> When PCI bridge is created but before the scan child bus, it has no 
> subordinate bus. Also users can remove the pci bus using
> interface pci_remove_bus() in remove.c. 
> 
> So use new pci_is_bridge() check if the PCI device is bridge is better
> choice. If user want check PCI bridge whether has a subordinate bus,
> pci_has_subordinate() is a candidate.
> 
> 
> Yijing Wang (13):
>   PCI: rename pci_is_bridge() to pci_has_subordinate()
>   PCI: Introduce new pci_is_bridge() helper function
>   PCI: Use new pci_is_bridge() to simplify code
>   x86/PCI: Use new pci_is_bridge() to simplify code
>   IA64/PCI: Use new pci_is_bridge() to simplify code
>   powerpc/PCI: Use new pci_is_bridge() to simplify code
>   sparc/PCI: Use new pci_is_bridge() to simplify code
>   PCI, rpaphp: Use new pci_is_bridge() to simplify code
>   PCI, shpchp: Use new pci_is_bridge() to simplify code
>   PCI, cpcihp: Use new pci_is_bridge() to simplify code
>   PCI, acpiphp: Use new pci_is_bridge() to simplify code
>   PCI, pcmcia: Use new pci_is_bridge() to simplify code
>   PCI, pciehp: Use new pci_is_bridge() to simplify code
> 
>  arch/ia64/pci/fixup.c                  |    4 +---
>  arch/powerpc/kernel/pci-hotplug.c      |    3 +--
>  arch/powerpc/kernel/pci_of_scan.c      |    3 +--
>  arch/sparc/kernel/pci.c                |    3 +--
>  arch/x86/pci/fixup.c                   |    4 +---
>  drivers/pci/hotplug/acpiphp_glue.c     |    3 +--
>  drivers/pci/hotplug/cpci_hotplug_pci.c |    3 +--
>  drivers/pci/hotplug/pciehp_pci.c       |    3 +--
>  drivers/pci/hotplug/rpadlpar_core.c    |    3 +--
>  drivers/pci/hotplug/shpchp_pci.c       |    3 +--
>  drivers/pci/pci-acpi.c                 |    8 +-------
>  drivers/pci/pci-driver.c               |    8 ++++----
>  drivers/pci/pci.h                      |    2 +-
>  drivers/pci/probe.c                    |    3 +--
>  drivers/pci/setup-bus.c                |    4 +---
>  drivers/pcmcia/cardbus.c               |    3 +--
>  include/linux/pci.h                    |   13 +++++++++++++
>  17 files changed, 32 insertions(+), 41 deletions(-)

Applied to pci/pci_is_bridge for v3.16, thanks,

Bjorn

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-05-27 21:05 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2 03/13] PCI: Use new pci_is_bridge() to simplify code Yijing Wang
2014-05-04  4:23 ` [PATCH v2 04/13] x86/PCI: " 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

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).