From patchwork Tue Nov 25 00:17:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Bresticker X-Patchwork-Id: 5371101 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 67824C11AC for ; Tue, 25 Nov 2014 00:21:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8CDA920158 for ; Tue, 25 Nov 2014 00:21: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 AB99E20154 for ; Tue, 25 Nov 2014 00:21: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 1Xt3qI-0006E9-Sv; Tue, 25 Nov 2014 00:18:54 +0000 Received: from mail-qc0-f202.google.com ([209.85.216.202]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xt3pJ-0005mX-Tl for linux-arm-kernel@lists.infradead.org; Tue, 25 Nov 2014 00:17:54 +0000 Received: by mail-qc0-f202.google.com with SMTP id i17so627039qcy.5 for ; Mon, 24 Nov 2014 16:17:32 -0800 (PST) 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=gKcWj+nVZjLPGvDqnpnX9syeJoVYm6Pqv3Yo9Pv4EVM=; b=YeFdPYNNL6Iczk5FgvCHpppPS7lD31xw1l1IpZJxJJd9Ko5CNda5oKtWIOFT03ibtR zPPlMwZCtprvkVPIayfVqBDCqfoA2tzX+Sz0DV7JtekSQO7d/6mZ8Qejn4WNaT5eaoMe NlOYmvEv2sW5217Acan7JkOo0RDZPGQ++meZbkFFv90mbNf28zPBtdkHEhDYS30lNK1+ cL5q3dECE25xqeYjkmwQhg+YOMRORJq5kKA7/733Q2UTpk86vWFYzpOl2KfyyJc+kJYP 2jH5YeG5BSHHngpMW33/kzCXzMI5cqYPFEGVEHOkhDC6crAh+dvffxZXYibkYHrGmVZ6 SS0w== X-Gm-Message-State: ALoCoQlCQ0kg5i9KeZsGd2WgqS3+FkNihOmm+EcygM5G0UZFXJQdj7clh1/OyZbnhzLkCPEjHlqq X-Received: by 10.236.207.40 with SMTP id m28mr4301697yho.12.1416874652306; Mon, 24 Nov 2014 16:17:32 -0800 (PST) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id k66si512096yho.7.2014.11.24.16.17.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Nov 2014 16:17:32 -0800 (PST) Received: from abrestic.mtv.corp.google.com ([172.22.65.70]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTP id l3yvvzpK.1; Mon, 24 Nov 2014 16:17:32 -0800 Received: by abrestic.mtv.corp.google.com (Postfix, from userid 137652) id 2AE64220977; Mon, 24 Nov 2014 16:17:30 -0800 (PST) From: Andrew Bresticker To: Stephen Warren , Thierry Reding , Alexandre Courbot , linux-tegra@vger.kernel.org Subject: [PATCH V6 03/12] mailbox: Fix up error handling in mbox_request_channel() Date: Mon, 24 Nov 2014 16:17:15 -0800 Message-Id: <1416874644-12070-4-git-send-email-abrestic@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1416874644-12070-1-git-send-email-abrestic@chromium.org> References: <1416874644-12070-1-git-send-email-abrestic@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141124_161754_063699_D60B5655 X-CRM114-Status: GOOD ( 14.84 ) X-Spam-Score: -0.7 (/) Cc: Mark Rutland , devicetree@vger.kernel.org, linux-usb@vger.kernel.org, Mathias Nyman , Pawel Moll , Ian Campbell , Andrew Bresticker , Greg Kroah-Hartman , Linus Walleij , Jassi Brar , linux-kernel@vger.kernel.org, Felipe Balbi , Kishon Vijay Abraham I , Olof Johansson , Rob Herring , Alan Stern , linux-arm-kernel@lists.infradead.org, Kumar Gala , Grant Likely , Benson Leung , Arnd Bergmann 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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, 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 --- No changes from v5. New for v5. --- drivers/mailbox/mailbox.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index afcb430..955c0a7 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -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]; }