public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: vinod.koul@intel•com (Vinod Koul)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v3 1/2] dmaengine: add interface of dma_get_slave_channel
Date: Mon, 19 Aug 2013 10:55:16 +0530	[thread overview]
Message-ID: <20130819052516.GT32147@intel.com> (raw)
In-Reply-To: <1376550163-30145-2-git-send-email-zhangfei.gao@linaro.org>

On Thu, Aug 15, 2013 at 03:02:42PM +0800, Zhangfei Gao wrote:
> Suggested by Arnd, add dma_get_slave_channel interface
> Dma host driver could get specific channel specificied by request line, rather than filter.
> 
> host example:
> static struct dma_chan *xx_of_dma_simple_xlate(struct of_phandle_args *dma_spec,
> 		struct of_dma *ofdma)
> {
> 	struct xx_dma_dev *d = ofdma->of_dma_data;
> 	unsigned int request = dma_spec->args[0];
> 
> 	if (request > d->dma_requests)
> 		return NULL;
> 
> 	return dma_get_slave_channel(&(d->chans[request].vc.chan));
> }
> 
> probe:
> of_dma_controller_register((&op->dev)->of_node, xx_of_dma_simple_xlate, d);
> 
> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro•org>
> Acked-by: Arnd Bergmann <arnd@arndb•de>
> ---
>  drivers/dma/dmaengine.c   |   25 +++++++++++++++++++++++++
>  include/linux/dmaengine.h |    1 +
>  2 files changed, 26 insertions(+)
> 
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index 9e56745..38dd8c3 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -504,6 +504,31 @@ static struct dma_chan *private_candidate(const dma_cap_mask_t *mask,
>  }
>  
>  /**
> + * dma_request_channel - try to get specific channel exclusively
> + * @chan: target channel
> + */
> +struct dma_chan *dma_get_slave_channel(struct dma_chan *chan)
> +{
> +	int err = -EBUSY;
> +
> +	/* lock against __dma_request_channel */
> +	mutex_lock(&dma_list_mutex);
> +
> +	if (chan->client_count == 0) {
> +		err = dma_chan_get(chan);
> +		if (err)
> +			pr_debug("%s: failed to get %s: (%d)\n",
> +				__func__, dma_chan_name(chan), err);
> +	} else
> +		chan = NULL;
> +
> +	mutex_unlock(&dma_list_mutex);
> +
> +	return chan;
> +}
> +EXPORT_SYMBOL_GPL(dma_get_slave_channel);
No, this is not the right approach.

When patch is applied and you find an issue you fix the issue. I have already
pushed and merged this. So removing is a bad idea.
you provide a fix for this miss.

Also for this you need to give due credit to Dan (reporter). That is how the
process works.

Anyway I have applied the below fix and will push it out.

---
dmaengine: fix - error: potential NULL dereference 'chan'

commit 7bb587f4 "dmaengine: add interface of dma_get_slave_channel" introduced
the above error so fix it

Reported-by: Dan Carpenter <dan.carpenter@oracle•com>
Suggested-by: Zhangfei Gao <zhangfei.gao@linaro•org>
Signed-off-by: Vinod Koul <vinod.koul@intel•com>
---
 drivers/dma/dmaengine.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 5932ab1..755ba2f 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -514,16 +514,16 @@ struct dma_chan *dma_get_slave_channel(struct dma_chan *chan)
 	/* lock against __dma_request_channel */
 	mutex_lock(&dma_list_mutex);
 
-	if (chan->client_count == 0)
+	if (chan->client_count == 0) {
 		err = dma_chan_get(chan);
-	else
+		if (err)
+			pr_debug("%s: failed to get %s: (%d)\n",
+				__func__, dma_chan_name(chan), err);
+	} else
 		chan = NULL;
 
 	mutex_unlock(&dma_list_mutex);
 
-	if (err)
-		pr_debug("%s: failed to get %s: (%d)\n",
-			__func__, dma_chan_name(chan), err);
 
 	return chan;
 }

--
~Vinod

  reply	other threads:[~2013-08-19  5:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-15  7:02 [PATCH v3 0/2] dmaengine: add k3dma Zhangfei Gao
2013-08-15  7:02 ` [PATCH v3 1/2] dmaengine: add interface of dma_get_slave_channel Zhangfei Gao
2013-08-19  5:25   ` Vinod Koul [this message]
2013-08-20  7:58     ` zhangfei gao
2013-08-20  8:13       ` Dan Carpenter
2013-08-20  8:22         ` Vinod Koul
2013-08-27  2:04         ` zhangfei
2013-09-03 20:39           ` Dan Carpenter
2013-08-20  8:22       ` Vinod Koul
2013-08-15  7:02 ` [PATCH v3 2/2] dmaengine: Add hisilicon k3 DMA engine driver Zhangfei Gao

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=20130819052516.GT32147@intel.com \
    --to=vinod.koul@intel$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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