linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Use of_get_parent() in pci_dma_dev_setup_pSeriesLP()
@ 2007-10-24  4:24 Michael Ellerman
  2007-10-25  1:46 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Ellerman @ 2007-10-24  4:24 UTC (permalink / raw)
  To: linuxppc-dev

The loop to check parent nodes for a dma-window property in
pci_dma_dev_setup_pSeriesLP() does not use the of_* accessors and
does not properly manage refcounts, fix it to do so.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/platforms/pseries/iommu.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index be17d23..2c6fc3f 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -481,7 +481,7 @@ static void pci_dma_dev_setup_pSeries(struct pci_dev *dev)
 
 static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
 {
-	struct device_node *pdn, *dn;
+	struct device_node *pdn, *dn, *tmp;
 	struct iommu_table *tbl;
 	const void *dma_window = NULL;
 	struct pci_dn *pci;
@@ -497,18 +497,22 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
 	dn = pci_device_to_OF_node(dev);
 	DBG("  node is %s\n", dn->full_name);
 
-	for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table;
-	     pdn = pdn->parent) {
+	pdn = of_node_get(dn);
+	while (pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table) {
 		dma_window = of_get_property(pdn, "ibm,dma-window", NULL);
 		if (dma_window)
 			break;
+
+		tmp = of_get_parent(pdn);
+		of_node_put(pdn);
+		pdn = tmp;
 	}
 
 	if (!pdn || !PCI_DN(pdn)) {
 		printk(KERN_WARNING "pci_dma_dev_setup_pSeriesLP: "
 		       "no DMA window found for pci dev=%s dn=%s\n",
 				 pci_name(dev), dn? dn->full_name : "<null>");
-		return;
+		goto out_put;
 	}
 	DBG("  parent is %s\n", pdn->full_name);
 
@@ -518,7 +522,7 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
 	if (dma_window == NULL || pdn->parent == NULL) {
 		DBG("  no dma window for device, linking to parent\n");
 		dev->dev.archdata.dma_data = PCI_DN(pdn)->iommu_table;
-		return;
+		goto out_put;
 	}
 
 	pci = PCI_DN(pdn);
@@ -538,6 +542,9 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
 	}
 
 	dev->dev.archdata.dma_data = pci->iommu_table;
+
+out_put:
+	of_node_put(pdn);
 }
 #else  /* CONFIG_PCI */
 #define pci_dma_bus_setup_pSeries	NULL
-- 
1.5.1.3.g7a33b

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

* Re: [PATCH] Use of_get_parent() in pci_dma_dev_setup_pSeriesLP()
  2007-10-24  4:24 [PATCH] Use of_get_parent() in pci_dma_dev_setup_pSeriesLP() Michael Ellerman
@ 2007-10-25  1:46 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2007-10-25  1:46 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

On Wed, 2007-10-24 at 14:24 +1000, Michael Ellerman wrote:
> The loop to check parent nodes for a dma-window property in
> pci_dma_dev_setup_pSeriesLP() does not use the of_* accessors and
> does not properly manage refcounts, fix it to do so.
> 
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
> ---
>  arch/powerpc/platforms/pseries/iommu.c |   17 ++++++++++++-----
>  1 files changed, 12 insertions(+), 5 deletions(-)

I'm starting to make a habit of this .. but nack.

Stephen points out that there are several other places in this file that
need fixing up, so I'll do them all as one series.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2007-10-25  1:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-24  4:24 [PATCH] Use of_get_parent() in pci_dma_dev_setup_pSeriesLP() Michael Ellerman
2007-10-25  1:46 ` Michael Ellerman

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