From patchwork Thu Nov 18 23:55:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Neuendorffer X-Patchwork-Id: 72176 X-Patchwork-Delegate: grant.likely@secretlab.ca Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 3D8C8B75ED for ; Fri, 19 Nov 2010 11:11:43 +1100 (EST) Received: from VA3EHSOBE001.bigfish.com (va3ehsobe001.messaging.microsoft.com [216.32.180.11]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "Cybertrust SureServer Standard Validation CA" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 667E3B730D for ; Fri, 19 Nov 2010 11:10:35 +1100 (EST) Received: from mail109-va3-R.bigfish.com (10.7.14.243) by VA3EHSOBE001.bigfish.com (10.7.40.21) with Microsoft SMTP Server id 14.1.225.8; Thu, 18 Nov 2010 23:55:20 +0000 Received: from mail109-va3 (localhost.localdomain [127.0.0.1]) by mail109-va3-R.bigfish.com (Postfix) with ESMTP id 0AB0D17103A2; Thu, 18 Nov 2010 23:52:17 +0000 (UTC) X-SpamScore: 0 X-BigFish: VPS0(zzzz1202hzz8275bhz2dh95h668h67dh685h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:xsj-gw1; RD:unknown-60-83.xilinx.com; EFVD:NLI Received: from mail109-va3 (localhost.localdomain [127.0.0.1]) by mail109-va3 (MessageSwitch) id 1290124336686271_16531; Thu, 18 Nov 2010 23:52:16 +0000 (UTC) Received: from VA3EHSMHS013.bigfish.com (unknown [10.7.14.245]) by mail109-va3.bigfish.com (Postfix) with ESMTP id A0C7F40004F; Thu, 18 Nov 2010 23:52:16 +0000 (UTC) Received: from xsj-gw1 (149.199.60.83) by VA3EHSMHS013.bigfish.com (10.7.99.23) with Microsoft SMTP Server id 14.1.225.8; Thu, 18 Nov 2010 23:55:12 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-smtp1.xilinx.com) by xsj-gw1 with esmtp (Exim 4.63) (envelope-from ) id 1PJEJs-0001LM-1W; Thu, 18 Nov 2010 15:55:12 -0800 From: Stephen Neuendorffer To: , , , , Subject: [PATCH 5/7] fdt.c: Refactor unflatten_dt_node Date: Thu, 18 Nov 2010 15:55:00 -0800 X-Mailer: git-send-email 1.5.6.6 In-Reply-To: <1290124502-13125-5-git-send-email-stephen.neuendorffer@xilinx.com> References: <1290021345-4303-1-git-send-email-stephen.neuendorffer@xilinx.com> <1290124502-13125-1-git-send-email-stephen.neuendorffer@xilinx.com> <1290124502-13125-2-git-send-email-stephen.neuendorffer@xilinx.com> <1290124502-13125-3-git-send-email-stephen.neuendorffer@xilinx.com> <1290124502-13125-4-git-send-email-stephen.neuendorffer@xilinx.com> <1290124502-13125-5-git-send-email-stephen.neuendorffer@xilinx.com> MIME-Version: 1.0 Message-ID: X-OriginatorOrg: xilinx.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org unflatten_dt_node is a helper function that does most of the work to convert a device tree blob into tree of device nodes. This code now uses a passed-in blob instead of using the single boot-time blob, allowing it to be called in more contexts. Signed-off-by: Stephen Neuendorffer --- V2: don't reorder blob argument first. --- drivers/of/fdt.c | 27 ++++++++++++++++----------- 1 files changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 190e26c..a07fd1a 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -206,7 +206,7 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) return of_fdt_is_compatible(initial_boot_params, node, compat); } -static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size, +static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size, unsigned long align) { void *res; @@ -220,16 +220,18 @@ static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size, /** * unflatten_dt_node - Alloc and populate a device_node from the flat tree + * @blob: The parent device tree blob * @p: pointer to node in flat tree * @dad: Parent struct device_node * @allnextpp: pointer to ->allnext from last allocated device_node * @fpsize: Size of the node path up at the current depth. */ -unsigned long __init unflatten_dt_node(unsigned long mem, - unsigned long *p, - struct device_node *dad, - struct device_node ***allnextpp, - unsigned long fpsize) +unsigned long unflatten_dt_node(struct boot_param_header *blob, + unsigned long mem, + unsigned long *p, + struct device_node *dad, + struct device_node ***allnextpp, + unsigned long fpsize) { struct device_node *np; struct property *pp, **prev_pp = NULL; @@ -325,10 +327,10 @@ unsigned long __init unflatten_dt_node(unsigned long mem, sz = be32_to_cpup((__be32 *)(*p)); noff = be32_to_cpup((__be32 *)((*p) + 4)); *p += 8; - if (be32_to_cpu(initial_boot_params->version) < 0x10) + if (be32_to_cpu(blob->version) < 0x10) *p = ALIGN(*p, sz >= 8 ? 8 : 4); - pname = of_fdt_get_string(initial_boot_params, noff); + pname = of_fdt_get_string(blob, noff); if (pname == NULL) { pr_info("Can't find property name in list !\n"); break; @@ -407,7 +409,8 @@ unsigned long __init unflatten_dt_node(unsigned long mem, if (tag == OF_DT_NOP) *p += 4; else - mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize); + mem = unflatten_dt_node(blob, mem, p, np, allnextpp, + fpsize); tag = be32_to_cpup((__be32 *)(*p)); } if (tag != OF_DT_END_NODE) { @@ -599,7 +602,8 @@ void __init unflatten_device_tree(void) /* First pass, scan for size */ start = ((unsigned long)initial_boot_params) + be32_to_cpu(initial_boot_params->off_dt_struct); - size = unflatten_dt_node(0, &start, NULL, NULL, 0); + size = unflatten_dt_node(initial_boot_params, 0, &start, + NULL, NULL, 0); size = (size | 3) + 1; pr_debug(" size is %lx, allocating...\n", size); @@ -616,7 +620,8 @@ void __init unflatten_device_tree(void) /* Second pass, do actual unflattening */ start = ((unsigned long)initial_boot_params) + be32_to_cpu(initial_boot_params->off_dt_struct); - unflatten_dt_node(mem, &start, NULL, &allnextp, 0); + unflatten_dt_node(initial_boot_params, mem, &start, + NULL, &allnextp, 0); if (be32_to_cpup((__be32 *)start) != OF_DT_END) pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start)); if (be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef)