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

From: Sethi Varun-B16395
Date: Tue Oct 15 2013 - 10:35:51 EST




> -----Original Message-----
> From: iommu-bounces@xxxxxxxxxxxxxxxxxxxxxxxxxx [mailto:iommu-
> bounces@xxxxxxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Bjorn Helgaas
> Sent: Tuesday, October 15, 2013 5:46 AM
> To: Sethi Varun-B16395
> Cc: Yoder Stuart-B08248; linux-kernel@xxxxxxxxxxxxxxx; iommu@xxxxxxxxxxxx
> foundation.org; Bhushan Bharat-R65777; Wood Scott-B07421; linuxppc-
> dev@xxxxxxxxxxxxxxxx
> Subject: Re: [PATCH 1/3] iommu/fsl: Factor out PCI specific code.
>
> On Sun, Oct 13, 2013 at 02:02:32AM +0530, Varun Sethi wrote:
> > Factor out PCI specific code in the PAMU driver.
> >
> > Signed-off-by: Varun Sethi <Varun.Sethi@xxxxxxxxxxxxx>
> > ---
> > drivers/iommu/fsl_pamu_domain.c | 81 +++++++++++++++++++------------
> --------
> > 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,
> > 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)
>
> "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.
>
> > {
> > - struct fsl_dma_domain *dma_domain = domain->priv;
> > - const u32 *liodn;
> > - u32 liodn_cnt;
> > - int len, ret = 0;
> > +#ifdef CONFIG_PCI
> > struct pci_dev *pdev = NULL;
> > struct pci_controller *pci_ctl;
>
> This is sort of a goofy looking function. It would read much better as
> something like this:
>
[Sethi Varun-B16395] Will make the change.

> struct device *dma_dev = dev;
>
> #ifdef CONFIG_PCI
> if (...) {
> dma_dev = ...;
> }
> #endif
>
> return dma_dev;
>
> Does this need to care about reference counting when you return a pointer
> to a different device?
>
[Sethi Varun-B16395] Reference counting isn't required, as we are just obtaining the LIODN value from the PCI controller.

-Varun

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/