Message ID | 1462254105-24128-21-git-send-email-gwshan@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On 03/05/16 15:41, Gavin Shan wrote: > This moves pci_find_bus_by_node() from arch/powerpc/platforms/ > pseries/pci_dlpar.c to arch/powerpc/kernel/pci-hotplug.c so that > the function can be used by pSeries and PowerNV platform at the > same time. Also, below cleanup applied. No functional changes > introduced. > > * Remove variable "busdn" in find_bus_among_children() > * Use PCI_DN() to convert device node to pci_dn > > Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> > Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Looks good to me Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> > --- > arch/powerpc/kernel/pci-hotplug.c | 29 ++++++++++++++++++++++++++++ > arch/powerpc/platforms/pseries/pci_dlpar.c | 31 ------------------------------ > 2 files changed, 29 insertions(+), 31 deletions(-) > > diff --git a/arch/powerpc/kernel/pci-hotplug.c b/arch/powerpc/kernel/pci-hotplug.c > index 2d108e5..46587a1 100644 > --- a/arch/powerpc/kernel/pci-hotplug.c > +++ b/arch/powerpc/kernel/pci-hotplug.c > @@ -21,6 +21,35 @@ > #include <asm/firmware.h> > #include <asm/eeh.h> > > +static struct pci_bus *find_bus_among_children(struct pci_bus *bus, > + struct device_node *dn) > +{ > + struct pci_bus *child = NULL; > + struct pci_bus *tmp; > + > + if (pci_bus_to_OF_node(bus) == dn) > + return bus; > + > + list_for_each_entry(tmp, &bus->children, node) { > + child = find_bus_among_children(tmp, dn); > + if (child) > + break; > + } > + > + return child; > +} > + > +struct pci_bus *pci_find_bus_by_node(struct device_node *dn) > +{ > + struct pci_dn *pdn = PCI_DN(dn); > + > + if (!pdn || !pdn->phb || !pdn->phb->bus) > + return NULL; > + > + return find_bus_among_children(pdn->phb->bus, dn); > +} > +EXPORT_SYMBOL_GPL(pci_find_bus_by_node); > + > /** > * pcibios_release_device - release PCI device > * @dev: PCI device > diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c > index aee22b4..906dbaa 100644 > --- a/arch/powerpc/platforms/pseries/pci_dlpar.c > +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c > @@ -34,37 +34,6 @@ > > #include "pseries.h" > > -static struct pci_bus * > -find_bus_among_children(struct pci_bus *bus, > - struct device_node *dn) > -{ > - struct pci_bus *child = NULL; > - struct pci_bus *tmp; > - struct device_node *busdn; > - > - busdn = pci_bus_to_OF_node(bus); > - if (busdn == dn) > - return bus; > - > - list_for_each_entry(tmp, &bus->children, node) { > - child = find_bus_among_children(tmp, dn); > - if (child) > - break; > - }; > - return child; > -} > - > -struct pci_bus *pci_find_bus_by_node(struct device_node *dn) > -{ > - struct pci_dn *pdn = dn->data; > - > - if (!pdn || !pdn->phb || !pdn->phb->bus) > - return NULL; > - > - return find_bus_among_children(pdn->phb->bus, dn); > -} > -EXPORT_SYMBOL_GPL(pci_find_bus_by_node); > - > struct pci_controller *init_phb_dynamic(struct device_node *dn) > { > struct pci_controller *phb; >
On 05/03/2016 03:41 PM, Gavin Shan wrote: > This moves pci_find_bus_by_node() from arch/powerpc/platforms/ > pseries/pci_dlpar.c to arch/powerpc/kernel/pci-hotplug.c so that > the function can be used by pSeries and PowerNV platform at the > same time. Also, below cleanup applied. No functional changes > introduced. > > * Remove variable "busdn" in find_bus_among_children() > * Use PCI_DN() to convert device node to pci_dn > > Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> > Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru> > --- > arch/powerpc/kernel/pci-hotplug.c | 29 ++++++++++++++++++++++++++++ > arch/powerpc/platforms/pseries/pci_dlpar.c | 31 ------------------------------ > 2 files changed, 29 insertions(+), 31 deletions(-) > > diff --git a/arch/powerpc/kernel/pci-hotplug.c b/arch/powerpc/kernel/pci-hotplug.c > index 2d108e5..46587a1 100644 > --- a/arch/powerpc/kernel/pci-hotplug.c > +++ b/arch/powerpc/kernel/pci-hotplug.c > @@ -21,6 +21,35 @@ > #include <asm/firmware.h> > #include <asm/eeh.h> > > +static struct pci_bus *find_bus_among_children(struct pci_bus *bus, > + struct device_node *dn) > +{ > + struct pci_bus *child = NULL; > + struct pci_bus *tmp; > + > + if (pci_bus_to_OF_node(bus) == dn) > + return bus; > + > + list_for_each_entry(tmp, &bus->children, node) { > + child = find_bus_among_children(tmp, dn); > + if (child) > + break; > + } > + > + return child; > +} > + > +struct pci_bus *pci_find_bus_by_node(struct device_node *dn) > +{ > + struct pci_dn *pdn = PCI_DN(dn); > + > + if (!pdn || !pdn->phb || !pdn->phb->bus) > + return NULL; > + > + return find_bus_among_children(pdn->phb->bus, dn); > +} > +EXPORT_SYMBOL_GPL(pci_find_bus_by_node); > + > /** > * pcibios_release_device - release PCI device > * @dev: PCI device > diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c > index aee22b4..906dbaa 100644 > --- a/arch/powerpc/platforms/pseries/pci_dlpar.c > +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c > @@ -34,37 +34,6 @@ > > #include "pseries.h" > > -static struct pci_bus * > -find_bus_among_children(struct pci_bus *bus, > - struct device_node *dn) > -{ > - struct pci_bus *child = NULL; > - struct pci_bus *tmp; > - struct device_node *busdn; > - > - busdn = pci_bus_to_OF_node(bus); > - if (busdn == dn) > - return bus; > - > - list_for_each_entry(tmp, &bus->children, node) { > - child = find_bus_among_children(tmp, dn); > - if (child) > - break; > - }; > - return child; > -} > - > -struct pci_bus *pci_find_bus_by_node(struct device_node *dn) > -{ > - struct pci_dn *pdn = dn->data; > - > - if (!pdn || !pdn->phb || !pdn->phb->bus) > - return NULL; > - > - return find_bus_among_children(pdn->phb->bus, dn); > -} > -EXPORT_SYMBOL_GPL(pci_find_bus_by_node); > - > struct pci_controller *init_phb_dynamic(struct device_node *dn) > { > struct pci_controller *phb; >
diff --git a/arch/powerpc/kernel/pci-hotplug.c b/arch/powerpc/kernel/pci-hotplug.c index 2d108e5..46587a1 100644 --- a/arch/powerpc/kernel/pci-hotplug.c +++ b/arch/powerpc/kernel/pci-hotplug.c @@ -21,6 +21,35 @@ #include <asm/firmware.h> #include <asm/eeh.h> +static struct pci_bus *find_bus_among_children(struct pci_bus *bus, + struct device_node *dn) +{ + struct pci_bus *child = NULL; + struct pci_bus *tmp; + + if (pci_bus_to_OF_node(bus) == dn) + return bus; + + list_for_each_entry(tmp, &bus->children, node) { + child = find_bus_among_children(tmp, dn); + if (child) + break; + } + + return child; +} + +struct pci_bus *pci_find_bus_by_node(struct device_node *dn) +{ + struct pci_dn *pdn = PCI_DN(dn); + + if (!pdn || !pdn->phb || !pdn->phb->bus) + return NULL; + + return find_bus_among_children(pdn->phb->bus, dn); +} +EXPORT_SYMBOL_GPL(pci_find_bus_by_node); + /** * pcibios_release_device - release PCI device * @dev: PCI device diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c index aee22b4..906dbaa 100644 --- a/arch/powerpc/platforms/pseries/pci_dlpar.c +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c @@ -34,37 +34,6 @@ #include "pseries.h" -static struct pci_bus * -find_bus_among_children(struct pci_bus *bus, - struct device_node *dn) -{ - struct pci_bus *child = NULL; - struct pci_bus *tmp; - struct device_node *busdn; - - busdn = pci_bus_to_OF_node(bus); - if (busdn == dn) - return bus; - - list_for_each_entry(tmp, &bus->children, node) { - child = find_bus_among_children(tmp, dn); - if (child) - break; - }; - return child; -} - -struct pci_bus *pci_find_bus_by_node(struct device_node *dn) -{ - struct pci_dn *pdn = dn->data; - - if (!pdn || !pdn->phb || !pdn->phb->bus) - return NULL; - - return find_bus_among_children(pdn->phb->bus, dn); -} -EXPORT_SYMBOL_GPL(pci_find_bus_by_node); - struct pci_controller *init_phb_dynamic(struct device_node *dn) { struct pci_controller *phb;