Thread (6 messages) flat view 6 messages, 3 authors, 2013-10-15

RE: [PATCH 1/3] iommu/fsl: Factor out PCI specific code.

From: Sethi Varun-B16395 <hidden>
Date: 2013-10-15 14:35:48
Also in: linux-iommu, lkml

-----Original Message-----
From: iommu-bounces@lists.linux-foundation.org [mailto:iommu-
bounces@lists.linux-foundation.org] On Behalf Of Bjorn Helgaas
Sent: Tuesday, October 15, 2013 5:46 AM
To: Sethi Varun-B16395
Cc: Yoder Stuart-B08248; linux-kernel@vger.kernel.org; iommu@lists.linux-
foundation.org; Bhushan Bharat-R65777; Wood Scott-B07421; linuxppc-
dev@lists.ozlabs.org
Subject: Re: [PATCH 1/3] iommu/fsl: Factor out PCI specific code.
=20
On Sun, Oct 13, 2013 at 02:02:32AM +0530, Varun Sethi wrote:
quoted
Factor out PCI specific code in the PAMU driver.

Signed-off-by: Varun Sethi <redacted>
---
 drivers/iommu/fsl_pamu_domain.c |   81 +++++++++++++++++++------------
--------
quoted
 1 file changed, 40 insertions(+), 41 deletions(-)
diff --git a/drivers/iommu/fsl_pamu_domain.c
b/drivers/iommu/fsl_pamu_domain.c index c857c30..e02e1de 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -677,13 +677,9 @@ static int handle_attach_device(struct
fsl_dma_domain *dma_domain,
quoted
 	return ret;
 }

-static int fsl_pamu_attach_device(struct iommu_domain *domain,
-				  struct device *dev)
+static void check_for_pci_dma_device(struct device **dev)
=20
"check_for_pci_dma_device()" doesn't give a good clue about what the
function returns.  And why return something via a reference parameter
when you could return it directly?
[Sethi Varun-B16395] I will rename the function to get_dma_device and make =
it return a pointer.
=20
quoted
 {
-	struct fsl_dma_domain *dma_domain =3D domain->priv;
-	const u32 *liodn;
-	u32 liodn_cnt;
-	int len, ret =3D 0;
+#ifdef CONFIG_PCI
 	struct pci_dev *pdev =3D NULL;
 	struct pci_controller *pci_ctl;
=20
This is sort of a goofy looking function.  It would read much better as
something like this:
=20
[Sethi Varun-B16395] Will make the change.
      struct device *dma_dev =3D dev;
=20
  #ifdef CONFIG_PCI
      if (...) {
          dma_dev =3D ...;
      }
  #endif
=20
      return dma_dev;
=20
Does this need to care about reference counting when you return a pointer
to a different device?
=20
[Sethi Varun-B16395] Reference counting isn't required, as we are just obta=
ining the LIODN value from the PCI controller.

-Varun
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help