devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Suman Anna <s-anna@ti.com>
To: Andrew Bresticker <abrestic@chromium.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Alexandre Courbot <gnurou@gmail.com>
Cc: linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Benson Leung <bleung@chromium.org>,
	Jassi Brar <jassisinghbrar@gmail.com>
Subject: Re: [PATCH V7 3/9] mailbox: Fix up error handling in mbox_request_channel()
Date: Tue, 28 Apr 2015 11:42:35 -0500	[thread overview]
Message-ID: <553FB87B.8000509@ti.com> (raw)
In-Reply-To: <1430174242-29465-4-git-send-email-abrestic@chromium.org>

On 04/27/2015 05:37 PM, Andrew Bresticker wrote:
> From: Benson Leung <bleung@chromium.org>
> 
> mbox_request_channel() currently returns EBUSY in the event the controller
> is not present or if of_xlate() fails, but in neither case is EBUSY really
> appropriate.  Return EPROBE_DEFER if the controller is not yet present
> and change of_xlate() to return an ERR_PTR instead of NULL so that the
> error can be propagated back to the caller of mbox_request_channel().
> 
> Signed-off-by: Benson Leung <bleung@chromium.org>
> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
> Cc: Jassi Brar <jassisinghbrar@gmail.com>
> Cc: Suman Anna <s-anna@ti.com>
> ---
> Changes from v6:
>  - Update omap-mailbox's xlate() to return error codes.
> No changes from v5.
> New for v5.
> ---
>  drivers/mailbox/mailbox.c      | 11 ++++++++---
>  drivers/mailbox/omap-mailbox.c |  6 +++---

For the OMAP mailbox portion,
Acked-by: Suman Anna <s-anna@ti.com>

>  2 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
> index 19b491d..c3c42d4 100644
> --- a/drivers/mailbox/mailbox.c
> +++ b/drivers/mailbox/mailbox.c
> @@ -318,7 +318,7 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index)
>  		return ERR_PTR(-ENODEV);
>  	}
>  
> -	chan = NULL;
> +	chan = ERR_PTR(-EPROBE_DEFER);
>  	list_for_each_entry(mbox, &mbox_cons, node)
>  		if (mbox->dev->of_node == spec.np) {
>  			chan = mbox->of_xlate(mbox, &spec);
> @@ -327,7 +327,12 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index)
>  
>  	of_node_put(spec.np);
>  
> -	if (!chan || chan->cl || !try_module_get(mbox->dev->driver->owner)) {
> +	if (IS_ERR(chan)) {
> +		mutex_unlock(&con_mutex);
> +		return chan;
> +	}
> +
> +	if (chan->cl || !try_module_get(mbox->dev->driver->owner)) {
>  		dev_dbg(dev, "%s: mailbox not free\n", __func__);
>  		mutex_unlock(&con_mutex);
>  		return ERR_PTR(-EBUSY);
> @@ -390,7 +395,7 @@ of_mbox_index_xlate(struct mbox_controller *mbox,
>  	int ind = sp->args[0];
>  
>  	if (ind >= mbox->num_chans)
> -		return NULL;
> +		return ERR_PTR(-EINVAL);
>  
>  	return &mbox->chans[ind];
>  }
> diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c
> index 0f332c1..e0df27b 100644
> --- a/drivers/mailbox/omap-mailbox.c
> +++ b/drivers/mailbox/omap-mailbox.c
> @@ -639,18 +639,18 @@ static struct mbox_chan *omap_mbox_of_xlate(struct mbox_controller *controller,
>  
>  	mdev = container_of(controller, struct omap_mbox_device, controller);
>  	if (WARN_ON(!mdev))
> -		return NULL;
> +		return ERR_PTR(-EINVAL);
>  
>  	node = of_find_node_by_phandle(phandle);
>  	if (!node) {
>  		pr_err("%s: could not find node phandle 0x%x\n",
>  		       __func__, phandle);
> -		return NULL;
> +		return ERR_PTR(-ENODEV);
>  	}
>  
>  	mbox = omap_mbox_device_find(mdev, node->name);
>  	of_node_put(node);
> -	return mbox ? mbox->chan : NULL;
> +	return mbox ? mbox->chan : ERR_PTR(-ENOENT);
>  }
>  
>  static int omap_mbox_probe(struct platform_device *pdev)
> 

  reply	other threads:[~2015-04-28 16:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 22:37 [PATCH V7 0/9] Tegra xHCI support Andrew Bresticker
2015-04-27 22:37 ` [PATCH V7 1/9] xhci: Set shared HCD's hcd_priv in xhci_gen_setup Andrew Bresticker
     [not found] ` <1430174242-29465-1-git-send-email-abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2015-04-27 22:37   ` [PATCH V7 2/9] mailbox: Make struct mbox_controller's ops field const Andrew Bresticker
     [not found]     ` <1430174242-29465-3-git-send-email-abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2015-04-28 16:49       ` Suman Anna
2015-04-27 22:37   ` [PATCH V7 3/9] mailbox: Fix up error handling in mbox_request_channel() Andrew Bresticker
2015-04-28 16:42     ` Suman Anna [this message]
2015-04-27 22:37   ` [PATCH V7 4/9] mfd: Add binding document for NVIDIA Tegra XUSB Andrew Bresticker
     [not found]     ` <1430174242-29465-5-git-send-email-abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2015-04-29  9:25       ` Lee Jones
2015-04-29 17:02         ` Andrew Bresticker
     [not found]           ` <CAL1qeaFh5go_K0GnGXxU7KqjcgCm2kpUL5mVgGSYosPoXAXgpw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-04-29 18:34             ` Lee Jones
2015-04-29 19:46               ` Andrew Bresticker
     [not found]                 ` <CAL1qeaEt9kGbcCfwqhVzwJxx9DvgOnjfU6C8MCH6t0vqwJK0WA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-04-30 10:06                   ` Lee Jones
2015-04-30 16:28                     ` Andrew Bresticker
2015-04-27 22:37   ` [PATCH V7 5/9] mfd: Add driver " Andrew Bresticker
2015-04-29  9:23     ` Lee Jones
2015-04-29 17:59       ` Andrew Bresticker
2015-04-29 18:30         ` Lee Jones
2015-04-27 22:37   ` [PATCH V7 6/9] mailbox: Add NVIDIA Tegra XUSB mailbox binding Andrew Bresticker
2015-04-27 22:37   ` [PATCH V7 7/9] mailbox: Add NVIDIA Tegra XUSB mailbox driver Andrew Bresticker
2015-04-27 22:37   ` [PATCH V7 8/9] usb: Add NVIDIA Tegra xHCI controller binding Andrew Bresticker
2015-04-27 22:37 ` [PATCH V7 9/9] usb: xhci: Add NVIDIA Tegra xHCI host-controller driver Andrew Bresticker

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=553FB87B.8000509@ti.com \
    --to=s-anna@ti.com \
    --cc=abrestic@chromium.org \
    --cc=bleung@chromium.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gnurou@gmail.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=swarren@wwwdotorg.org \
    --cc=thierry.reding@gmail.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;
as well as URLs for NNTP newsgroup(s).