From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7] dmaengine: Add MOXA ART DMA engine driver
Date: Mon, 5 Aug 2013 22:49:31 +0200 [thread overview]
Message-ID: <201308052249.32174.arnd@arndb.de> (raw)
In-Reply-To: <1375713457-5562-1-git-send-email-jonas.jensen@gmail.com>
On Monday 05 August 2013, Jonas Jensen wrote:
> +bool moxart_dma_filter_fn(struct dma_chan *chan, void *param)
> +{
> + struct moxart_dma_chan *mchan = to_moxart_dma_chan(chan);
> + struct moxart_dma_container *mc = to_dma_container(mchan->chan.device);
> +
> + if (chan->device->dev == mc->dma_slave.dev) {
This comparison seems rather pointless -- you only check that the
device owning the channel is the same as the device that belongs
to channel's "container", which would naturally be the case.
What you don't check here is that it matches the device that was passed
to of_dma_controller_register().
> + struct moxart_dma_chan *mchan = to_moxart_dma_chan(chan);
> + unsigned int ch_req = *(unsigned int *)param;
> + dev_dbg(chan2dev(chan), "%s: mchan=%p ch_req=%d mchan->ch_num=%d\n",
> + __func__, mchan, ch_req, mchan->ch_num);
> + return ch_req == mchan->ch_num;
> + } else {
> + dev_dbg(chan2dev(chan), "%s: device not registered to this DMA engine\n",
> + __func__);
> + return false;
> + }
> +}
> +
> +static struct of_dma_filter_info moxart_dma_info = {
> + .filter_fn = moxart_dma_filter_fn,
> +};
> +
> +static struct dma_chan *moxart_of_xlate(struct of_phandle_args *dma_spec,
> + struct of_dma *ofdma)
> +{
> + struct dma_chan *chan;
> + struct of_dma_filter_info *info = ofdma->of_dma_data;
> +
> + if (!info || !info->filter_fn)
> + return NULL;
This seems pointless too. Why do you pass a of_dma_filter_info pointer
as ofdma->of_dma_data? It's constant after all and you can just access
it a couple of lines higher.
> + if (dma_spec->args_count != 2)
> + return NULL;
> +
> + chan = dma_request_channel(info->dma_cap, info->filter_fn,
> + &dma_spec->args[0]);
The filter function is also constant. However, you need to pass the
device pointer here so the filter can compare it.
> + if (chan)
> + to_moxart_dma_chan(chan)->line = dma_spec->args[1];
> +
> + return chan;
> +}
There is still an open question here regarding whether or not the
channel number is actually required to be fixed or not. In most
dma engines, the channels are actually interchangeable, so you only
need to specify the request number, not the channel. Does this still
work if you just pick the first
Arnd
WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Jonas Jensen <jonas.jensen@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, arm@kernel.org,
vinod.koul@intel.com, djbw@fb.com, linux@arm.linux.org.uk,
mark.rutland@arm.com
Subject: Re: [PATCH v7] dmaengine: Add MOXA ART DMA engine driver
Date: Mon, 5 Aug 2013 22:49:31 +0200 [thread overview]
Message-ID: <201308052249.32174.arnd@arndb.de> (raw)
In-Reply-To: <1375713457-5562-1-git-send-email-jonas.jensen@gmail.com>
On Monday 05 August 2013, Jonas Jensen wrote:
> +bool moxart_dma_filter_fn(struct dma_chan *chan, void *param)
> +{
> + struct moxart_dma_chan *mchan = to_moxart_dma_chan(chan);
> + struct moxart_dma_container *mc = to_dma_container(mchan->chan.device);
> +
> + if (chan->device->dev == mc->dma_slave.dev) {
This comparison seems rather pointless -- you only check that the
device owning the channel is the same as the device that belongs
to channel's "container", which would naturally be the case.
What you don't check here is that it matches the device that was passed
to of_dma_controller_register().
> + struct moxart_dma_chan *mchan = to_moxart_dma_chan(chan);
> + unsigned int ch_req = *(unsigned int *)param;
> + dev_dbg(chan2dev(chan), "%s: mchan=%p ch_req=%d mchan->ch_num=%d\n",
> + __func__, mchan, ch_req, mchan->ch_num);
> + return ch_req == mchan->ch_num;
> + } else {
> + dev_dbg(chan2dev(chan), "%s: device not registered to this DMA engine\n",
> + __func__);
> + return false;
> + }
> +}
> +
> +static struct of_dma_filter_info moxart_dma_info = {
> + .filter_fn = moxart_dma_filter_fn,
> +};
> +
> +static struct dma_chan *moxart_of_xlate(struct of_phandle_args *dma_spec,
> + struct of_dma *ofdma)
> +{
> + struct dma_chan *chan;
> + struct of_dma_filter_info *info = ofdma->of_dma_data;
> +
> + if (!info || !info->filter_fn)
> + return NULL;
This seems pointless too. Why do you pass a of_dma_filter_info pointer
as ofdma->of_dma_data? It's constant after all and you can just access
it a couple of lines higher.
> + if (dma_spec->args_count != 2)
> + return NULL;
> +
> + chan = dma_request_channel(info->dma_cap, info->filter_fn,
> + &dma_spec->args[0]);
The filter function is also constant. However, you need to pass the
device pointer here so the filter can compare it.
> + if (chan)
> + to_moxart_dma_chan(chan)->line = dma_spec->args[1];
> +
> + return chan;
> +}
There is still an open question here regarding whether or not the
channel number is actually required to be fixed or not. In most
dma engines, the channels are actually interchangeable, so you only
need to specify the request number, not the channel. Does this still
work if you just pick the first
Arnd
next prev parent reply other threads:[~2013-08-05 20:49 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-10 8:51 [PATCH] dmaengine: Add MOXA ART DMA engine driver Jonas Jensen
2013-07-10 8:51 ` Jonas Jensen
2013-07-10 9:30 ` Russell King - ARM Linux
2013-07-10 9:30 ` Russell King - ARM Linux
2013-07-10 9:48 ` Jonas Jensen
2013-07-10 9:48 ` Jonas Jensen
2013-07-10 12:43 ` [PATCH v2] " Jonas Jensen
2013-07-10 12:43 ` Jonas Jensen
2013-07-17 10:06 ` [PATCH v3] " Jonas Jensen
2013-07-17 10:06 ` Jonas Jensen
2013-07-29 13:44 ` [PATCH v4] " Jonas Jensen
2013-07-29 13:44 ` Jonas Jensen
2013-07-29 16:35 ` Arnd Bergmann
2013-07-29 16:35 ` Arnd Bergmann
2013-08-02 12:28 ` Jonas Jensen
2013-08-02 12:28 ` Jonas Jensen
2013-08-02 19:28 ` Arnd Bergmann
2013-08-02 19:28 ` Arnd Bergmann
2013-08-02 12:03 ` [PATCH v5] " Jonas Jensen
2013-08-02 12:03 ` Jonas Jensen
2013-08-02 13:28 ` [PATCH v6] " Jonas Jensen
2013-08-02 13:28 ` Jonas Jensen
2013-08-02 13:51 ` Russell King - ARM Linux
2013-08-02 13:51 ` Russell King - ARM Linux
2013-08-02 14:09 ` Mark Rutland
2013-08-02 14:09 ` Mark Rutland
2013-08-05 14:37 ` [PATCH v7] " Jonas Jensen
2013-08-05 14:37 ` Jonas Jensen
2013-08-05 16:57 ` Mark Rutland
2013-08-05 16:57 ` Mark Rutland
2013-08-05 20:49 ` Arnd Bergmann [this message]
2013-08-05 20:49 ` Arnd Bergmann
2013-08-06 12:38 ` [PATCH v8] " Jonas Jensen
2013-08-06 12:38 ` Jonas Jensen
2013-08-06 18:42 ` Arnd Bergmann
2013-08-06 18:42 ` Arnd Bergmann
2013-08-07 15:13 ` Mark Rutland
2013-08-07 15:13 ` Mark Rutland
2013-10-07 13:42 ` Jonas Jensen
2013-10-07 13:42 ` Jonas Jensen
2013-10-07 13:13 ` [PATCH v9] " Jonas Jensen
2013-10-07 13:13 ` Jonas Jensen
2013-10-07 14:10 ` [PATCH v10] " Jonas Jensen
2013-10-07 14:10 ` Jonas Jensen
2013-10-07 15:12 ` Mark Rutland
2013-10-07 15:12 ` Mark Rutland
2013-10-07 15:12 ` Mark Rutland
2013-10-08 9:53 ` Jonas Jensen
2013-10-08 9:53 ` Jonas Jensen
2013-10-08 9:53 ` Jonas Jensen
2013-10-08 12:55 ` Mark Rutland
2013-10-08 12:55 ` Mark Rutland
2013-10-08 12:55 ` Mark Rutland
2013-10-08 8:42 ` [PATCH v11] " Jonas Jensen
2013-10-08 8:42 ` Jonas Jensen
2013-11-13 13:59 ` Vinod Koul
2013-11-13 13:59 ` Vinod Koul
2013-11-13 17:16 ` Arnd Bergmann
2013-11-13 17:16 ` Arnd Bergmann
2013-12-06 14:27 ` [PATCH v12] " Jonas Jensen
2013-12-06 14:27 ` Jonas Jensen
2013-12-11 15:13 ` [PATCH v13] " Jonas Jensen
2013-12-11 15:13 ` Jonas Jensen
2013-12-11 21:27 ` Arnd Bergmann
2013-12-11 21:27 ` Arnd Bergmann
2013-12-12 9:16 ` Andy Shevchenko
2013-12-12 9:16 ` Andy Shevchenko
2013-12-12 12:32 ` [PATCH v14] " Jonas Jensen
2013-12-12 12:32 ` Jonas Jensen
2013-12-13 16:02 ` Lars-Peter Clausen
2013-12-13 16:02 ` Lars-Peter Clausen
2013-12-16 10:24 ` [PATCH v15] " Jonas Jensen
2013-12-16 10:24 ` Jonas Jensen
2014-01-17 8:46 ` [PATCH v16] " Jonas Jensen
2014-01-17 8:46 ` Jonas Jensen
[not found] ` <1389948365-13999-1-git-send-email-jonas.jensen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-17 13:29 ` Fwd: " Jonas Jensen
2014-01-17 14:42 ` Arnd Bergmann
2014-01-17 14:42 ` Arnd Bergmann
2014-01-20 7:07 ` Vinod Koul
2014-01-20 7:07 ` 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=201308052249.32174.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.