Re: [PATCH 05/11] of: Ratify of_dma_configure() interface

From: Nicolas Saenz Julienne
Date: Mon Sep 30 2019 - 09:33:00 EST


On Mon, 2019-09-30 at 05:57 -0700, Christoph Hellwig wrote:
> On Thu, Sep 26, 2019 at 07:24:49PM -0500, Rob Herring wrote:
> > -int of_dma_configure(struct device *dev, struct device_node *np, bool
> > force_dma)
> > +int of_dma_configure(struct device *dev, struct device_node *parent, bool
> > force_dma)
>
> This creates a > 80 char line.
>
> > {
> > u64 dma_addr, paddr, size = 0;
> > int ret;
> > bool coherent;
> > unsigned long offset;
> > const struct iommu_ops *iommu;
> > + struct device_node *np;
> > u64 mask;
> >
> > + np = dev->of_node;
> > + if (!np)
> > + np = parent;
> > + if (!np)
> > + return -ENODEV;
>
> I have to say I find the older calling convention simpler to understand.
> If we want to enforce the invariant I'd rather do that explicitly:
>
> if (dev->of_node && np != dev->of_node)
> return -EINVAL;

As is, this would break Freescale Layerscape fsl-mc bus' dma_configure():

static int fsl_mc_dma_configure(struct device *dev)
{
struct device *dma_dev = dev;

while (dev_is_fsl_mc(dma_dev))
dma_dev = dma_dev->parent;

return of_dma_configure(dev, dma_dev->of_node, 0);
}

But I think that with this series, given the fact that we now treat the lack of
dma-ranges as a 1:1 mapping instead of an error, we could rewrite the function
like this:

static int fsl_mc_dma_configure(struct device *dev)
{
return of_dma_configure(dev, false, 0);
}

If needed I can test this.

Regards,
Nicolas

Attachment: signature.asc
Description: This is a digitally signed message part