summaryrefslogtreecommitdiffstats
path: root/drivers/mailbox/mailbox.c
diff options
context:
space:
mode:
authorBenson Leung <bleung@chromium.org>2015-05-04 13:36:36 -0400
committerJassi Brar <jaswinder.singh@linaro.org>2015-05-11 23:48:21 -0400
commit2d805fc1c6b2ec09f27bcd951c2aee3da919f81a (patch)
tree295523b6586a470b8b01e91929b531cf3c0e0af4 /drivers/mailbox/mailbox.c
parent05ae797566a66d159cf1e2ee11bf3f6fae40c8eb (diff)
mailbox: Fix up error handling in mbox_request_channel()
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> Acked-by: Suman Anna <s-anna@ti.com> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
Diffstat (limited to 'drivers/mailbox/mailbox.c')
-rw-r--r--drivers/mailbox/mailbox.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 19b491d2964f..c3c42d42d017 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)
318 return ERR_PTR(-ENODEV); 318 return ERR_PTR(-ENODEV);
319 } 319 }
320 320
321 chan = NULL; 321 chan = ERR_PTR(-EPROBE_DEFER);
322 list_for_each_entry(mbox, &mbox_cons, node) 322 list_for_each_entry(mbox, &mbox_cons, node)
323 if (mbox->dev->of_node == spec.np) { 323 if (mbox->dev->of_node == spec.np) {
324 chan = mbox->of_xlate(mbox, &spec); 324 chan = mbox->of_xlate(mbox, &spec);
@@ -327,7 +327,12 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index)
327 327
328 of_node_put(spec.np); 328 of_node_put(spec.np);
329 329
330 if (!chan || chan->cl || !try_module_get(mbox->dev->driver->owner)) { 330 if (IS_ERR(chan)) {
331 mutex_unlock(&con_mutex);
332 return chan;
333 }
334
335 if (chan->cl || !try_module_get(mbox->dev->driver->owner)) {
331 dev_dbg(dev, "%s: mailbox not free\n", __func__); 336 dev_dbg(dev, "%s: mailbox not free\n", __func__);
332 mutex_unlock(&con_mutex); 337 mutex_unlock(&con_mutex);
333 return ERR_PTR(-EBUSY); 338 return ERR_PTR(-EBUSY);
@@ -390,7 +395,7 @@ of_mbox_index_xlate(struct mbox_controller *mbox,
390 int ind = sp->args[0]; 395 int ind = sp->args[0];
391 396
392 if (ind >= mbox->num_chans) 397 if (ind >= mbox->num_chans)
393 return NULL; 398 return ERR_PTR(-EINVAL);
394 399
395 return &mbox->chans[ind]; 400 return &mbox->chans[ind];
396} 401}