Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143526819
D14225.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D14225.diff
View Options
Index: head/sys/dev/ofw/ofw_fdt.c
===================================================================
--- head/sys/dev/ofw/ofw_fdt.c
+++ head/sys/dev/ofw/ofw_fdt.c
@@ -174,7 +174,7 @@
static phandle_t
ofw_fdt_peer(ofw_t ofw, phandle_t node)
{
- int depth, offset;
+ int offset;
if (node == 0) {
/* Find root node */
@@ -186,39 +186,21 @@
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. */
@@ -341,26 +323,24 @@
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)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 31, 8:24 PM (13 m, 31 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28177077
Default Alt Text
D14225.diff (2 KB)
Attached To
Mode
D14225: ofw_fdt: Simplify with libfdt methods
Attached
Detach File
Event Timeline
Log In to Comment