Subject: [PATCH] of: Add generic device tree DMA helpers

From: [email-masked] (Arnd Bergmann)
Date: Sun, 18 Mar 2012 21:58:10 +0000

On Sunday 18 March 2012, Grant Likely wrote:
> > struct dma_channel *of_dma_request_channel(struct of_node*, int index,
> >                                       dma_cap_mask_t *mask,
> >                                       void *driver_data)
> > {
> >       struct of_phandle_args dma_spec;
> >       struct dma_device *device;
> >       struct dma_chan *chan = NULL;
> >       dma_filter_fn *filter;
> > 
> >       ret = of_parse_phandle_with_args(np, "dma-request", "#dma-cells",
> >                                        index, &dma_spec);
> > 
> >       device = dma_find_device(dma_spec->np);
> 
> Is dma_find_device() a new function?  How does it look up the dma
> device?

Yes, it would be similar to the proposed function in Benoit's patch

> > 
> >       if (dma_spec->args_count == 0)
> >               filter = dma_filter_simple;
> >       else
> >               filter = device->dma_dt_filter; /* new member */
> 
> I'm not thrilled with this if/else hunk; even the case of
> #dma-cells=<0> should provide a hook; even it if is the stock simple
> filter.  Leaving filter as NULL is the same as accepting everything
> anyway.

Right, good point. So a dmaengine driver would either register a trivial
filter if it wants to do anything here, or it would just leave it as a NULL
pointer otherwise.

	Arnd