aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-10 16:53:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-10 16:53:52 -0400
commit31f7c3a688f75bceaf2fd009efc489659ad6aa61 (patch)
tree1721765e553c01559d1b784563d4840c5d3dd0b9 /drivers
parentec5b103ecfde929004b691f29183255aeeadecd5 (diff)
parent2bc552df76d83cf1455ac8cf4c87615bfd15df74 (diff)
Merge tag 'devicetree-for-linus' of git://git.secretlab.ca/git/linux
Pull device tree core updates from Grant Likely: "Generally minor changes. A bunch of bug fixes, particularly for initialization and some refactoring. Most notable change if feeding the entire flattened tree into the random pool at boot. May not be significant, but shouldn't hurt either" Tim Bird questions whether the boot time cost of the random feeding may be noticeable. And "add_device_randomness()" is definitely not some speed deamon of a function. * tag 'devicetree-for-linus' of git://git.secretlab.ca/git/linux: of/platform: add error reporting to of_amba_device_create() irq/of: Fix comment typo for irq_of_parse_and_map of: Feed entire flattened device tree into the random pool of/fdt: Clean up casting in unflattening path of/fdt: Remove duplicate memory clearing on FDT unflattening gpio: implement gpio-ranges binding document fix of: call __of_parse_phandle_with_args from of_parse_phandle of: introduce of_parse_phandle_with_fixed_args of: move of_parse_phandle() of: move documentation of of_parse_phandle_with_args of: Fix missing memory initialization on FDT unflattening of: consolidate definition of early_init_dt_alloc_memory_arch() of: Make of_get_phy_mode() return int i.s.o. const int include: dt-binding: input: create a DT header defining key codes. of/platform: Staticize of_platform_device_create_pdata() of: Specify initrd location using 64-bit dt: Typo fix OF: make of_property_for_each_{u32|string}() use parameters if OF is not enabled
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpiolib-of.c4
-rw-r--r--drivers/of/base.c200
-rw-r--r--drivers/of/fdt.c98
-rw-r--r--drivers/of/irq.c2
-rw-r--r--drivers/of/of_net.c2
-rw-r--r--drivers/of/platform.c21
6 files changed, 211 insertions, 116 deletions
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index ba9876ffb017..0dfaf20e4dad 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -195,8 +195,8 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
195 return; 195 return;
196 196
197 for (;; index++) { 197 for (;; index++) {
198 ret = of_parse_phandle_with_args(np, "gpio-ranges", 198 ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
199 "#gpio-range-cells", index, &pinspec); 199 index, &pinspec);
200 if (ret) 200 if (ret)
201 break; 201 break;
202 202
diff --git a/drivers/of/base.c b/drivers/of/base.c
index e486e416d5a0..865d3f66c86b 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1176,65 +1176,10 @@ int of_property_count_strings(struct device_node *np, const char *propname)
1176} 1176}
1177EXPORT_SYMBOL_GPL(of_property_count_strings); 1177EXPORT_SYMBOL_GPL(of_property_count_strings);
1178 1178
1179/**
1180 * of_parse_phandle - Resolve a phandle property to a device_node pointer
1181 * @np: Pointer to device node holding phandle property
1182 * @phandle_name: Name of property holding a phandle value
1183 * @index: For properties holding a table of phandles, this is the index into
1184 * the table
1185 *
1186 * Returns the device_node pointer with refcount incremented. Use
1187 * of_node_put() on it when done.
1188 */
1189struct device_node *of_parse_phandle(const struct device_node *np,
1190 const char *phandle_name, int index)
1191{
1192 const __be32 *phandle;
1193 int size;
1194
1195 phandle = of_get_property(np, phandle_name, &size);
1196 if ((!phandle) || (size < sizeof(*phandle) * (index + 1)))
1197 return NULL;
1198
1199 return of_find_node_by_phandle(be32_to_cpup(phandle + index));
1200}
1201EXPORT_SYMBOL(of_parse_phandle);
1202
1203/**
1204 * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
1205 * @np: pointer to a device tree node containing a list
1206 * @list_name: property name that contains a list
1207 * @cells_name: property name that specifies phandles' arguments count
1208 * @index: index of a phandle to parse out
1209 * @out_args: optional pointer to output arguments structure (will be filled)
1210 *
1211 * This function is useful to parse lists of phandles and their arguments.
1212 * Returns 0 on success and fills out_args, on error returns appropriate
1213 * errno value.
1214 *
1215 * Caller is responsible to call of_node_put() on the returned out_args->node
1216 * pointer.
1217 *
1218 * Example:
1219 *
1220 * phandle1: node1 {
1221 * #list-cells = <2>;
1222 * }
1223 *
1224 * phandle2: node2 {
1225 * #list-cells = <1>;
1226 * }
1227 *
1228 * node3 {
1229 * list = <&phandle1 1 2 &phandle2 3>;
1230 * }
1231 *
1232 * To get a device_node of the `node2' node you may call this:
1233 * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
1234 */
1235static int __of_parse_phandle_with_args(const struct device_node *np, 1179static int __of_parse_phandle_with_args(const struct device_node *np,
1236 const char *list_name, 1180 const char *list_name,
1237 const char *cells_name, int index, 1181 const char *cells_name,
1182 int cell_count, int index,
1238 struct of_phandle_args *out_args) 1183 struct of_phandle_args *out_args)
1239{ 1184{
1240 const __be32 *list, *list_end; 1185 const __be32 *list, *list_end;
@@ -1262,19 +1207,32 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
1262 if (phandle) { 1207 if (phandle) {
1263 /* 1208 /*
1264 * Find the provider node and parse the #*-cells 1209 * Find the provider node and parse the #*-cells
1265 * property to determine the argument length 1210 * property to determine the argument length.
1211 *
1212 * This is not needed if the cell count is hard-coded
1213 * (i.e. cells_name not set, but cell_count is set),
1214 * except when we're going to return the found node
1215 * below.
1266 */ 1216 */
1267 node = of_find_node_by_phandle(phandle); 1217 if (cells_name || cur_index == index) {
1268 if (!node) { 1218 node = of_find_node_by_phandle(phandle);
1269 pr_err("%s: could not find phandle\n", 1219 if (!node) {
1270 np->full_name); 1220 pr_err("%s: could not find phandle\n",
1271 goto err; 1221 np->full_name);
1222 goto err;
1223 }
1272 } 1224 }
1273 if (of_property_read_u32(node, cells_name, &count)) { 1225
1274 pr_err("%s: could not get %s for %s\n", 1226 if (cells_name) {
1275 np->full_name, cells_name, 1227 if (of_property_read_u32(node, cells_name,
1276 node->full_name); 1228 &count)) {
1277 goto err; 1229 pr_err("%s: could not get %s for %s\n",
1230 np->full_name, cells_name,
1231 node->full_name);
1232 goto err;
1233 }
1234 } else {
1235 count = cell_count;
1278 } 1236 }
1279 1237
1280 /* 1238 /*
@@ -1334,17 +1292,117 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
1334 return rc; 1292 return rc;
1335} 1293}
1336 1294
1295/**
1296 * of_parse_phandle - Resolve a phandle property to a device_node pointer
1297 * @np: Pointer to device node holding phandle property
1298 * @phandle_name: Name of property holding a phandle value
1299 * @index: For properties holding a table of phandles, this is the index into
1300 * the table
1301 *
1302 * Returns the device_node pointer with refcount incremented. Use
1303 * of_node_put() on it when done.
1304 */
1305struct device_node *of_parse_phandle(const struct device_node *np,
1306 const char *phandle_name, int index)
1307{
1308 struct of_phandle_args args;
1309
1310 if (index < 0)
1311 return NULL;
1312
1313 if (__of_parse_phandle_with_args(np, phandle_name, NULL, 0,
1314 index, &args))
1315 return NULL;
1316
1317 return args.np;
1318}
1319EXPORT_SYMBOL(of_parse_phandle);
1320
1321/**
1322 * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
1323 * @np: pointer to a device tree node containing a list
1324 * @list_name: property name that contains a list
1325 * @cells_name: property name that specifies phandles' arguments count
1326 * @index: index of a phandle to parse out
1327 * @out_args: optional pointer to output arguments structure (will be filled)
1328 *
1329 * This function is useful to parse lists of phandles and their arguments.
1330 * Returns 0 on success and fills out_args, on error returns appropriate
1331 * errno value.
1332 *
1333 * Caller is responsible to call of_node_put() on the returned out_args->node
1334 * pointer.
1335 *
1336 * Example:
1337 *
1338 * phandle1: node1 {
1339 * #list-cells = <2>;
1340 * }
1341 *
1342 * phandle2: node2 {
1343 * #list-cells = <1>;
1344 * }
1345 *
1346 * node3 {
1347 * list = <&phandle1 1 2 &phandle2 3>;
1348 * }
1349 *
1350 * To get a device_node of the `node2' node you may call this:
1351 * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
1352 */
1337int of_parse_phandle_with_args(const struct device_node *np, const char *list_name, 1353int of_parse_phandle_with_args(const struct device_node *np, const char *list_name,
1338 const char *cells_name, int index, 1354 const char *cells_name, int index,
1339 struct of_phandle_args *out_args) 1355 struct of_phandle_args *out_args)
1340{ 1356{
1341 if (index < 0) 1357 if (index < 0)
1342 return -EINVAL; 1358 return -EINVAL;
1343 return __of_parse_phandle_with_args(np, list_name, cells_name, index, out_args); 1359 return __of_parse_phandle_with_args(np, list_name, cells_name, 0,
1360 index, out_args);
1344} 1361}
1345EXPORT_SYMBOL(of_parse_phandle_with_args); 1362EXPORT_SYMBOL(of_parse_phandle_with_args);
1346 1363
1347/** 1364/**
1365 * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
1366 * @np: pointer to a device tree node containing a list
1367 * @list_name: property name that contains a list
1368 * @cell_count: number of argument cells following the phandle
1369 * @index: index of a phandle to parse out
1370 * @out_args: optional pointer to output arguments structure (will be filled)
1371 *
1372 * This function is useful to parse lists of phandles and their arguments.
1373 * Returns 0 on success and fills out_args, on error returns appropriate
1374 * errno value.
1375 *
1376 * Caller is responsible to call of_node_put() on the returned out_args->node
1377 * pointer.
1378 *
1379 * Example:
1380 *
1381 * phandle1: node1 {
1382 * }
1383 *
1384 * phandle2: node2 {
1385 * }
1386 *
1387 * node3 {
1388 * list = <&phandle1 0 2 &phandle2 2 3>;
1389 * }
1390 *
1391 * To get a device_node of the `node2' node you may call this:
1392 * of_parse_phandle_with_fixed_args(node3, "list", 2, 1, &args);
1393 */
1394int of_parse_phandle_with_fixed_args(const struct device_node *np,
1395 const char *list_name, int cell_count,
1396 int index, struct of_phandle_args *out_args)
1397{
1398 if (index < 0)
1399 return -EINVAL;
1400 return __of_parse_phandle_with_args(np, list_name, NULL, cell_count,
1401 index, out_args);
1402}
1403EXPORT_SYMBOL(of_parse_phandle_with_fixed_args);
1404
1405/**
1348 * of_count_phandle_with_args() - Find the number of phandles references in a property 1406 * of_count_phandle_with_args() - Find the number of phandles references in a property
1349 * @np: pointer to a device tree node containing a list 1407 * @np: pointer to a device tree node containing a list
1350 * @list_name: property name that contains a list 1408 * @list_name: property name that contains a list
@@ -1362,7 +1420,8 @@ EXPORT_SYMBOL(of_parse_phandle_with_args);
1362int of_count_phandle_with_args(const struct device_node *np, const char *list_name, 1420int of_count_phandle_with_args(const struct device_node *np, const char *list_name,
1363 const char *cells_name) 1421 const char *cells_name)
1364{ 1422{
1365 return __of_parse_phandle_with_args(np, list_name, cells_name, -1, NULL); 1423 return __of_parse_phandle_with_args(np, list_name, cells_name, 0, -1,
1424 NULL);
1366} 1425}
1367EXPORT_SYMBOL(of_count_phandle_with_args); 1426EXPORT_SYMBOL(of_count_phandle_with_args);
1368 1427
@@ -1734,6 +1793,7 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
1734 ap = dt_alloc(sizeof(*ap) + len + 1, 4); 1793 ap = dt_alloc(sizeof(*ap) + len + 1, 4);
1735 if (!ap) 1794 if (!ap)
1736 continue; 1795 continue;
1796 memset(ap, 0, sizeof(*ap) + len + 1);
1737 ap->alias = start; 1797 ap->alias = start;
1738 of_alias_add(ap, np, id, start, len); 1798 of_alias_add(ap, np, id, start, len);
1739 } 1799 }
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 4fb06f3e7b3c..229dd9d69e18 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -11,12 +11,14 @@
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/initrd.h> 13#include <linux/initrd.h>
14#include <linux/memblock.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/of.h> 16#include <linux/of.h>
16#include <linux/of_fdt.h> 17#include <linux/of_fdt.h>
17#include <linux/string.h> 18#include <linux/string.h>
18#include <linux/errno.h> 19#include <linux/errno.h>
19#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/random.h>
20 22
21#include <asm/setup.h> /* for COMMAND_LINE_SIZE */ 23#include <asm/setup.h> /* for COMMAND_LINE_SIZE */
22#ifdef CONFIG_PPC 24#ifdef CONFIG_PPC
@@ -125,13 +127,13 @@ int of_fdt_match(struct boot_param_header *blob, unsigned long node,
125 return score; 127 return score;
126} 128}
127 129
128static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size, 130static void *unflatten_dt_alloc(void **mem, unsigned long size,
129 unsigned long align) 131 unsigned long align)
130{ 132{
131 void *res; 133 void *res;
132 134
133 *mem = ALIGN(*mem, align); 135 *mem = PTR_ALIGN(*mem, align);
134 res = (void *)*mem; 136 res = *mem;
135 *mem += size; 137 *mem += size;
136 138
137 return res; 139 return res;
@@ -146,9 +148,9 @@ static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size,
146 * @allnextpp: pointer to ->allnext from last allocated device_node 148 * @allnextpp: pointer to ->allnext from last allocated device_node
147 * @fpsize: Size of the node path up at the current depth. 149 * @fpsize: Size of the node path up at the current depth.
148 */ 150 */
149static unsigned long unflatten_dt_node(struct boot_param_header *blob, 151static void * unflatten_dt_node(struct boot_param_header *blob,
150 unsigned long mem, 152 void *mem,
151 unsigned long *p, 153 void **p,
152 struct device_node *dad, 154 struct device_node *dad,
153 struct device_node ***allnextpp, 155 struct device_node ***allnextpp,
154 unsigned long fpsize) 156 unsigned long fpsize)
@@ -161,15 +163,15 @@ static unsigned long unflatten_dt_node(struct boot_param_header *blob,
161 int has_name = 0; 163 int has_name = 0;
162 int new_format = 0; 164 int new_format = 0;
163 165
164 tag = be32_to_cpup((__be32 *)(*p)); 166 tag = be32_to_cpup(*p);
165 if (tag != OF_DT_BEGIN_NODE) { 167 if (tag != OF_DT_BEGIN_NODE) {
166 pr_err("Weird tag at start of node: %x\n", tag); 168 pr_err("Weird tag at start of node: %x\n", tag);
167 return mem; 169 return mem;
168 } 170 }
169 *p += 4; 171 *p += 4;
170 pathp = (char *)*p; 172 pathp = *p;
171 l = allocl = strlen(pathp) + 1; 173 l = allocl = strlen(pathp) + 1;
172 *p = ALIGN(*p + l, 4); 174 *p = PTR_ALIGN(*p + l, 4);
173 175
174 /* version 0x10 has a more compact unit name here instead of the full 176 /* version 0x10 has a more compact unit name here instead of the full
175 * path. we accumulate the full path size using "fpsize", we'll rebuild 177 * path. we accumulate the full path size using "fpsize", we'll rebuild
@@ -201,7 +203,6 @@ static unsigned long unflatten_dt_node(struct boot_param_header *blob,
201 __alignof__(struct device_node)); 203 __alignof__(struct device_node));
202 if (allnextpp) { 204 if (allnextpp) {
203 char *fn; 205 char *fn;
204 memset(np, 0, sizeof(*np));
205 np->full_name = fn = ((char *)np) + sizeof(*np); 206 np->full_name = fn = ((char *)np) + sizeof(*np);
206 if (new_format) { 207 if (new_format) {
207 /* rebuild full path for new format */ 208 /* rebuild full path for new format */
@@ -239,7 +240,7 @@ static unsigned long unflatten_dt_node(struct boot_param_header *blob,
239 u32 sz, noff; 240 u32 sz, noff;
240 char *pname; 241 char *pname;
241 242
242 tag = be32_to_cpup((__be32 *)(*p)); 243 tag = be32_to_cpup(*p);
243 if (tag == OF_DT_NOP) { 244 if (tag == OF_DT_NOP) {
244 *p += 4; 245 *p += 4;
245 continue; 246 continue;
@@ -247,11 +248,11 @@ static unsigned long unflatten_dt_node(struct boot_param_header *blob,
247 if (tag != OF_DT_PROP) 248 if (tag != OF_DT_PROP)
248 break; 249 break;
249 *p += 4; 250 *p += 4;
250 sz = be32_to_cpup((__be32 *)(*p)); 251 sz = be32_to_cpup(*p);
251 noff = be32_to_cpup((__be32 *)((*p) + 4)); 252 noff = be32_to_cpup(*p + 4);
252 *p += 8; 253 *p += 8;
253 if (be32_to_cpu(blob->version) < 0x10) 254 if (be32_to_cpu(blob->version) < 0x10)
254 *p = ALIGN(*p, sz >= 8 ? 8 : 4); 255 *p = PTR_ALIGN(*p, sz >= 8 ? 8 : 4);
255 256
256 pname = of_fdt_get_string(blob, noff); 257 pname = of_fdt_get_string(blob, noff);
257 if (pname == NULL) { 258 if (pname == NULL) {
@@ -281,11 +282,11 @@ static unsigned long unflatten_dt_node(struct boot_param_header *blob,
281 np->phandle = be32_to_cpup((__be32 *)*p); 282 np->phandle = be32_to_cpup((__be32 *)*p);
282 pp->name = pname; 283 pp->name = pname;
283 pp->length = sz; 284 pp->length = sz;
284 pp->value = (void *)*p; 285 pp->value = *p;
285 *prev_pp = pp; 286 *prev_pp = pp;
286 prev_pp = &pp->next; 287 prev_pp = &pp->next;
287 } 288 }
288 *p = ALIGN((*p) + sz, 4); 289 *p = PTR_ALIGN((*p) + sz, 4);
289 } 290 }
290 /* with version 0x10 we may not have the name property, recreate 291 /* with version 0x10 we may not have the name property, recreate
291 * it here from the unit name if absent 292 * it here from the unit name if absent
@@ -334,7 +335,7 @@ static unsigned long unflatten_dt_node(struct boot_param_header *blob,
334 else 335 else
335 mem = unflatten_dt_node(blob, mem, p, np, allnextpp, 336 mem = unflatten_dt_node(blob, mem, p, np, allnextpp,
336 fpsize); 337 fpsize);
337 tag = be32_to_cpup((__be32 *)(*p)); 338 tag = be32_to_cpup(*p);
338 } 339 }
339 if (tag != OF_DT_END_NODE) { 340 if (tag != OF_DT_END_NODE) {
340 pr_err("Weird tag at end of node: %x\n", tag); 341 pr_err("Weird tag at end of node: %x\n", tag);
@@ -360,7 +361,8 @@ static void __unflatten_device_tree(struct boot_param_header *blob,
360 struct device_node **mynodes, 361 struct device_node **mynodes,
361 void * (*dt_alloc)(u64 size, u64 align)) 362 void * (*dt_alloc)(u64 size, u64 align))
362{ 363{
363 unsigned long start, mem, size; 364 unsigned long size;
365 void *start, *mem;
364 struct device_node **allnextp = mynodes; 366 struct device_node **allnextp = mynodes;
365 367
366 pr_debug(" -> unflatten_device_tree()\n"); 368 pr_debug(" -> unflatten_device_tree()\n");
@@ -381,32 +383,28 @@ static void __unflatten_device_tree(struct boot_param_header *blob,
381 } 383 }
382 384
383 /* First pass, scan for size */ 385 /* First pass, scan for size */
384 start = ((unsigned long)blob) + 386 start = ((void *)blob) + be32_to_cpu(blob->off_dt_struct);
385 be32_to_cpu(blob->off_dt_struct); 387 size = (unsigned long)unflatten_dt_node(blob, 0, &start, NULL, NULL, 0);
386 size = unflatten_dt_node(blob, 0, &start, NULL, NULL, 0); 388 size = ALIGN(size, 4);
387 size = (size | 3) + 1;
388 389
389 pr_debug(" size is %lx, allocating...\n", size); 390 pr_debug(" size is %lx, allocating...\n", size);
390 391
391 /* Allocate memory for the expanded device tree */ 392 /* Allocate memory for the expanded device tree */
392 mem = (unsigned long) 393 mem = dt_alloc(size + 4, __alignof__(struct device_node));
393 dt_alloc(size + 4, __alignof__(struct device_node)); 394 memset(mem, 0, size);
394 395
395 memset((void *)mem, 0, size); 396 *(__be32 *)(mem + size) = cpu_to_be32(0xdeadbeef);
396 397
397 ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef); 398 pr_debug(" unflattening %p...\n", mem);
398
399 pr_debug(" unflattening %lx...\n", mem);
400 399
401 /* Second pass, do actual unflattening */ 400 /* Second pass, do actual unflattening */
402 start = ((unsigned long)blob) + 401 start = ((void *)blob) + be32_to_cpu(blob->off_dt_struct);
403 be32_to_cpu(blob->off_dt_struct);
404 unflatten_dt_node(blob, mem, &start, NULL, &allnextp, 0); 402 unflatten_dt_node(blob, mem, &start, NULL, &allnextp, 0);
405 if (be32_to_cpup((__be32 *)start) != OF_DT_END) 403 if (be32_to_cpup(start) != OF_DT_END)
406 pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start)); 404 pr_warning("Weird tag at end of tree: %08x\n", be32_to_cpup(start));
407 if (be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef) 405 if (be32_to_cpup(mem + size) != 0xdeadbeef)
408 pr_warning("End of tree marker overwritten: %08x\n", 406 pr_warning("End of tree marker overwritten: %08x\n",
409 be32_to_cpu(((__be32 *)mem)[size / 4])); 407 be32_to_cpup(mem + size));
410 *allnextp = NULL; 408 *allnextp = NULL;
411 409
412 pr_debug(" <- unflatten_device_tree()\n"); 410 pr_debug(" <- unflatten_device_tree()\n");
@@ -628,7 +626,8 @@ int __init of_scan_flat_dt_by_path(const char *path,
628 */ 626 */
629void __init early_init_dt_check_for_initrd(unsigned long node) 627void __init early_init_dt_check_for_initrd(unsigned long node)
630{ 628{
631 unsigned long start, end, len; 629 u64 start, end;
630 unsigned long len;
632 __be32 *prop; 631 __be32 *prop;
633 632
634 pr_debug("Looking for initrd properties... "); 633 pr_debug("Looking for initrd properties... ");
@@ -636,15 +635,16 @@ void __init early_init_dt_check_for_initrd(unsigned long node)
636 prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len); 635 prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len);
637 if (!prop) 636 if (!prop)
638 return; 637 return;
639 start = of_read_ulong(prop, len/4); 638 start = of_read_number(prop, len/4);
640 639
641 prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len); 640 prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len);
642 if (!prop) 641 if (!prop)
643 return; 642 return;
644 end = of_read_ulong(prop, len/4); 643 end = of_read_number(prop, len/4);
645 644
646 early_init_dt_setup_initrd_arch(start, end); 645 early_init_dt_setup_initrd_arch(start, end);
647 pr_debug("initrd_start=0x%lx initrd_end=0x%lx\n", start, end); 646 pr_debug("initrd_start=0x%llx initrd_end=0x%llx\n",
647 (unsigned long long)start, (unsigned long long)end);
648} 648}
649#else 649#else
650inline void early_init_dt_check_for_initrd(unsigned long node) 650inline void early_init_dt_check_for_initrd(unsigned long node)
@@ -774,6 +774,17 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
774 return 1; 774 return 1;
775} 775}
776 776
777#ifdef CONFIG_HAVE_MEMBLOCK
778/*
779 * called from unflatten_device_tree() to bootstrap devicetree itself
780 * Architectures can override this definition if memblock isn't used
781 */
782void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align)
783{
784 return __va(memblock_alloc(size, align));
785}
786#endif
787
777/** 788/**
778 * unflatten_device_tree - create tree of device_nodes from flat blob 789 * unflatten_device_tree - create tree of device_nodes from flat blob
779 * 790 *
@@ -792,3 +803,14 @@ void __init unflatten_device_tree(void)
792} 803}
793 804
794#endif /* CONFIG_OF_EARLY_FLATTREE */ 805#endif /* CONFIG_OF_EARLY_FLATTREE */
806
807/* Feed entire flattened device tree into the random pool */
808static int __init add_fdt_randomness(void)
809{
810 if (initial_boot_params)
811 add_device_randomness(initial_boot_params,
812 be32_to_cpu(initial_boot_params->totalsize));
813
814 return 0;
815}
816core_initcall(add_fdt_randomness);
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 1264923ade0f..1752988d6aa8 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -28,7 +28,7 @@
28 28
29/** 29/**
30 * irq_of_parse_and_map - Parse and map an interrupt into linux virq space 30 * irq_of_parse_and_map - Parse and map an interrupt into linux virq space
31 * @device: Device node of the device whose interrupt is to be mapped 31 * @dev: Device node of the device whose interrupt is to be mapped
32 * @index: Index of the interrupt to map 32 * @index: Index of the interrupt to map
33 * 33 *
34 * This function is a wrapper that chains of_irq_map_one() and 34 * This function is a wrapper that chains of_irq_map_one() and
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index ea174c8ee34b..8f9be2e09937 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -39,7 +39,7 @@ static const char *phy_modes[] = {
39 * The function gets phy interface string from property 'phy-mode', 39 * The function gets phy interface string from property 'phy-mode',
40 * and return its index in phy_modes table, or errno in error case. 40 * and return its index in phy_modes table, or errno in error case.
41 */ 41 */
42const int of_get_phy_mode(struct device_node *np) 42int of_get_phy_mode(struct device_node *np)
43{ 43{
44 const char *pm; 44 const char *pm;
45 int err, i; 45 int err, i;
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index eeca8a596973..9b439ac63d8e 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -197,7 +197,7 @@ EXPORT_SYMBOL(of_device_alloc);
197 * Returns pointer to created platform device, or NULL if a device was not 197 * Returns pointer to created platform device, or NULL if a device was not
198 * registered. Unavailable devices will not get registered. 198 * registered. Unavailable devices will not get registered.
199 */ 199 */
200struct platform_device *of_platform_device_create_pdata( 200static struct platform_device *of_platform_device_create_pdata(
201 struct device_node *np, 201 struct device_node *np,
202 const char *bus_id, 202 const char *bus_id,
203 void *platform_data, 203 void *platform_data,
@@ -268,8 +268,11 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
268 return NULL; 268 return NULL;
269 269
270 dev = amba_device_alloc(NULL, 0, 0); 270 dev = amba_device_alloc(NULL, 0, 0);
271 if (!dev) 271 if (!dev) {
272 pr_err("%s(): amba_device_alloc() failed for %s\n",
273 __func__, node->full_name);
272 return NULL; 274 return NULL;
275 }
273 276
274 /* setup generic device info */ 277 /* setup generic device info */
275 dev->dev.coherent_dma_mask = ~0; 278 dev->dev.coherent_dma_mask = ~0;
@@ -294,12 +297,18 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
294 dev->irq[i] = irq_of_parse_and_map(node, i); 297 dev->irq[i] = irq_of_parse_and_map(node, i);
295 298
296 ret = of_address_to_resource(node, 0, &dev->res); 299 ret = of_address_to_resource(node, 0, &dev->res);
297 if (ret) 300 if (ret) {
301 pr_err("%s(): of_address_to_resource() failed (%d) for %s\n",
302 __func__, ret, node->full_name);
298 goto err_free; 303 goto err_free;
304 }
299 305
300 ret = amba_device_add(dev, &iomem_resource); 306 ret = amba_device_add(dev, &iomem_resource);
301 if (ret) 307 if (ret) {
308 pr_err("%s(): amba_device_add() failed (%d) for %s\n",
309 __func__, ret, node->full_name);
302 goto err_free; 310 goto err_free;
311 }
303 312
304 return dev; 313 return dev;
305 314
@@ -378,6 +387,10 @@ static int of_platform_bus_create(struct device_node *bus,
378 } 387 }
379 388
380 if (of_device_is_compatible(bus, "arm,primecell")) { 389 if (of_device_is_compatible(bus, "arm,primecell")) {
390 /*
391 * Don't return an error here to keep compatibility with older
392 * device tree files.
393 */
381 of_amba_device_create(bus, bus_id, platform_data, parent); 394 of_amba_device_create(bus, bus_id, platform_data, parent);
382 return 0; 395 return 0;
383 } 396 }