From patchwork Tue Oct 6 17:04:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 526836 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43AB9140D88 for ; Wed, 7 Oct 2015 04:05:53 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752887AbbJFRFi (ORCPT ); Tue, 6 Oct 2015 13:05:38 -0400 Received: from foss.arm.com ([217.140.101.70]:53540 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753478AbbJFREf (ORCPT ); Tue, 6 Oct 2015 13:04:35 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 244A759F; Tue, 6 Oct 2015 10:04:35 -0700 (PDT) Received: from approximate.cambridge.arm.com (approximate.cambridge.arm.com [10.1.209.125]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3DF703F487; Tue, 6 Oct 2015 10:04:33 -0700 (PDT) From: Marc Zyngier To: Rob Herring , Jason Cooper , Thomas Gleixner , Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, Mark Rutland , David Daney , Robin Murphy Subject: [PATCH v2 5/8] of/irq: Split of_msi_map_rid to reuse msi-map lookup Date: Tue, 6 Oct 2015 18:04:00 +0100 Message-Id: <1444151043-31084-6-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444151043-31084-1-git-send-email-marc.zyngier@arm.com> References: <1444151043-31084-1-git-send-email-marc.zyngier@arm.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The msi-map property is also used to identify the MSI controller as a form of grown-up msi-parent property. Looking it up is complicated enough, and since of_msi_map_rid already implements this, let's turn it into an internal utility function. We'll put that to good use later on. Signed-off-by: Marc Zyngier --- drivers/of/irq.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 89ebc61..ed64d98 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -579,21 +579,12 @@ err: } } -/** - * of_msi_map_rid - Map a MSI requester ID for a device. - * @dev: device for which the mapping is to be done. - * @msi_np: device node of the expected msi controller. - * @rid_in: unmapped MSI requester ID for the device. - * - * Walk up the device hierarchy looking for devices with a "msi-map" - * property. If found, apply the mapping to @rid_in. - * - * Returns the mapped MSI requester ID. - */ -u32 of_msi_map_rid(struct device *dev, struct device_node *msi_np, u32 rid_in) +static u32 __of_msi_map_rid(struct device *dev, struct device_node **np, + u32 rid_in) { struct device *parent_dev; struct device_node *msi_controller_node; + struct device_node *msi_np = *np; u32 map_mask, masked_rid, rid_base, msi_base, rid_len, phandle; int msi_map_len; bool matched; @@ -643,9 +634,15 @@ u32 of_msi_map_rid(struct device *dev, struct device_node *msi_np, u32 rid_in) msi_controller_node = of_find_node_by_phandle(phandle); - matched = masked_rid >= rid_base && - masked_rid < rid_base + rid_len && - msi_np == msi_controller_node; + matched = (masked_rid >= rid_base && + masked_rid < rid_base + rid_len); + if (msi_np) + matched &= msi_np == msi_controller_node; + + if (matched && !msi_np) { + *np = msi_np = msi_controller_node; + break; + } of_node_put(msi_controller_node); msi_map_len -= 4 * sizeof(__be32); @@ -663,6 +660,22 @@ u32 of_msi_map_rid(struct device *dev, struct device_node *msi_np, u32 rid_in) return rid_out; } +/** + * of_msi_map_rid - Map a MSI requester ID for a device. + * @dev: device for which the mapping is to be done. + * @msi_np: device node of the expected msi controller. + * @rid_in: unmapped MSI requester ID for the device. + * + * Walk up the device hierarchy looking for devices with a "msi-map" + * property. If found, apply the mapping to @rid_in. + * + * Returns the mapped MSI requester ID. + */ +u32 of_msi_map_rid(struct device *dev, struct device_node *msi_np, u32 rid_in) +{ + return __of_msi_map_rid(dev, &msi_np, rid_in); +} + static struct irq_domain *__of_get_msi_domain(struct device_node *np, enum irq_domain_bus_token token) {