CHROMIUM: mailbox - Defer if request channel called before register

If mbox_request_channel is called before mbox_controller_register,
it will return -EBUSY. Lets return -EPROBE_DEFER to allow
the requester to try again later on when register has been done.

Also, cleaned up the return values of of_xlate. It now returns
an ERR_PTR instead of NULL.

Signed-off-by: Benson Leung <bleung@chromium.org>

BUG=chrome-os-partner:30796
TEST=Boot, plug in usb. see it enumerate.

Change-Id: I58888cc8049807020a98d72e7f7797dd005c818f
Reviewed-on: https://chromium-review.googlesource.com/227545
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Benson Leung <bleung@chromium.org>
Tested-by: Benson Leung <bleung@chromium.org>
This commit is contained in:
Benson Leung
2014-11-04 09:31:15 -08:00
committed by chrome-internal-fetch
parent 7f96400cd3
commit 1c95069950
2 changed files with 9 additions and 4 deletions

View File

@@ -315,7 +315,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);
@@ -324,7 +324,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);
@@ -387,7 +392,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];
}

View File

@@ -198,7 +198,7 @@ static struct mbox_chan *tegra_xusb_mbox_of_xlate(struct mbox_controller *ctlr,
const struct of_phandle_args *sp)
{
struct tegra_xusb_mbox *mbox = dev_get_drvdata(ctlr->dev);
struct mbox_chan *chan = NULL;
struct mbox_chan *chan = ERR_PTR(-EBUSY);
unsigned long flags;
int i;