summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/dev/ofw/ofw_fdt.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-21 09:39:55 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-21 10:29:40 +0200
commit2df56dbd60bb5d925d2ce0ddbdefdbe6107ea783 (patch)
treebd7bad558534db4a1f400bc38a2c9aa7ea4f411e /freebsd/sys/dev/ofw/ofw_fdt.c
parentUpdate to FreeBSD head 2018-02-01 (diff)
downloadrtems-libbsd-2df56dbd60bb5d925d2ce0ddbdefdbe6107ea783.tar.bz2
Update to FreeBSD head 2018-04-01
Git mirror commit 8dfb1ccc26d1cea7e2529303003ff61f9f1784c4. Update #3472.
Diffstat (limited to 'freebsd/sys/dev/ofw/ofw_fdt.c')
-rw-r--r--freebsd/sys/dev/ofw/ofw_fdt.c56
1 files changed, 18 insertions, 38 deletions
diff --git a/freebsd/sys/dev/ofw/ofw_fdt.c b/freebsd/sys/dev/ofw/ofw_fdt.c
index b9266eb5..8878b5c9 100644
--- a/freebsd/sys/dev/ofw/ofw_fdt.c
+++ b/freebsd/sys/dev/ofw/ofw_fdt.c
@@ -182,7 +182,7 @@ fdt_phandle_offset(phandle_t p)
static phandle_t
ofw_fdt_peer(ofw_t ofw, phandle_t node)
{
- int depth, offset;
+ int offset;
if (node == 0) {
/* Find root node */
@@ -194,39 +194,21 @@ ofw_fdt_peer(ofw_t ofw, phandle_t node)
offset = fdt_phandle_offset(node);
if (offset < 0)
return (0);
-
- for (depth = 1, offset = fdt_next_node(fdtp, offset, &depth);
- offset >= 0;
- offset = fdt_next_node(fdtp, offset, &depth)) {
- if (depth < 0)
- return (0);
- if (depth == 1)
- return (fdt_offset_phandle(offset));
- }
-
- return (0);
+ offset = fdt_next_subnode(fdtp, offset);
+ return (fdt_offset_phandle(offset));
}
/* Return the first child of this node or 0. */
static phandle_t
ofw_fdt_child(ofw_t ofw, phandle_t node)
{
- int depth, offset;
+ int offset;
offset = fdt_phandle_offset(node);
if (offset < 0)
return (0);
-
- for (depth = 0, offset = fdt_next_node(fdtp, offset, &depth);
- (offset >= 0) && (depth > 0);
- offset = fdt_next_node(fdtp, offset, &depth)) {
- if (depth < 0)
- return (0);
- if (depth == 1)
- return (fdt_offset_phandle(offset));
- }
-
- return (0);
+ offset = fdt_first_subnode(fdtp, offset);
+ return (fdt_offset_phandle(offset));
}
/* Return the parent of this node or 0. */
@@ -349,27 +331,25 @@ ofw_fdt_nextprop(ofw_t ofw, phandle_t package, const char *previous, char *buf,
if (offset < 0)
return (-1);
- /* Find the first prop in the node */
- offset = fdt_first_property_offset(fdtp, offset);
- if (offset < 0)
- return (0); /* No properties */
-
- if (previous != NULL) {
- while (offset >= 0) {
+ if (previous == NULL)
+ /* Find the first prop in the node */
+ offset = fdt_first_property_offset(fdtp, offset);
+ else {
+ fdt_for_each_property_offset(offset, fdtp, offset) {
prop = fdt_getprop_by_offset(fdtp, offset, &name, NULL);
if (prop == NULL)
return (-1); /* Internal error */
-
+ /* Skip until we find 'previous', then bail out */
+ if (strcmp(name, previous) != 0)
+ continue;
offset = fdt_next_property_offset(fdtp, offset);
- if (offset < 0)
- return (0); /* No more properties */
-
- /* Check if the last one was the one we wanted */
- if (strcmp(name, previous) == 0)
- break;
+ break;
}
}
+ if (offset < 0)
+ return (0); /* No properties */
+
prop = fdt_getprop_by_offset(fdtp, offset, &name, &offset);
if (prop == NULL)
return (-1); /* Internal error */