All of lore.kernel.org
 help / color / mirror / Atom feed
From: rizhao@nvidia.com (Richard Zhao)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] DMA: add help function to check whether dma controller registered
Date: Mon, 5 Aug 2013 13:56:09 +0800	[thread overview]
Message-ID: <20130805055607.GC31469@rizhao-lap> (raw)
In-Reply-To: <51FC0FBF.9010107@wwwdotorg.org>

On Sat, Aug 03, 2013 at 03:59:59AM +0800, Stephen Warren wrote:
> On 08/02/2013 12:04 AM, Richard Zhao wrote:
> > DMA client device driver usually needs to know at probe time whether
> > dma controller has been registered to deffer probe. So add a help
> > function of_dma_check_controller.
> > 
> > DMA request channel functions can also used to check it, but they
> > are usually called at open() time.
> 
> > diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
> > index e1c4d3b..b6828c1 100644
> 
> > +int of_dma_check_controller(struct device *dev, const char *name)
> 
> 
> > +	for (i = 0; i < count; i++) {
> > +		if (of_dma_match_channel(np, name, i, &dma_spec))
> > +			continue;
> > +
> > +		mutex_lock(&of_dma_lock);
> > +		ofdma = of_dma_find_controller(&dma_spec);
> > +		mutex_unlock(&of_dma_lock);
> > +		of_node_put(dma_spec.np);
> 
> Do we need to add the following here:
> 
> if (ofdma)
> 	break
> 
> To ensure that as soon as a successful match is found, the loop exits?
> Otherwise, if there are multiple providers for that name, and the first
> N are registered but the last isn't, this function will still return
> failure.
Right. Thanks.
> 
> > +	if (ofdma)
> > +		return 0;
> > +	else
> > +		return -ENODEV;
> 
> That probably should be -EPROBE_DEFER?
> 
> Although, what about differentiating between "entry not found by
> of_dma_match_channel" and "controller not yet probed"?
I thought it might be called in non-probe functions.  If no people
against it, I'll change it to EPROBE_DEFER.

Thanks
Richard

WARNING: multiple messages have this Message-ID (diff)
From: Richard Zhao <rizhao@nvidia.com>
To: Stephen Warren <swarren@wwwdotorg.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"vinod.koul@intel.com" <vinod.koul@intel.com>,
	"djbw@fb.com" <djbw@fb.com>,
	"grant.likely@linaro.org" <grant.likely@linaro.org>,
	"rob.herring@calxeda.com" <rob.herring@calxeda.com>
Subject: Re: [PATCH] DMA: add help function to check whether dma controller registered
Date: Mon, 5 Aug 2013 13:56:09 +0800	[thread overview]
Message-ID: <20130805055607.GC31469@rizhao-lap> (raw)
In-Reply-To: <51FC0FBF.9010107@wwwdotorg.org>

On Sat, Aug 03, 2013 at 03:59:59AM +0800, Stephen Warren wrote:
> On 08/02/2013 12:04 AM, Richard Zhao wrote:
> > DMA client device driver usually needs to know at probe time whether
> > dma controller has been registered to deffer probe. So add a help
> > function of_dma_check_controller.
> > 
> > DMA request channel functions can also used to check it, but they
> > are usually called at open() time.
> 
> > diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
> > index e1c4d3b..b6828c1 100644
> 
> > +int of_dma_check_controller(struct device *dev, const char *name)
> 
> 
> > +	for (i = 0; i < count; i++) {
> > +		if (of_dma_match_channel(np, name, i, &dma_spec))
> > +			continue;
> > +
> > +		mutex_lock(&of_dma_lock);
> > +		ofdma = of_dma_find_controller(&dma_spec);
> > +		mutex_unlock(&of_dma_lock);
> > +		of_node_put(dma_spec.np);
> 
> Do we need to add the following here:
> 
> if (ofdma)
> 	break
> 
> To ensure that as soon as a successful match is found, the loop exits?
> Otherwise, if there are multiple providers for that name, and the first
> N are registered but the last isn't, this function will still return
> failure.
Right. Thanks.
> 
> > +	if (ofdma)
> > +		return 0;
> > +	else
> > +		return -ENODEV;
> 
> That probably should be -EPROBE_DEFER?
> 
> Although, what about differentiating between "entry not found by
> of_dma_match_channel" and "controller not yet probed"?
I thought it might be called in non-probe functions.  If no people
against it, I'll change it to EPROBE_DEFER.

Thanks
Richard

  reply	other threads:[~2013-08-05  5:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-02  6:04 [PATCH] DMA: add help function to check whether dma controller registered Richard Zhao
2013-08-02  6:04 ` Richard Zhao
2013-08-02 19:59 ` Stephen Warren
2013-08-02 19:59   ` Stephen Warren
2013-08-05  5:56   ` Richard Zhao [this message]
2013-08-05  5:56     ` Richard Zhao
2013-08-22  6:43 ` [PATCH v2] " Richard Zhao
2013-08-22  6:43   ` Richard Zhao
2013-08-22  6:43   ` Richard Zhao
2013-08-22 20:36   ` Stephen Warren
2013-08-22 20:36     ` Stephen Warren
2013-08-23  1:17     ` Richard Zhao
2013-08-23  1:17       ` Richard Zhao
2013-08-23 15:56       ` Stephen Warren
2013-08-23 15:56         ` Stephen Warren

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=20130805055607.GC31469@rizhao-lap \
    --to=rizhao@nvidia.com \
    --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.