Lines Matching +full:a +full:- +full:child +full:- +full:node +full:- +full:property
1 // SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
3 * libfdt - Flat Device Tree manipulation
15 * overlay_get_target_phandle - retrieves the target phandle of a fragment
17 * @fragment: node offset of the fragment in the overlay
20 * overlay fragment when that fragment uses a phandle (target
21 * property) instead of a path (target-path property).
24 * the phandle pointed by the target property
26 * -1, if the phandle was malformed
37 if ((len != sizeof(*val)) || (fdt32_to_cpu(*val) == (uint32_t)-1)) in overlay_get_target_phandle()
38 return (uint32_t)-1; in overlay_get_target_phandle()
44 * overlay_get_target - retrieves the offset of a fragment's target
47 * @fragment: node offset of the fragment in the overlay
51 * device tree of a fragment, no matter how the actual targeting is
52 * done (through a phandle or a path)
55 * the targeted node offset in the base device tree
65 /* Try first to do a phandle based lookup */ in overlay_get_target()
67 if (phandle == (uint32_t)-1) in overlay_get_target()
68 return -FDT_ERR_BADPHANDLE; in overlay_get_target()
72 /* And then a path based lookup */ in overlay_get_target()
73 path = fdt_getprop(fdto, fragment, "target-path", &path_len); in overlay_get_target()
82 * If we haven't found either a target or a in overlay_get_target()
83 * target-path property in a node that contains a in overlay_get_target()
85 * otherwise), consider it a improperly written in overlay_get_target()
88 if (ret < 0 && path_len == -FDT_ERR_NOTFOUND) in overlay_get_target()
89 ret = -FDT_ERR_BADOVERLAY; in overlay_get_target()
103 * overlay_phandle_add_offset - Increases a phandle by an offset
105 * @node: Device tree overlay blob
106 * @name: Name of the property to modify (phandle or linux,phandle)
109 * overlay_phandle_add_offset() increments a node phandle by a given
116 static int overlay_phandle_add_offset(void *fdt, int node, in overlay_phandle_add_offset() argument
123 val = fdt_getprop(fdt, node, name, &len); in overlay_phandle_add_offset()
128 return -FDT_ERR_BADPHANDLE; in overlay_phandle_add_offset()
132 return -FDT_ERR_NOPHANDLES; in overlay_phandle_add_offset()
135 if (adj_val == (uint32_t)-1) in overlay_phandle_add_offset()
136 return -FDT_ERR_NOPHANDLES; in overlay_phandle_add_offset()
138 return fdt_setprop_inplace_u32(fdt, node, name, adj_val); in overlay_phandle_add_offset()
142 * overlay_adjust_node_phandles - Offsets the phandles of a node
144 * @node: Offset of the node we want to adjust
147 * overlay_adjust_node_phandles() adds a constant to all the phandles
148 * of a given node. This is mainly use as part of the overlay
156 static int overlay_adjust_node_phandles(void *fdto, int node, in overlay_adjust_node_phandles() argument
159 int child; in overlay_adjust_node_phandles() local
162 ret = overlay_phandle_add_offset(fdto, node, "phandle", delta); in overlay_adjust_node_phandles()
163 if (ret && ret != -FDT_ERR_NOTFOUND) in overlay_adjust_node_phandles()
166 ret = overlay_phandle_add_offset(fdto, node, "linux,phandle", delta); in overlay_adjust_node_phandles()
167 if (ret && ret != -FDT_ERR_NOTFOUND) in overlay_adjust_node_phandles()
170 fdt_for_each_subnode(child, fdto, node) { in overlay_adjust_node_phandles()
171 ret = overlay_adjust_node_phandles(fdto, child, delta); in overlay_adjust_node_phandles()
180 * overlay_adjust_local_phandles - Adjust the phandles of a whole overlay
184 * overlay_adjust_local_phandles() adds a constant to all the
202 * overlay_update_local_node_references - Adjust the overlay references
204 * @tree_node: Node offset of the node to operate on
205 * @fixup_node: Node offset of the matching local fixups node
209 * pointing to a node within the device tree overlay by adding a
212 * This is mainly used as part of a device tree application process,
243 return -FDT_ERR_BADOVERLAY; in overlay_update_local_node_references()
248 if (tree_len == -FDT_ERR_NOTFOUND) in overlay_update_local_node_references()
249 return -FDT_ERR_BADOVERLAY; in overlay_update_local_node_references()
263 * Use a memcpy for the architectures that do in overlay_update_local_node_references()
277 if (ret == -FDT_ERR_NOSPACE) in overlay_update_local_node_references()
278 return -FDT_ERR_BADOVERLAY; in overlay_update_local_node_references()
292 if (tree_child == -FDT_ERR_NOTFOUND) in overlay_update_local_node_references()
293 return -FDT_ERR_BADOVERLAY; in overlay_update_local_node_references()
309 * overlay_update_local_references - Adjust the overlay references
314 * to a node within the device tree overlay by adding a constant
317 * This is mainly used as part of a device tree application process,
332 if (fixups == -FDT_ERR_NOTFOUND) in overlay_update_local_references()
346 * overlay_fixup_one_phandle - Set an overlay phandle to the base one
349 * @symbols_off: Node offset of the symbols node in the base device tree
350 * @path: Path to a node holding a phandle in the overlay
352 * @name: Name of the property holding the phandle reference in the overlay
354 * @poffset: Offset within the overlay property where the phandle is stored
355 * @label: Label of the node referenced by the phandle
358 * a node in the base device tree.
394 return -FDT_ERR_NOTFOUND; in overlay_fixup_one_phandle()
397 if (fixup_off == -FDT_ERR_NOTFOUND) in overlay_fixup_one_phandle()
398 return -FDT_ERR_BADOVERLAY; in overlay_fixup_one_phandle()
410 * overlay_fixup_phandle - Set an overlay phandle to the base one
413 * @symbols_off: Node offset of the symbols node in the base device tree
414 * @property: Property offset in the overlay holding the list of fixups
417 * to in a __fixups__ property, and updates them to match the phandles
429 int property) in overlay_fixup_phandle() argument
435 value = fdt_getprop_by_offset(fdto, property, in overlay_fixup_phandle()
438 if (len == -FDT_ERR_NOTFOUND) in overlay_fixup_phandle()
439 return -FDT_ERR_INTERNAL; in overlay_fixup_phandle()
454 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
455 fixup_len = fixup_end - fixup_str; in overlay_fixup_phandle()
457 len -= fixup_len + 1; in overlay_fixup_phandle()
463 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
465 path_len = sep - path; in overlay_fixup_phandle()
466 if (path_len == (fixup_len - 1)) in overlay_fixup_phandle()
467 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
469 fixup_len -= path_len + 1; in overlay_fixup_phandle()
473 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
475 name_len = sep - name; in overlay_fixup_phandle()
477 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
481 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
494 * overlay_fixup_phandles - Resolve the overlay phandles to the base
513 int property; in overlay_fixup_phandles() local
517 if (fixups_off == -FDT_ERR_NOTFOUND) in overlay_fixup_phandles()
524 if ((symbols_off < 0 && (symbols_off != -FDT_ERR_NOTFOUND))) in overlay_fixup_phandles()
527 fdt_for_each_property_offset(property, fdto, fixups_off) { in overlay_fixup_phandles()
530 ret = overlay_fixup_phandle(fdt, fdto, symbols_off, property); in overlay_fixup_phandles()
539 * overlay_apply_node - Merges a node into the base device tree
541 * @target: Node offset in the base device tree to apply the fragment to
543 * @node: Node offset in the overlay holding the changes to merge
545 * overlay_apply_node() merges a node into a target base device tree
546 * node pointed.
558 void *fdto, int node) in overlay_apply_node() argument
560 int property; in overlay_apply_node() local
563 fdt_for_each_property_offset(property, fdto, node) { in overlay_apply_node()
569 prop = fdt_getprop_by_offset(fdto, property, &name, in overlay_apply_node()
571 if (prop_len == -FDT_ERR_NOTFOUND) in overlay_apply_node()
572 return -FDT_ERR_INTERNAL; in overlay_apply_node()
581 fdt_for_each_subnode(subnode, fdto, node) { in overlay_apply_node()
587 if (nnode == -FDT_ERR_EXISTS) { in overlay_apply_node()
589 if (nnode == -FDT_ERR_NOTFOUND) in overlay_apply_node()
590 return -FDT_ERR_INTERNAL; in overlay_apply_node()
605 * overlay_merge - Merge an overlay into its base device tree
629 * Each fragments will have an __overlay__ node. If in overlay_merge()
633 if (overlay == -FDT_ERR_NOTFOUND) in overlay_merge()
680 * overlay_symbol_update - Update the symbols of base tree after a merge
717 if (root_sym == -FDT_ERR_NOTFOUND) in overlay_symbol_update()
730 /* verify it's a string property (terminated by a single \0) */ in overlay_symbol_update()
731 if (path_len < 1 || memchr(path, '\0', path_len) != &path[path_len - 1]) in overlay_symbol_update()
732 return -FDT_ERR_BADVALUE; in overlay_symbol_update()
738 return -FDT_ERR_BADVALUE; in overlay_symbol_update()
749 frag_name_len = s - path - 1; in overlay_symbol_update()
752 len = sizeof("/__overlay__/") - 1; in overlay_symbol_update()
753 if ((e - s) > len && (memcmp(s, "/__overlay__/", len) == 0)) { in overlay_symbol_update()
754 /* /<fragment-name>/__overlay__/<relative-subnode-path> */ in overlay_symbol_update()
756 rel_path_len = e - rel_path - 1; in overlay_symbol_update()
757 } else if ((e - s) == len in overlay_symbol_update()
758 && (memcmp(s, "/__overlay__", len - 1) == 0)) { in overlay_symbol_update()
759 /* /<fragment-name>/__overlay__ */ in overlay_symbol_update()
773 return -FDT_ERR_BADOVERLAY; in overlay_symbol_update()
779 return -FDT_ERR_BADOVERLAY; in overlay_symbol_update()
787 /* if we have a target path use */ in overlay_symbol_update()
820 len--; in overlay_symbol_update()