[PATCH/RFC] powerpc: make pci use device notifier
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2006-11-03 21:23:01
This is just an add-on to my previous patch to make it use the new device notifier thingy that I added to gregkh tree instead of the old style function pointer hooks Index: linux-cell/arch/powerpc/kernel/setup_64.c ===================================================================
--- linux-cell.orig/arch/powerpc/kernel/setup_64.c 2006-10-26 16:43:32.000000000 +1000
+++ linux-cell/arch/powerpc/kernel/setup_64.c 2006-10-26 16:44:09.000000000 +1000@@ -531,10 +531,6 @@ void __init setup_arch(char **cmdline_p) conswitchp = &dummy_con; #endif -#ifdef CONFIG_PCI - platform_notify = pci_platform_notify; - platform_notify_remove = pci_platform_notify_remove; -#endif ppc_md.setup_arch(); paging_init();
Index: linux-cell/arch/powerpc/kernel/pci_64.c ===================================================================
--- linux-cell.orig/arch/powerpc/kernel/pci_64.c 2006-10-26 16:43:32.000000000 +1000
+++ linux-cell/arch/powerpc/kernel/pci_64.c 2006-10-26 16:44:09.000000000 +1000@@ -22,6 +22,7 @@ #include <linux/list.h> #include <linux/syscalls.h> #include <linux/irq.h> +#include <linux/notifier.h> #include <asm/processor.h> #include <asm/io.h>
@@ -554,6 +555,29 @@ void __devinit scan_phb(struct pci_contr hose->last_busno = bus->subordinate = pci_scan_child_bus(bus); } +static int ppc_pci_dev_notify(struct notifier_block *nb, unsigned long action, + void *data) +{ + struct device *dev = data; + struct device_ext *dext; + + if (action == BUS_NOTIFY_DEL_DEVICE) { + dext = device_get_ext(dev); + + DBG("%s:%s platform notify remove !\n", + dev_driver_string(dev), dev->bus_id); + + device_set_ext(dev, NULL); + kfree(dext); + } + + return 0; +} + +static struct notifier_block ppc_pci_dev_notifier = { + .notifier_call = ppc_pci_dev_notify +}; + static int __init pcibios_init(void) { struct pci_controller *hose, *tmp;
@@ -566,6 +590,8 @@ static int __init pcibios_init(void) if (firmware_has_feature(FW_FEATURE_ISERIES)) iSeries_pcibios_init(); + register_bus_notifier(&pci_bus_type, &ppc_pci_dev_notifier); + printk(KERN_DEBUG "PCI: Probing PCI hardware\n"); /* Scan all of the recorded PCI controllers. */
@@ -1458,24 +1484,3 @@ int pcibus_to_node(struct pci_bus *bus) EXPORT_SYMBOL(pcibus_to_node); #endif -int pci_platform_notify(struct device * dev) -{ - return 0; -} - -int pci_platform_notify_remove(struct device * dev) -{ - struct device_ext *dext = device_get_ext(dev); - - DBG("%s:%s platform notify remove !\n", - dev_driver_string(dev), dev->bus_id); - - if (dev->bus != &pci_bus_type) - return 0; - - device_set_ext(dev, NULL); - mb(); - kfree(dext); - - return 0; -}