From patchwork Mon May 4 17:36:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Bresticker X-Patchwork-Id: 6328991 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CF6DA9F1C2 for ; Mon, 4 May 2015 17:40:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E29192026D for ; Mon, 4 May 2015 17:40:44 +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 07ACC200E6 for ; Mon, 4 May 2015 17:40:44 +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 1YpKJc-0003dT-9X; Mon, 04 May 2015 17:38:00 +0000 Received: from mail-yk0-f202.google.com ([209.85.160.202]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YpKIq-0002kP-F7 for linux-arm-kernel@lists.infradead.org; Mon, 04 May 2015 17:37:13 +0000 Received: by ykp9 with SMTP id 9so4342869ykp.0 for ; Mon, 04 May 2015 10:36:50 -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=utvi7VTm79UEmrOINYxlvDoZ48bAzO6F93srPbvQrVg=; b=Kk6ozvA26aoGZO8POGnv1VVmhQWaUDKywr+OL2PhJ/k+yLLN853Yhr7obCM3aji6hP gHjcXH4T/mymyKsyZdigkUMMtY6sk6Va7MMUD3n3+tqf7lABIJ9pLugbtnE3tV4t3A+u WUzW6xcrkXOedOb/l5ts+VCBNv4/DWp68FTv8/O3mcj+ghXyRYOM3nIQOjmrwXUSU66v +5L8JO7LcK793JxTRIwcUB4iHE89N+36dML91CPMMswSZ1i/eth6k8ZiGNSE1TC7zBsJ qlgLuGjnXJWvs96xPqtWqeZ3Tq15kVLoXdRPFIOSKeA0An0nDoCTOLNPtkUf98mZYP6l zTAw== X-Gm-Message-State: ALoCoQm9ibNsTdrjM+yNw7rj81+gezhXiG3I8E1Z8Nr0YMz93cpERV10XQ+0rfWmxgD4aTwu1jH7 X-Received: by 10.140.149.84 with SMTP id 81mr42192485qhv.4.1430761010707; Mon, 04 May 2015 10:36:50 -0700 (PDT) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id v23si727774yhv.4.2015.05.04.10.36.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2015 10:36:50 -0700 (PDT) Received: from abrestic.mtv.corp.google.com ([172.22.65.70]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id 2HHtFqhR.1; Mon, 04 May 2015 10:36:50 -0700 Received: by abrestic.mtv.corp.google.com (Postfix, from userid 137652) id 7649DA4910; Mon, 4 May 2015 10:36:49 -0700 (PDT) From: Andrew Bresticker To: Stephen Warren , Thierry Reding , Alexandre Courbot Subject: [PATCH v8 3/9] mailbox: Fix up error handling in mbox_request_channel() Date: Mon, 4 May 2015 10:36:36 -0700 Message-Id: <1430761002-9327-4-git-send-email-abrestic@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1430761002-9327-1-git-send-email-abrestic@chromium.org> References: <1430761002-9327-1-git-send-email-abrestic@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150504_103712_629799_5BEAF982 X-CRM114-Status: GOOD ( 14.95 ) X-Spam-Score: -0.7 (/) Cc: devicetree@vger.kernel.org, Jassi Brar , Andrew Bresticker , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jon Hunter , 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 Acked-by: Suman Anna Cc: Jassi Brar --- No changes from v7. 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 03f8545..a3dbfd9 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)