mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC][PATCH] add PCI bus registration support [2/9]
@ 2005-07-14  8:55 Adam Belay
  2005-07-14 19:33 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Belay @ 2005-07-14  8:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: greg


This patch adds pci_add_bus() for PCI bus registration.  It also moves
pci_remove_bus() from remove.c to bus/bus.c for consistency.

Signed-off-by: Adam Belay <abelay@novell.com>

--- a/drivers/pci/bus/bus.c	2005-07-12 00:59:58.000000000 -0400
+++ b/drivers/pci/bus/bus.c	2005-07-12 01:01:13.992787920 -0400
@@ -9,6 +9,7 @@
 #include <linux/module.h>
 
 #include "bus.h"
+#include "../pci.h"
 
 #undef DEBUG
 
@@ -50,7 +51,7 @@
  */
 
 /**
- *	pci_alloc_bus - allocates a "pci_bus" structure
+ * pci_alloc_bus - allocates a "pci_bus" structure
  */
 struct pci_bus * pci_alloc_bus(void)
 {
@@ -67,3 +68,61 @@
 }
 
 EXPORT_SYMBOL(pci_alloc_bus);
+
+/**
+ * pci_add_bus - registers a bus with the pci bus class
+ * @bus: the bus
+ *
+ * Setup class data, register with the driver core, proc, etc...
+ */
+int pci_add_bus(struct pci_bus *bus)
+{
+	int ret;
+
+	bus->class_dev.class = &pcibus_class;
+	sprintf(bus->class_dev.class_id, "%04x:%02x", pci_domain_nr(bus),
+		bus->primary);
+
+	ret = class_device_register(&bus->class_dev);
+	if (ret)
+		return ret;
+
+	class_device_create_file(&bus->class_dev,
+				 &class_device_attr_cpuaffinity);
+	if (bus->self)
+		sysfs_create_link(&bus->class_dev.kobj,
+				  &bus->self->dev.kobj, "bridge");
+
+	spin_lock(&pci_bus_lock);
+	list_add_tail(&bus->node, &bus->parent->children);
+	spin_unlock(&pci_bus_lock);
+
+	pci_proc_attach_bus(bus);
+
+	return 0;
+}
+
+EXPORT_SYMBOL(pci_add_bus);
+
+/**
+ * pci_remove_bus - unregisters a bus with the pci bus class
+ * @bus: the bus
+ *
+ * Remove the bus from bus lists, remove proc/sysfs files, and unregister
+ * from the driver core.
+ */
+void pci_remove_bus(struct pci_bus *pci_bus)
+{
+	pci_proc_detach_bus(pci_bus);
+
+	spin_lock(&pci_bus_lock);
+	list_del(&pci_bus->node);
+	spin_unlock(&pci_bus_lock);
+	pci_remove_legacy_files(pci_bus);
+	class_device_remove_file(&pci_bus->class_dev,
+		&class_device_attr_cpuaffinity);
+	sysfs_remove_link(&pci_bus->class_dev.kobj, "bridge");
+	class_device_unregister(&pci_bus->class_dev);
+}
+
+EXPORT_SYMBOL(pci_remove_bus);
--- a/drivers/pci/remove.c	2005-07-08 17:06:20.000000000 -0400
+++ b/drivers/pci/remove.c	2005-07-12 01:01:13.998787008 -0400
@@ -57,20 +57,6 @@
 }
 EXPORT_SYMBOL(pci_remove_device_safe);
 
-void pci_remove_bus(struct pci_bus *pci_bus)
-{
-	pci_proc_detach_bus(pci_bus);
-
-	spin_lock(&pci_bus_lock);
-	list_del(&pci_bus->node);
-	spin_unlock(&pci_bus_lock);
-	pci_remove_legacy_files(pci_bus);
-	class_device_remove_file(&pci_bus->class_dev,
-		&class_device_attr_cpuaffinity);
-	sysfs_remove_link(&pci_bus->class_dev.kobj, "bridge");
-	class_device_unregister(&pci_bus->class_dev);
-}
-EXPORT_SYMBOL(pci_remove_bus);
 
 /**
  * pci_remove_bus_device - remove a PCI device and any children
--- a/include/linux/pci.h	2005-07-12 00:59:58.000000000 -0400
+++ b/include/linux/pci.h	2005-07-12 01:01:14.065776824 -0400
@@ -734,6 +734,8 @@
 /* Generic PCI functions used internally */
 
 extern struct pci_bus * pci_alloc_bus(void);
+extern int pci_add_bus(struct pci_bus *bus);
+extern void pci_remove_bus(struct pci_bus *bus);
 extern struct pci_bus *pci_find_bus(int domain, int busnr);
 void pci_bus_add_devices(struct pci_bus *bus);
 struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata);
@@ -756,7 +758,6 @@
 int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
 extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
 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);
 
 /* Generic PCI functions exported to card drivers */



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

* Re: [RFC][PATCH] add PCI bus registration support [2/9]
  2005-07-14  8:55 [RFC][PATCH] add PCI bus registration support [2/9] Adam Belay
@ 2005-07-14 19:33 ` Greg KH
  2005-07-14 19:46   ` Adam Belay
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2005-07-14 19:33 UTC (permalink / raw)
  To: Adam Belay; +Cc: linux-kernel

On Thu, Jul 14, 2005 at 04:55:12AM -0400, Adam Belay wrote:
> +EXPORT_SYMBOL(pci_add_bus);

This doens't need to be exported, right?  No module uses it.  But if
they do, I suggest EXPORT_SYMBOL_GPL() instead, is that ok?

thanks,

greg k-h

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

* Re: [RFC][PATCH] add PCI bus registration support [2/9]
  2005-07-14 19:33 ` Greg KH
@ 2005-07-14 19:46   ` Adam Belay
  0 siblings, 0 replies; 3+ messages in thread
From: Adam Belay @ 2005-07-14 19:46 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

On Thu, 2005-07-14 at 12:33 -0700, Greg KH wrote:
> On Thu, Jul 14, 2005 at 04:55:12AM -0400, Adam Belay wrote:
> > +EXPORT_SYMBOL(pci_add_bus);
> 
> This doens't need to be exported, right?  No module uses it.  But if
> they do, I suggest EXPORT_SYMBOL_GPL() instead, is that ok?
> 
> thanks,
> 
> greg k-h

Yes, no module currently uses it, but now that "pci_driver" is
supported, any PCI bridge driver could potentially be made into a
module.  In theory, this could even include the PCI<->PCI bridge driver.
I also wanted to export this as a module so that it would be easier to
add new drivers for more unusual bridge hardware.  EXPORT_SYMBOL_GPL()
would be fine.

Thanks,
Adam



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

end of thread, other threads:[~2005-07-14 19:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-14  8:55 [RFC][PATCH] add PCI bus registration support [2/9] Adam Belay
2005-07-14 19:33 ` Greg KH
2005-07-14 19:46   ` Adam Belay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®