From patchwork Mon Apr 27 22:37:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Bresticker X-Patchwork-Id: 6283911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 289B1BEEE1 for ; Mon, 27 Apr 2015 22:43:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 470D8202F8 for ; Mon, 27 Apr 2015 22:43:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A71D202F0 for ; Mon, 27 Apr 2015 22:43:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ymrh5-0006Ix-I8; Mon, 27 Apr 2015 22:40:03 +0000 Received: from mail-pd0-f201.google.com ([209.85.192.201]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YmrfJ-0005ON-Le for linux-arm-kernel@lists.infradead.org; Mon, 27 Apr 2015 22:38:14 +0000 Received: by pdev10 with SMTP id v10so9671602pde.1 for ; Mon, 27 Apr 2015 15:37:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/Lw/Cl+FiNB1EXGeafK/hBkmPzIfJ9avXQV6TpIqCYg=; b=dOEIaUVAzq4QLC9iqg5Z951AM2dzRyKnilOjnZtniW6fq/z7LsnHAAEIV3BY5xWuv8 3lat/WVaDmOJ7G9Uo8fU2i6ihPP2zcW4NBeJ7TtlLzE8zE3TSNPPnQsNsJu1kTYrY+W4 KnVSsJ67zWX9jHfTvtBEdNV38gKdMZqwRlOArQ2ivKkJJmIlGvq0jgxP7MzO8BbGejwP 1Z1UaK/3l9fwyPwLjM3PQRtrdhfLo2VfByne2d3YJk7ZxJ3XOWjMjnDCqXnqUCPenvU/ NgmtaJJ3VcpK+L6mVgbCLWK2zPoHtF/xRfFL36ODBzqZo4FIRROi0ul8u18KFuOufYpL adAg== X-Gm-Message-State: ALoCoQkw9YcDKZjWZac/o/p5alE7j9VU7z3dPGcdwXxXzK2oN6ZwcUKBotdPB1avCmMACs7hzlDD X-Received: by 10.70.48.206 with SMTP id o14mr23521513pdn.1.1430174271163; Mon, 27 Apr 2015 15:37:51 -0700 (PDT) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id l36si1187706yhb.1.2015.04.27.15.37.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Apr 2015 15:37:51 -0700 (PDT) Received: from abrestic.mtv.corp.google.com ([172.22.65.70]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTP id ZNn0bwvT.1; Mon, 27 Apr 2015 15:37:51 -0700 Received: by abrestic.mtv.corp.google.com (Postfix, from userid 137652) id EEA65A49BE; Mon, 27 Apr 2015 15:37:49 -0700 (PDT) From: Andrew Bresticker To: Stephen Warren , Thierry Reding , Alexandre Courbot Subject: [PATCH V7 3/9] mailbox: Fix up error handling in mbox_request_channel() Date: Mon, 27 Apr 2015 15:37:16 -0700 Message-Id: <1430174242-29465-4-git-send-email-abrestic@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1430174242-29465-1-git-send-email-abrestic@chromium.org> References: <1430174242-29465-1-git-send-email-abrestic@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150427_153813_765021_348F1872 X-CRM114-Status: GOOD ( 14.60 ) X-Spam-Score: -0.9 (/) Cc: devicetree@vger.kernel.org, Jassi Brar , Andrew Bresticker , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, Benson Leung , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: 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 +++--- 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)