From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: Zubair Lutfullah Kakakhel
<Zubair.Kakakhel-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
Cc: vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
alex-oucj9GSTHrKwpo/f3jThPQ@public.gmane.org
Subject: Re: [PATCH_V4 2/3] dma: jz4780: add driver for the Ingenic JZ4780 DMA controller
Date: Thu, 02 Apr 2015 16:51:44 +0200 [thread overview]
Message-ID: <2520994.aQ5VZIsnTb@wuerfel> (raw)
In-Reply-To: <1426695397-54906-3-git-send-email-Zubair.Kakakhel-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
On Wednesday 18 March 2015 16:16:36 Zubair Lutfullah Kakakhel wrote:
> +
> +static bool jz4780_dma_filter_fn(struct dma_chan *chan, void *param)
> +{
> + struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan);
> + struct jz4780_dma_dev *jzdma = jz4780_dma_chan_parent(jzchan);
> + struct jz4780_dma_data *data = param;
> +
> + if (data->channel > -1) {
> + if (data->channel != jzchan->id)
> + return false;
> + } else if (jzdma->chan_reserved & BIT(jzchan->id)) {
> + return false;
> + }
> +
> + jzchan->transfer_type = data->transfer_type;
> +
> + return true;
> +}
> +
> +static struct dma_chan *jz4780_of_dma_xlate(struct of_phandle_args *dma_spec,
> + struct of_dma *ofdma)
> +{
> + struct jz4780_dma_dev *jzdma = ofdma->of_dma_data;
> + dma_cap_mask_t mask = jzdma->dma_device.cap_mask;
> + struct jz4780_dma_data data;
> +
> + if (dma_spec->args_count != 2)
> + return NULL;
> +
> + data.transfer_type = dma_spec->args[0];
> + data.channel = dma_spec->args[1];
> +
> + if (data.channel > -1) {
> + if (data.channel >= JZ_DMA_NR_CHANNELS) {
> + dev_err(jzdma->dma_device.dev,
> + "device requested non-existent channel %u\n",
> + data.channel);
> + return NULL;
> + }
> +
> + /* Can only select a channel marked as reserved. */
> + if (!(jzdma->chan_reserved & BIT(data.channel))) {
> + dev_err(jzdma->dma_device.dev,
> + "device requested unreserved channel %u\n",
> + data.channel);
> + return NULL;
> + }
> + }
> +
> + return dma_request_channel(mask, jz4780_dma_filter_fn, &data);
> +}
> +
You should be able to avoid the use of the filter function by calling
dma_get_slave_channel. You already know which channel you want, so no
need to scan all channels of all controllers in the system.
> --- /dev/null
> +++ b/include/dt-bindings/dma/jz4780-dma.h
> @@ -0,0 +1,49 @@
> +#ifndef __DT_BINDINGS_DMA_JZ4780_DMA_H__
> +#define __DT_BINDINGS_DMA_JZ4780_DMA_H__
> +
> +/*
> + * Request type numbers for the JZ4780 DMA controller (written to the DRTn
> + * register for the channel).
> + */
> +#define JZ4780_DMA_I2S1_TX 0x4
> +#define JZ4780_DMA_I2S1_RX 0x5
> +#define JZ4780_DMA_I2S0_TX 0x6
> +#define JZ4780_DMA_I2S0_RX 0x7
> +#define JZ4780_DMA_AUTO 0x8
> +#define JZ4780_DMA_SADC_RX 0x9
This is evidently just a hardware number, so please don't introduce
a false dependency here, and remove that header file. Putting the numbers
into the dts file like you do for gpio or irq numbers makes it easier to
do updates and avoids dependencies between the platform and driver files.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-04-02 14:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-18 16:16 [PATCH_V4 0/3] dma: dt: Add DMA driver for jz4780 Zubair Lutfullah Kakakhel
2015-03-18 16:16 ` [PATCH_V4 1/3] dt-bindings: dma: Add binding for jz4780-dma Zubair Lutfullah Kakakhel
2015-03-18 16:16 ` [PATCH_V4 2/3] dma: jz4780: add driver for the Ingenic JZ4780 DMA controller Zubair Lutfullah Kakakhel
[not found] ` <1426695397-54906-3-git-send-email-Zubair.Kakakhel-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-04-02 14:51 ` Arnd Bergmann [this message]
[not found] ` <1426695397-54906-1-git-send-email-Zubair.Kakakhel-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-03-18 16:16 ` [PATCH_V4 3/3] MAINTAINERS: Add Ingenic JZ4780 DMA driver maintainer entry Zubair Lutfullah Kakakhel
2015-04-01 3:15 ` [PATCH_V4 0/3] dma: dt: Add DMA driver for jz4780 Vinod Koul
2015-04-02 14:52 ` Arnd Bergmann
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=2520994.aQ5VZIsnTb@wuerfel \
--to=arnd-r2ngtmty4d4@public.gmane.org \
--cc=Zubair.Kakakhel-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org \
--cc=alex-oucj9GSTHrKwpo/f3jThPQ@public.gmane.org \
--cc=dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox