From nobody Tue Nov 11 13:36:58 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1561161407; cv=none; d=zoho.com; s=zohoarc; b=SX23sQkFGHY6YwMmAgZvPfuDT4FW88NQ9J+Oqpn3bDXK2iGG1PGB7XSf/01hU5aoaDf69dnl/716nicFUZLKnYAM6LZ0zJmH4PgC10oh43hfQWpuzjH7Wud/r4SPW5jLVanEH4fdNvf2OlmGEbZhm+QUIkVaR7ivV1eU7systw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561161407; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=fHdF9K4vWCF+kniiXZuxItpMjBplQ9lIiJrz2aR+2ro=; b=oThUxO9fDTDMfVeUNuv5gEsHx+xN6tpqkutnHMnac/LC5aw9foWH0NALWIu8guo7XSobLhRI45AgD9YWew2Rh+YVTF02AkZEWxA/fjfD3FWPYn9letqffMPA/M+CKEALdWh5cg8/5rfm2735174H7yUCDPNS/zgQ1n9VcdtRtMk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1561161407617505.21354062196633; Fri, 21 Jun 2019 16:56:47 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTO9-0004WO-RY; Fri, 21 Jun 2019 23:56:13 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTO8-0004V6-BZ for xen-devel@lists.xenproject.org; Fri, 21 Jun 2019 23:56:12 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 247e2e7d-9480-11e9-8980-bc764e045a96; Fri, 21 Jun 2019 23:56:10 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A0A29206B6; Fri, 21 Jun 2019 23:56:09 +0000 (UTC) X-Inumbo-ID: 247e2e7d-9480-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561161369; bh=kGs74uz4c0uoAwjFV0wL1k7xd0I+FLY1Eo1BEY4gNTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GBCDsBxKEkNiT35VCiO1UcIFmC5D/bs0khSuI57hwieLKlooqgNajjpN6kdFIxiEK 1cKIaOluFkQpjeT6s6qQqJueHLmPTwXaQUPLuSqqIWXcLCkY9pcDMgyaLv2bbB1eB7 StfMEk7Z3IxpQ8y/25DQfFlKy3zzc5yQTJuPvKYs= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Fri, 21 Jun 2019 16:56:03 -0700 Message-Id: <20190621235608.2153-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v3 1/6] 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add two new parameters to device_tree_for_each_node: node and depth. Node is the parent node to start the search from and depth is the min depth of the search (the depth of the parent node). Passing 0, 0 triggers the old behavior. We need this change because in follow-up patches we want to be able to use reuse device_tree_for_each_node to call a function for each children nodes of a provided node. Signed-off-by: Stefano Stabellini --- Changes in v3: - improve commit message - improve in-code comments - improve code style 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 9b29769a10..cfc85c2b61 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_flat= tened, - dt_scan_depth1_nodes, N= ULL))) + 0, 0, dt_scan_depth1_nodes, NULL))) goto disable; =20 /* diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 891b4b66ff..2f9cb8878d 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, in= t node, /** * device_tree_for_each_node - iterate over all device tree nodes * @fdt: flat device tree. + * @node: parent node to start the search from + * @depth: depth of the parent node * @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 =3D depth; =20 - for ( node =3D 0, depth =3D 0; - node >=3D0 && depth >=3D 0; + for ( ; node >=3D 0 && depth >=3D min_depth; node =3D fdt_next_node(fdt, node, &depth) ) { const char *name =3D fdt_get_name(fdt, node, NULL); @@ -357,7 +357,7 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t pa= ddr) =20 add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false); =20 - 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(); =20 return fdt_totalsize(fdt); diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 83156297e2..e1ec6cb88d 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; =20 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); =20 /** * dt_unflatten_host_device_tree - Unflatten the host device tree --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel