From patchwork Tue Apr 30 21:02:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 10924199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 493EE912 for ; Tue, 30 Apr 2019 21:08:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ADE928A03 for ; Tue, 30 Apr 2019 21:08:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2ECD328A33; Tue, 30 Apr 2019 21:08:17 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BABC028A03 for ; Tue, 30 Apr 2019 21:08:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZxs-0000MI-OT; Tue, 30 Apr 2019 21:07:00 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZxr-0000MB-S2 for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:06:59 +0000 X-Inumbo-ID: 54c6d320-6b8b-11e9-87ac-1fc2ba82c803 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 54c6d320-6b8b-11e9-87ac-1fc2ba82c803; Tue, 30 Apr 2019 21:02:58 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6A80D217D6; Tue, 30 Apr 2019 21:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658177; bh=mDmgj+zPtn+AKbS1JChR6ZLHxHQ50ygJNrJz20vO0xg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G1zVapUaz3Gcdm8KW4Ra9Oi5o7mb+biWzQbiNRaGneGWmdpjVpKK6VRwog6VqK91e qP45ApnVMnANuYI1dnpz7o/9xVbgpWBRYBndf5ET6AI+KJ6y6noUK6bAHevXnZOY6Z MG0ysSfZVcCVraZWa0+HKKpNcFnjpvjsj0w2dac4= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:48 -0700 Message-Id: <1556658172-8824-6-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 06/10] xen/arm: extend device_tree_for_each_node X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add two new paramters to device_tree_for_each_node: node and depth. Node is the node to start the search from and depth is the min depth of the search. Passing 0, 0 triggers the old behavior. Signed-off-by: Stefano Stabellini --- Changes in v2: - new --- xen/arch/arm/acpi/boot.c | 2 +- xen/arch/arm/bootfdt.c | 12 ++++++------ xen/include/xen/device_tree.h | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index 9b29769..cfc85c2 100644 --- a/xen/arch/arm/acpi/boot.c +++ b/xen/arch/arm/acpi/boot.c @@ -248,7 +248,7 @@ int __init acpi_boot_table_init(void) */ if ( param_acpi_off || ( !param_acpi_force && device_tree_for_each_node(device_tree_flattened, - dt_scan_depth1_nodes, NULL))) + 0, 0, dt_scan_depth1_nodes, NULL))) goto disable; /* diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 891b4b6..e7b08ed 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -77,6 +77,8 @@ static u32 __init device_tree_get_u32(const void *fdt, int node, /** * device_tree_for_each_node - iterate over all device tree nodes * @fdt: flat device tree. + * @node: node to start the search from + * @depth: min depth of the search * @func: function to call for each node. * @data: data to pass to @func. * @@ -86,17 +88,15 @@ static u32 __init device_tree_get_u32(const void *fdt, int node, * returns a value different from 0, that value is returned immediately. */ int __init device_tree_for_each_node(const void *fdt, + int node, int depth, device_tree_node_func func, void *data) { - int node; - int depth; u32 address_cells[DEVICE_TREE_MAX_DEPTH]; u32 size_cells[DEVICE_TREE_MAX_DEPTH]; - int ret; + int ret, min_depth = depth; - for ( node = 0, depth = 0; - node >=0 && depth >= 0; + for ( ; node >=0 && depth >= min_depth; node = fdt_next_node(fdt, node, &depth) ) { const char *name = fdt_get_name(fdt, node, NULL); @@ -357,7 +357,7 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t paddr) add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false); - device_tree_for_each_node((void *)fdt, early_scan_node, NULL); + device_tree_for_each_node((void *)fdt, 0, 0, early_scan_node, NULL); early_print_info(); return fdt_totalsize(fdt); diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 7408a6c..4ff78ba 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -159,8 +159,9 @@ typedef int (*device_tree_node_func)(const void *fdt, extern const void *device_tree_flattened; int device_tree_for_each_node(const void *fdt, - device_tree_node_func func, - void *data); + int node, int depth, + device_tree_node_func func, + void *data); /** * dt_unflatten_host_device_tree - Unflatten the host device tree