From: Arnd Bergmann <arnd@arndb.de>
To: Barry Song <21cnbao@gmail.com>
Cc: Barry Song <Baohua.Song@csr.com>,
vinod.koul@intel.com, linux-kernel@vger.kernel.org,
workgroup.linux@csr.com, Rongjun Ying <rongjun.ying@csr.com>,
dan.j.williams@intel.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] dmaengine: add CSR SiRFprimaII DMAC driver
Date: Thu, 8 Sep 2011 18:19:29 +0200 [thread overview]
Message-ID: <201109081819.30035.arnd@arndb.de> (raw)
In-Reply-To: <CAGsJ_4wOQddus_Vz5zUjy-4ETOeaiZ+STRD22SwRy+yr4YLaRA@mail.gmail.com>
On Thursday 08 September 2011, Barry Song wrote:
> i am not sure whether i have other way to require a special channel
> for a special device. it seems dma_request_channel only gives me a
> chance to use a filter function since my all channels have same DMA
> cap masks.
>
> this filter is used by all drivers with DMA since every dma channel is
> fixed to be assigned to one device.
>
> i did do some copy from coh901318.c:
> bool coh901318_filter_id(struct dma_chan *chan, void *chan_id)
> {
> unsigned int ch_nr = (unsigned int) chan_id;
>
> if (ch_nr == to_coh901318_chan(chan)->id)
> return true;
>
> return false;
> }
> EXPORT_SYMBOL(coh901318_filter_id);
>
> if it does become a common filter, we might have a function like:
>
> bool dmaengine_filter_match_channel_id(struct dma_chan *chan, void *chan_id)
> {
> if (ch_nr == chan->chan_id)
> return true;
>
> return false;
> }
> EXPORT_SYMBOL(dmaengine_filter_match_channel_id);
Ok, I see now. I think it would be best to introduce a generic
'filter by device tree property' function or alternatively an
dma_of_request_channel function like this:
struct dma_chan *dma_of_request_channel(struct device *dev, unsigned int index)
{
struct dma_device *dmadev;
struct {
unsigned int phandle;
unsigned int channel_num;
} *property;
int lenp;
property = of_get_property(dev->of_node, "dma-channel", &lenp);
if (lenp < (index * sizeof (*property))
return -EINVAL;
property += index;
dmadev = dma_find_device(of_find_node_by_phandle(property->phandle));
if (!dmadev)
return -ENODEV;
return dma_get_channel(dmadev, property->channel_num);
}
This way, you can link a device to its dma_channel in the device tree without
the device driver even understanding what a dma_device or a channel id
is.
Arnd
next prev parent reply other threads:[~2011-09-09 2:11 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-07 5:41 [PATCH] dmaengine: add CSR SiRFprimaII DMAC driver Barry Song
2011-09-07 16:14 ` Koul, Vinod
2011-09-07 16:46 ` Barry Song
2011-09-07 18:09 ` Koul, Vinod
2011-09-08 2:12 ` Barry Song
2011-09-08 3:17 ` Jassi Brar
2011-09-08 5:25 ` Jassi Brar
2011-09-08 6:36 ` Barry Song
2011-09-08 7:49 ` Jassi Brar
2011-09-08 21:51 ` Vinod Koul
2011-09-09 2:35 ` Barry Song
2011-09-09 2:52 ` Barry Song
2011-09-09 16:25 ` Vinod Koul
2011-09-09 23:37 ` Barry Song
2011-09-11 15:59 ` Vinod Koul
2011-09-12 0:13 ` Barry Song
2011-09-08 21:46 ` Vinod Koul
2011-09-09 8:18 ` Barry Song
2011-09-09 16:21 ` Vinod Koul
2011-09-09 23:40 ` Barry Song
2011-09-10 7:33 ` Jassi Brar
2011-09-11 16:02 ` Vinod Koul
2011-09-12 6:33 ` Jassi Brar
2011-09-14 5:07 ` Vinod Koul
2011-09-14 6:46 ` Barry Song
2011-09-14 7:11 ` Jassi Brar
2011-09-14 9:49 ` Barry Song
2011-09-08 6:14 ` Barry Song
2011-09-08 6:37 ` Jassi Brar
2011-09-08 2:18 ` Barry Song
2011-09-16 9:06 ` Barry Song
2011-09-07 19:27 ` Linus Walleij
2011-09-08 1:47 ` Barry Song
2011-09-08 14:52 ` Arnd Bergmann
2011-09-08 15:27 ` Barry Song
2011-09-08 16:19 ` Arnd Bergmann [this message]
[not found] ` <CAKnu2Mpnjec-hvfbT0zH1P2mGZKNwTQYgDLGHWUXLmGGQB0_ow@mail.gmail.com>
2011-09-08 20:11 ` Arnd Bergmann
2011-09-08 21:38 ` Vinod Koul
2011-09-11 21:27 ` Linus Walleij
2011-09-12 0:01 ` Barry Song
2011-09-14 4:54 ` Vinod Koul
2011-09-09 16:10 ` Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201109081819.30035.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=21cnbao@gmail.com \
--cc=Baohua.Song@csr.com \
--cc=dan.j.williams@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rongjun.ying@csr.com \
--cc=vinod.koul@intel.com \
--cc=workgroup.linux@csr.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox