Lines Matching +full:in +full:- +full:tree

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
16 * @fdto: pointer to the device tree overlay blob
17 * @fragment: node offset of the fragment in the overlay
21 * property) instead of a path (target-path 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
45 * @fdt: Base device tree blob
46 * @fdto: Device tree overlay blob
47 * @fragment: node offset of the fragment in the overlay
50 * overlay_get_target() retrieves the target offset in the base
51 * device tree of a fragment, no matter how the actual targeting is
55 * the targeted node offset in the base device tree
67 if (phandle == (uint32_t)-1) in overlay_get_target()
68 return -FDT_ERR_BADPHANDLE; in overlay_get_target()
73 path = fdt_getprop(fdto, fragment, "target-path", &path_len); in overlay_get_target()
83 * target-path property in a node that contains a 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
104 * @fdt: Base device tree blob
105 * @node: Device tree overlay blob
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()
142 * overlay_adjust_node_phandles - Offsets the phandles of a node
143 * @fdto: Device tree overlay blob
150 * phandles to not conflict with the overlays of the base device tree.
163 if (ret && ret != -FDT_ERR_NOTFOUND) in overlay_adjust_node_phandles()
167 if (ret && ret != -FDT_ERR_NOTFOUND) in overlay_adjust_node_phandles()
180 * overlay_adjust_local_phandles - Adjust the phandles of a whole overlay
181 * @fdto: Device tree overlay blob
187 * phandles to not conflict with the overlays of the base device tree.
202 * overlay_update_local_node_references - Adjust the overlay references
203 * @fdto: Device tree overlay blob
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,
213 * where you want the device tree overlays phandles to not conflict
214 * with the ones from the base device tree before merging them.
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()
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
310 * @fdto: Device tree overlay blob
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,
318 * where you want the device tree overlays phandles to not conflict
319 * with the ones from the base device tree before merging them.
332 if (fixups == -FDT_ERR_NOTFOUND) in overlay_update_local_references()
339 * Update our local references from the root of the tree in overlay_update_local_references()
346 * overlay_fixup_one_phandle - Set an overlay phandle to the base one
347 * @fdt: Base Device Tree blob
348 * @fdto: Device tree overlay blob
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
358 * a node in the base device tree.
360 * This is part of the device tree overlay application process, when
361 * you want all the phandles in the overlay to point to the actual
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
411 * @fdt: Base Device Tree blob
412 * @fdto: Device tree overlay blob
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
418 * in use in the base device tree.
420 * This is part of the device tree overlay application process, when
421 * you want all the phandles in the overlay to point to the actual
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
495 * device tree
496 * @fdt: Base Device Tree blob
497 * @fdto: Device tree overlay blob
500 * to nodes in the base device tree.
502 * This is one of the steps of the device tree overlay application
503 * process, when you want all the phandles in the overlay to point to
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()
539 * overlay_apply_node - Merges a node into the base device tree
540 * @fdt: Base Device Tree blob
541 * @target: Node offset in the base device tree to apply the fragment to
542 * @fdto: Device tree overlay blob
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
548 * This is part of the final step in the device tree overlay
551 * tree.
571 if (prop_len == -FDT_ERR_NOTFOUND) in overlay_apply_node()
572 return -FDT_ERR_INTERNAL; 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
606 * @fdt: Base Device Tree blob
607 * @fdto: Device tree overlay blob
609 * overlay_merge() merges an overlay into its base device tree.
611 * This is the next to last step in the device tree overlay application
613 * you just have to merge overlay into the base device tree.
633 if (overlay == -FDT_ERR_NOTFOUND) in overlay_merge()
673 /* in case of root pretend it's "/" */ in get_path_len()
680 * overlay_symbol_update - Update the symbols of base tree after a merge
681 * @fdt: Base Device Tree blob
682 * @fdto: Device tree overlay blob
684 * overlay_symbol_update() updates the symbols of the base tree with the
687 * This is the last step in the device tree overlay application
717 if (root_sym == -FDT_ERR_NOTFOUND) 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()
744 * up in the target tree */ in overlay_symbol_update()
749 frag_name_len = s - path - 1; in overlay_symbol_update()
751 /* verify format; safe since "s" lies in \0 terminated prop */ 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()
764 * up in the target tree */ in overlay_symbol_update()
768 /* find the fragment index in which the symbol lies */ in overlay_symbol_update()
773 return -FDT_ERR_BADOVERLAY; in overlay_symbol_update()
779 return -FDT_ERR_BADOVERLAY; in overlay_symbol_update()
803 /* again in case setprop_placeholder changed it */ in overlay_symbol_update()
820 len--; in overlay_symbol_update()
876 * The base device tree might have been damaged, erase its in fdt_overlay_apply()