aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/fdt.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2009-11-23 22:06:59 -0500
committerGrant Likely <grant.likely@secretlab.ca>2009-11-23 22:06:59 -0500
commitca900cfa2944448bdb76e1246f282e59bc65f472 (patch)
treeafddd9358f1772cc5467c3c012a0c3e998a3c8c7 /drivers/of/fdt.c
parent31a6a87dfc34fbf02aef9a160adf558ec56d3ccd (diff)
of/flattree: merge of_get_flat_dt_prop
Merge common code between PowerPC and Microblaze Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Reviewed-by: Wolfram Sang <w.sang@pengutronix.de> Tested-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'drivers/of/fdt.c')
-rw-r--r--drivers/of/fdt.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index f41d739aa2f7..b17a9086cbfc 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -99,3 +99,46 @@ unsigned long __init of_get_flat_dt_root(void)
99 return _ALIGN(p + strlen((char *)p) + 1, 4); 99 return _ALIGN(p + strlen((char *)p) + 1, 4);
100} 100}
101 101
102/**
103 * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr
104 *
105 * This function can be used within scan_flattened_dt callback to get
106 * access to properties
107 */
108void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
109 unsigned long *size)
110{
111 unsigned long p = node;
112
113 do {
114 u32 tag = *((u32 *)p);
115 u32 sz, noff;
116 const char *nstr;
117
118 p += 4;
119 if (tag == OF_DT_NOP)
120 continue;
121 if (tag != OF_DT_PROP)
122 return NULL;
123
124 sz = *((u32 *)p);
125 noff = *((u32 *)(p + 4));
126 p += 8;
127 if (initial_boot_params->version < 0x10)
128 p = _ALIGN(p, sz >= 8 ? 8 : 4);
129
130 nstr = find_flat_dt_string(noff);
131 if (nstr == NULL) {
132 pr_warning("Can't find property index name !\n");
133 return NULL;
134 }
135 if (strcmp(name, nstr) == 0) {
136 if (size)
137 *size = sz;
138 return (void *)p;
139 }
140 p += sz;
141 p = _ALIGN(p, 4);
142 } while (1);
143}
144