From patchwork Fri Jun 10 05:03:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 633521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rQqtg38wmz9sD3 for ; Fri, 10 Jun 2016 15:07:55 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rQqtg20WtzDqQW for ; Fri, 10 Jun 2016 15:07:55 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3rQqrP604XzDqNj for ; Fri, 10 Jun 2016 15:05:57 +1000 (AEST) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5A53oZp034281 for ; Fri, 10 Jun 2016 01:05:55 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0a-001b2d01.pphosted.com with ESMTP id 23fm5y30hs-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Jun 2016 01:05:55 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Jun 2016 15:05:53 +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, 10 Jun 2016 15:05:52 +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 d23relay08.au.ibm.com (d23relay08.au.ibm.com [9.185.71.33]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 7AC762BB0059 for ; Fri, 10 Jun 2016 15:05:46 +1000 (EST) Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5A55fte7406032 for ; Fri, 10 Jun 2016 15:05:41 +1000 Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u5A55eMk026131 for ; Fri, 10 Jun 2016 15:05:41 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u5A55e1D026025; Fri, 10 Jun 2016 15:05:40 +1000 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 002CFA03A0; Fri, 10 Jun 2016 15:04:01 +1000 (AEST) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id BAA0FE3B19; Fri, 10 Jun 2016 15:03:55 +1000 (AEST) Received: by gwshan (Postfix, from userid 1000) id 9EB62942CA3; Fri, 10 Jun 2016 15:03:55 +1000 (AEST) From: Gavin Shan To: skiboot@lists.ozlabs.org Date: Fri, 10 Jun 2016 15:03:32 +1000 X-Mailer: git-send-email 2.1.0 In-Reply-To: <1465535032-26749-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1465535032-26749-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16061005-0040-0000-0000-000001B049F2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16061005-0041-0000-0000-000009D76D3C Message-Id: <1465535032-26749-4-git-send-email-gwshan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-10_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606100058 Subject: [Skiboot] [PATCH v12 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 4ef470d..a934e08 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("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(" 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("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)