[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1332135996-13860-25-git-send-email-yinghai@kernel.org>
Date: Sun, 18 Mar 2012 22:46:13 -0700
From: Yinghai Lu <yinghai@...nel.org>
To: Jesse Barnes <jbarnes@...tuousgeek.org>, x86 <x86@...nel.org>
Cc: Bjorn Helgaas <bhelgaas@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
Yinghai Lu <yinghai@...nel.org>
Subject: [PATCH -v3 24/47] PCI: Add pci_stop_and_remove_bus()
It supports both pci root bus and pci bus under pci bridge.
-v2: clear pci_bridge's subordinate.
Signed-off-by: Yinghai Lu <yinghai@...nel.org>
---
drivers/pci/remove.c | 32 ++++++++++++++++++++++++++++++++
include/linux/pci.h | 1 +
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 64ba5b1..75b0092 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -169,6 +169,38 @@ void pci_stop_bus_device(struct pci_dev *dev)
pci_stop_dev(dev);
}
+static void pci_stop_host_bridge(struct pci_host_bridge *bridge)
+{
+ device_unregister(&bridge->dev);
+}
+/*
+ * it will support pci root bus too, in that case we need
+ * stop and remove host bridge
+ */
+void pci_stop_and_remove_bus(struct pci_bus *bus)
+{
+ struct pci_host_bridge *host_bridge = NULL;
+ struct pci_dev *pci_bridge = NULL;
+
+ pci_stop_bus_devices(bus);
+
+ if (pci_is_root_bus(bus)) {
+ host_bridge = to_pci_host_bridge(bus->bridge);
+ pci_stop_host_bridge(host_bridge);
+ } else
+ pci_bridge = bus->self;
+
+ __pci_remove_bus_devices(bus);
+
+ pci_remove_bus(bus);
+
+ if (host_bridge)
+ host_bridge->bus = NULL;
+
+ if (pci_bridge)
+ pci_bridge->subordinate = NULL;
+}
+
EXPORT_SYMBOL(pci_stop_and_remove_bus_device);
EXPORT_SYMBOL(pci_stop_and_remove_behind_bridge);
EXPORT_SYMBOL_GPL(pci_stop_bus_device);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b434401..aec945d 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -703,6 +703,7 @@ extern void pci_dev_put(struct pci_dev *dev);
extern void pci_remove_bus(struct pci_bus *b);
extern void __pci_remove_bus_device(struct pci_dev *dev);
extern void pci_stop_and_remove_bus_device(struct pci_dev *dev);
+void pci_stop_and_remove_bus(struct pci_bus *bus);
extern void pci_stop_bus_device(struct pci_dev *dev);
void pci_setup_cardbus(struct pci_bus *bus);
extern void pci_sort_breadthfirst(void);
--
1.7.7
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists