aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of')
-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