From patchwork Fri May 20 06:32:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 624319 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r9yns5Zprz9t6B for ; Fri, 20 May 2016 16:34:09 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3r9yns4rf3zDqFh for ; Fri, 20 May 2016 16:34:09 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) (using TLSv1.2 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3r9yn86T37zDqBZ for ; Fri, 20 May 2016 16:33:32 +1000 (AEST) Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 May 2016 16:33:32 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 May 2016 16:33:30 +1000 X-IBM-Helo: d23dlp02.au.ibm.com X-IBM-MailFrom: gwshan@linux.vnet.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 50E252BB0054 for ; Fri, 20 May 2016 16:33:28 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u4K6XKiV786940 for ; Fri, 20 May 2016 16:33:28 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u4K6Wtrw014566 for ; Fri, 20 May 2016 16:32:55 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u4K6WtjU013842; Fri, 20 May 2016 16:32:55 +1000 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 7D301A038F; Fri, 20 May 2016 16:32:30 +1000 (AEST) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id 7B76CE3A8C; Fri, 20 May 2016 16:32:30 +1000 (AEST) Received: by gwshan (Postfix, from userid 1000) id 558EF942543; Fri, 20 May 2016 16:32:30 +1000 (AEST) From: Gavin Shan To: skiboot@lists.ozlabs.org Date: Fri, 20 May 2016 16:32:05 +1000 Message-Id: <1463725945-12916-4-git-send-email-gwshan@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1463725945-12916-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1463725945-12916-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16052006-0021-0000-0000-000009B279D3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused Subject: [Skiboot] [PATCH v11 03/23] core/fdt: Introduce flatten_dt_properties() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair@popple.id.au MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" We need unflatten the child nodes of the specified one during PCI hot add time. After it, the FDT blob is transferred to kernel and unflattened there. A device sub-tree is represented by the FDT blob and it excludes the specified (root) node. This introduces helper function flatten_dt_properties() to flatten the properties of the specified node. In the path to create the device sub-tree, the root's properties is skipped in subsequent patch. In the mean time, the node tag is created in flatten_dt_node() so that the function is self-contained. No functional changes introduced. Signed-off-by: Gavin Shan --- core/fdt.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/core/fdt.c b/core/fdt.c index 721c35d..652d0f4 100644 --- a/core/fdt.c +++ b/core/fdt.c @@ -118,25 +118,30 @@ static void dump_fdt(void) static inline void dump_fdt(void) { } #endif -static void flatten_dt_node(const struct dt_node *root) +static void flatten_dt_properties(const struct dt_node *dn) { - const struct dt_node *i; const struct dt_property *p; - FDT_DBG("FDT: node: %s\n", root->name); - list_for_each(&root->properties, p, list) { + list_for_each(&dn->properties, p, list) { if (strstarts(p->name, DT_PRIVATE)) continue; FDT_DBG("FDT: prop: %s size: %ld\n", p->name, p->len); dt_property(p); } +} - list_for_each(&root->children, i, list) { - dt_begin_node(i); +static void flatten_dt_node(const struct dt_node *root) +{ + const struct dt_node *i; + + FDT_DBG("FDT: node: %s\n", root->name); + dt_begin_node(root); + flatten_dt_properties(root); + list_for_each(&root->children, i, list) flatten_dt_node(i); - dt_end_node(); - } + + dt_end_node(); } static void create_dtb_reservemap(const struct dt_node *root) @@ -181,15 +186,9 @@ void *create_dtb(const struct dt_node *root) create_dtb_reservemap(root); - /* Open root node */ - dt_begin_node(root); - /* Unflatten our live tree */ flatten_dt_node(root); - /* Close root node */ - dt_end_node(); - save_err(fdt_finish(fdt)); if (!fdt_error)