From patchwork Tue May 16 12:09:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 9729003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 25B0060386 for ; Tue, 16 May 2017 12:09:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17E0628A0D for ; Tue, 16 May 2017 12:09:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C98028A1D; Tue, 16 May 2017 12:09:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8880F28A0D for ; Tue, 16 May 2017 12:09:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=BVamCJaM+k5InfWU8XVJvUvNiopLNC6L7TkN1y59x6o=; b=j4y F9EGhtvbWgOgWp1aFkMhSIET0eu6jE5rbQNlgYbyEfupwWTAj4cU2WIiy7PtuJ3MlpK3IvYfbbzeG CZFyBFmSQdFcXJgte23vpf4KnRaTZGJWoecj2yyCQ0/ctyrmOQomVv4cDC5INkplNZewz/ZCEP4yO 2E9O87tTnoFaoT8qEIKeuzdXS1+Wr3Gl3kb53gr7HrziHK0iA7lZMpOk/TfpuZrvsxMK13D/Nryde ZY3SuZ8DZgvKuGd044XtqNUdUW6fAaOKbEsQzRO+iDsSYG6Gfhvdl4VTJ/LXzzytFUohbEv+Poa/L 2oT0Gk+8GsLuHZMKEIkmY8h5OuhCLxA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dAbIG-0005AI-Vg; Tue, 16 May 2017 12:09:36 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dAbI6-00056f-A3 for linux-arm-kernel@lists.infradead.org; Tue, 16 May 2017 12:09:34 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id CFCB32081C; Tue, 16 May 2017 14:09:04 +0200 (CEST) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id A7FAA20819; Tue, 16 May 2017 14:09:04 +0200 (CEST) From: Thomas Petazzoni To: Rob Herring , Frank Rowand Subject: [PATCH] of: irq: use of_irq_get() in of_irq_to_resource() Date: Tue, 16 May 2017 14:09:04 +0200 Message-Id: <1494936544-27541-1-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170516_050926_560900_D3A54829 X-CRM114-Status: GOOD ( 12.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gregory Clement , devicetree@vger.kernel.org, Thomas Petazzoni , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP of_irq_to_resource() currently uses irq_of_parse_and_map() to translate a DT interrupt specification into a Linux virtual interrupt number. While this works in most cases, irq_of_parse_and_map() doesn't properly handle the case where the interrupt controller is not yet available (due to deferred probing for example). So instead, use of_irq_get(), which is implemented exactly like irq_of_parse_and_map(), with the exception that if the interrupt controller is not yet available, it returns -EPROBE_DEFER. Obviously, we also handle this error and bail out from of_irq_to_resource() when of_irq_get() returns an error. This allows to avoid silly error messages at boot time caused by irq_create_of_mapping() when the interrupt controller is not available: [ 0.153168] irq: no irq domain found for /ap806/config-space@f0000000/interrupt-controller@3f0100 ! [ 0.154041] irq: no irq domain found for /cp110-master/config-space@f2000000/interrupt-controller@1e0000 ! [ 0.154124] irq: no irq domain found for /cp110-master/config-space@f2000000/interrupt-controller@1e0000 ! [ 0.154207] irq: no irq domain found for /cp110-master/config-space@f2000000/interrupt-controller@1e0000 ! [ 0.154437] irq: no irq domain found for /cp110-master/config-space@f2000000/interrupt-controller@1e0000 ! [ 0.154518] irq: no irq domain found for /cp110-master/config-space@f2000000/interrupt-controller@1e0000 ! Signed-off-by: Thomas Petazzoni --- drivers/of/irq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 7c56b72..47b3614 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -369,7 +369,10 @@ EXPORT_SYMBOL_GPL(of_irq_parse_one); */ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) { - int irq = irq_of_parse_and_map(dev, index); + int irq = of_irq_get(dev, index); + + if (irq < 0) + return irq; /* Only dereference the resource if both the * resource and the irq are valid. */