Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030802AbbD1QnH (ORCPT ); Tue, 28 Apr 2015 12:43:07 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:35100 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030472AbbD1QnD (ORCPT ); Tue, 28 Apr 2015 12:43:03 -0400 Message-ID: <553FB87B.8000509@ti.com> Date: Tue, 28 Apr 2015 11:42:35 -0500 From: Suman Anna User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Andrew Bresticker , Stephen Warren , Thierry Reding , Alexandre Courbot CC: , , , , , Benson Leung , Jassi Brar Subject: Re: [PATCH V7 3/9] mailbox: Fix up error handling in mbox_request_channel() References: <1430174242-29465-1-git-send-email-abrestic@chromium.org> <1430174242-29465-4-git-send-email-abrestic@chromium.org> In-Reply-To: <1430174242-29465-4-git-send-email-abrestic@chromium.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3316 Lines: 96 On 04/27/2015 05:37 PM, Andrew Bresticker wrote: > From: Benson Leung > > 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 > Signed-off-by: Andrew Bresticker > Cc: Jassi Brar > Cc: Suman Anna > --- > 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 > 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) > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/