From patchwork Thu Nov 5 07:46:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 37737 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id DE215B7B96 for ; Thu, 5 Nov 2009 18:46:17 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754741AbZKEHqL (ORCPT ); Thu, 5 Nov 2009 02:46:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754967AbZKEHqL (ORCPT ); Thu, 5 Nov 2009 02:46:11 -0500 Received: from mail-pw0-f42.google.com ([209.85.160.42]:59266 "EHLO mail-pw0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754741AbZKEHqK (ORCPT ); Thu, 5 Nov 2009 02:46:10 -0500 Received: by mail-pw0-f42.google.com with SMTP id 9so3727900pwj.21 for ; Wed, 04 Nov 2009 23:46:16 -0800 (PST) Received: by 10.115.135.23 with SMTP id m23mr4394018wan.136.1257407175913; Wed, 04 Nov 2009 23:46:15 -0800 (PST) Received: from angua (S01060002b3d79728.cg.shawcable.net [68.146.87.181]) by mx.google.com with ESMTPS id 23sm1070838pzk.0.2009.11.04.23.46.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 04 Nov 2009 23:46:15 -0800 (PST) Received: from [127.0.1.1] (unknown [IPv6:::1]) by angua (Postfix) with ESMTP id 86DD411ED0; Thu, 5 Nov 2009 00:46:13 -0700 (MST) From: Grant Likely Subject: [PATCH 05/11] of/flattree: merge of_get_flat_dt_prop To: linuxppc-dev@lists.ozlabs.org, devicetree-discuss@lists.ozlabs.org, benh@kernel.crashing.org, sfr@canb.auug.org.au, davem@davemloft.net, sparclinux@vger.kernel.org, monstr@monstr.eu, microblaze-uclinux@itee.uq.edu.au Date: Thu, 05 Nov 2009 00:46:13 -0700 Message-ID: <20091105074606.10460.23775.stgit@angua> In-Reply-To: <20091105073728.10460.6061.stgit@angua> References: <20091105073728.10460.6061.stgit@angua> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org Merge common code between PowerPC and Microblaze Signed-off-by: Grant Likely --- arch/microblaze/kernel/prom.c | 42 ---------------------------------------- arch/powerpc/kernel/prom.c | 42 ---------------------------------------- drivers/of/fdt.c | 43 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 84 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c index 7eb6f8b..d75c625 100644 --- a/arch/microblaze/kernel/prom.c +++ b/arch/microblaze/kernel/prom.c @@ -50,48 +50,6 @@ typedef u32 cell_t; /* export that to outside world */ struct device_node *of_chosen; -/** - * This function can be used within scan_flattened_dt callback to get - * access to properties - */ -void *__init of_get_flat_dt_prop(unsigned long node, const char *name, - unsigned long *size) -{ - unsigned long p = node; - - do { - u32 tag = *((u32 *)p); - u32 sz, noff; - const char *nstr; - - p += 4; - if (tag == OF_DT_NOP) - continue; - if (tag != OF_DT_PROP) - return NULL; - - sz = *((u32 *)p); - noff = *((u32 *)(p + 4)); - p += 8; - if (initial_boot_params->version < 0x10) - p = _ALIGN(p, sz >= 8 ? 8 : 4); - - nstr = find_flat_dt_string(noff); - if (nstr == NULL) { - printk(KERN_WARNING "Can't find property index" - " name !\n"); - return NULL; - } - if (strcmp(name, nstr) == 0) { - if (size) - *size = sz; - return (void *)p; - } - p += sz; - p = _ALIGN(p, 4); - } while (1); -} - int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) { const char *cp; diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index b5d5f85..cd0a2bf 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -80,48 +80,6 @@ extern rwlock_t devtree_lock; /* temporary while merging */ /* export that to outside world */ struct device_node *of_chosen; -/** - * This function can be used within scan_flattened_dt callback to get - * access to properties - */ -void* __init of_get_flat_dt_prop(unsigned long node, const char *name, - unsigned long *size) -{ - unsigned long p = node; - - do { - u32 tag = *((u32 *)p); - u32 sz, noff; - const char *nstr; - - p += 4; - if (tag == OF_DT_NOP) - continue; - if (tag != OF_DT_PROP) - return NULL; - - sz = *((u32 *)p); - noff = *((u32 *)(p + 4)); - p += 8; - if (initial_boot_params->version < 0x10) - p = _ALIGN(p, sz >= 8 ? 8 : 4); - - nstr = find_flat_dt_string(noff); - if (nstr == NULL) { - printk(KERN_WARNING "Can't find property index" - " name !\n"); - return NULL; - } - if (strcmp(name, nstr) == 0) { - if (size) - *size = sz; - return (void *)p; - } - p += sz; - p = _ALIGN(p, 4); - } while(1); -} - int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) { const char* cp; diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index a6e869e..7a51343 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -100,3 +100,46 @@ unsigned long __init of_get_flat_dt_root(void) return _ALIGN(p + strlen((char *)p) + 1, 4); } +/** + * of_get_flat_dt_prop - Given a node in the flat blob, return the property pointer + * + * This function can be used within scan_flattened_dt callback to get + * access to properties + */ +void *__init of_get_flat_dt_prop(unsigned long node, const char *name, + unsigned long *size) +{ + unsigned long p = node; + + do { + u32 tag = *((u32 *)p); + u32 sz, noff; + const char *nstr; + + p += 4; + if (tag == OF_DT_NOP) + continue; + if (tag != OF_DT_PROP) + return NULL; + + sz = *((u32 *)p); + noff = *((u32 *)(p + 4)); + p += 8; + if (initial_boot_params->version < 0x10) + p = _ALIGN(p, sz >= 8 ? 8 : 4); + + nstr = find_flat_dt_string(noff); + if (nstr == NULL) { + pr_warning("Can't find property index name !\n"); + return NULL; + } + if (strcmp(name, nstr) == 0) { + if (size) + *size = sz; + return (void *)p; + } + p += sz; + p = _ALIGN(p, 4); + } while (1); +} +