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()
52 if (phandle == (uint32_t)-1) in fdt_overlay_target_offset()
53 return -FDT_ERR_BADPHANDLE; in fdt_overlay_target_offset()
58 path = fdt_getprop(fdto, fragment_offset, "target-path", &path_len); in fdt_overlay_target_offset()
68 * target-path property in a node that contains a in fdt_overlay_target_offset()
73 if (ret < 0 && path_len == -FDT_ERR_NOTFOUND) in fdt_overlay_target_offset()
74 ret = -FDT_ERR_BADOVERLAY; in fdt_overlay_target_offset()
88 * overlay_phandle_add_offset - Increases a phandle by an offset
89 * @fdt: Base device tree blob
90 * @node: Device tree overlay blob
112 return -FDT_ERR_BADPHANDLE; in overlay_phandle_add_offset()
115 if (val + delta < val || val + delta == (uint32_t)-1) in overlay_phandle_add_offset()
116 return -FDT_ERR_NOPHANDLES; in overlay_phandle_add_offset()
123 * overlay_adjust_node_phandles - Offsets the phandles of a node
124 * @fdto: Device tree overlay blob
131 * phandles to not conflict with the overlays of the base device tree.
144 if (ret && ret != -FDT_ERR_NOTFOUND) in overlay_adjust_node_phandles()
148 if (ret && ret != -FDT_ERR_NOTFOUND) in overlay_adjust_node_phandles()
161 * overlay_adjust_local_phandles - Adjust the phandles of a whole overlay
162 * @fdto: Device tree overlay blob
168 * phandles to not conflict with the overlays of the base device tree.
183 * overlay_update_local_node_references - Adjust the overlay references
184 * @fdto: Device tree overlay blob
190 * pointing to a node within the device tree overlay by adding a
193 * This is mainly used as part of a device tree application process,
194 * where you want the device tree overlays phandles to not conflict
195 * with the ones from the base device tree before merging them.
224 return -FDT_ERR_BADOVERLAY; in overlay_update_local_node_references()
229 if (tree_len == -FDT_ERR_NOTFOUND) in overlay_update_local_node_references()
230 return -FDT_ERR_BADOVERLAY; in overlay_update_local_node_references()
255 if (tree_child == -FDT_ERR_NOTFOUND) in overlay_update_local_node_references()
256 return -FDT_ERR_BADOVERLAY; in overlay_update_local_node_references()
272 * overlay_update_local_references - Adjust the overlay references
273 * @fdto: Device tree overlay blob
277 * to a node within the device tree overlay by adding a constant
280 * This is mainly used as part of a device tree application process,
281 * where you want the device tree overlays phandles to not conflict
282 * with the ones from the base device tree before merging them.
295 if (fixups == -FDT_ERR_NOTFOUND) in overlay_update_local_references()
302 * Update our local references from the root of the tree in overlay_update_local_references()
309 * overlay_fixup_one_phandle - Set an overlay phandle to the base one
310 * @fdt: Base Device Tree blob
311 * @fdto: Device tree overlay blob
312 * @symbols_off: Node offset of the symbols node in the base device tree
313 * @path: Path to a node holding a phandle in the overlay
315 * @name: Name of the property holding the phandle reference in the overlay
321 * a node in the base device tree.
323 * This is part of the device tree overlay application process, when
324 * you want all the phandles in the overlay to point to the actual
344 if (fixup_off == -FDT_ERR_NOTFOUND) in overlay_fixup_one_phandle()
345 return -FDT_ERR_BADOVERLAY; in overlay_fixup_one_phandle()
357 * overlay_fixup_phandle - Set an overlay phandle to the base one
358 * @fdt: Base Device Tree blob
359 * @fdto: Device tree overlay blob
360 * @symbols_off: Node offset of the symbols node in the base device tree
361 * @property: Property offset in the overlay holding the list of fixups
364 * to in a __fixups__ property, and updates them to match the phandles
365 * in use in the base device tree.
367 * This is part of the device tree overlay application process, when
368 * you want all the phandles in the overlay to point to the actual
389 if (len == -FDT_ERR_NOTFOUND) in overlay_fixup_phandle()
390 return -FDT_ERR_INTERNAL; in overlay_fixup_phandle()
405 return -FDT_ERR_NOTFOUND; in overlay_fixup_phandle()
417 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
418 fixup_len = fixup_end - fixup_str; in overlay_fixup_phandle()
420 len -= fixup_len + 1; in overlay_fixup_phandle()
426 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
428 path_len = sep - path; in overlay_fixup_phandle()
429 if (path_len == (fixup_len - 1)) in overlay_fixup_phandle()
430 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
432 fixup_len -= path_len + 1; in overlay_fixup_phandle()
436 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
438 name_len = sep - name; in overlay_fixup_phandle()
440 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
444 return -FDT_ERR_BADOVERLAY; in overlay_fixup_phandle()
457 * overlay_fixup_phandles - Resolve the overlay phandles to the base
458 * device tree
459 * @fdt: Base Device Tree blob
460 * @fdto: Device tree overlay blob
463 * to nodes in the base device tree.
465 * This is one of the steps of the device tree overlay application
466 * process, when you want all the phandles in the overlay to point to
480 if (fixups_off == -FDT_ERR_NOTFOUND) in overlay_fixup_phandles()
487 if ((symbols_off < 0 && (symbols_off != -FDT_ERR_NOTFOUND))) in overlay_fixup_phandles()
503 * @fdto: Device tree overlay
535 * overlay_update_node_conflicting_references - Recursively replace phandle values
536 * @fdto: Device tree overlay blob
571 return -FDT_ERR_BADOVERLAY; in overlay_update_node_conflicting_references()
576 if (tree_len == -FDT_ERR_NOTFOUND) in overlay_update_node_conflicting_references()
577 return -FDT_ERR_BADOVERLAY; in overlay_update_node_conflicting_references()
600 if (tree_child == -FDT_ERR_NOTFOUND) in overlay_update_node_conflicting_references()
601 return -FDT_ERR_BADOVERLAY; in overlay_update_node_conflicting_references()
617 * overlay_update_local_conflicting_references - Recursively replace phandle values
618 * @fdto: Device tree overlay blob
635 if (fixups == -FDT_ERR_NOTFOUND) in overlay_update_local_conflicting_references()
646 * overlay_prevent_phandle_overwrite_node - Helper function for overlay_prevent_phandle_overwrite
647 * @fdt: Base Device tree blob
648 * @fdtnode: Node in fdt that is checked for an overwrite
649 * @fdto: Device tree overlay blob
650 * @fdtonode: Node in fdto matching @fdtnode
686 if (fdtchild == -FDT_ERR_NOTFOUND) in overlay_prevent_phandle_overwrite_node()
703 * overlay_prevent_phandle_overwrite - Fixes overlay phandles to not overwrite base phandles
704 * @fdt: Base Device Tree blob
705 * @fdto: Device tree overlay blob
707 * Checks recursively if applying fdto overwrites phandle values in the base
709 * phandle value to not break references in the base.
725 if (overlay == -FDT_ERR_NOTFOUND) in overlay_prevent_phandle_overwrite()
732 if (target == -FDT_ERR_NOTFOUND) in overlay_prevent_phandle_overwrite()
734 * The subtree doesn't exist in the base, so nothing in overlay_prevent_phandle_overwrite()
751 * overlay_apply_node - Merges a node into the base device tree
752 * @fdt: Base Device Tree blob
753 * @target: Node offset in the base device tree to apply the fragment to
754 * @fdto: Device tree overlay blob
755 * @node: Node offset in the overlay holding the changes to merge
757 * overlay_apply_node() merges a node into a target base device tree
760 * This is part of the final step in the device tree overlay
763 * tree.
783 if (prop_len == -FDT_ERR_NOTFOUND) in overlay_apply_node()
784 return -FDT_ERR_INTERNAL; in overlay_apply_node()
799 if (nnode == -FDT_ERR_EXISTS) { in overlay_apply_node()
801 if (nnode == -FDT_ERR_NOTFOUND) in overlay_apply_node()
802 return -FDT_ERR_INTERNAL; in overlay_apply_node()
817 * overlay_merge - Merge an overlay into its base device tree
818 * @fdt: Base Device Tree blob
819 * @fdto: Device tree overlay blob
821 * overlay_merge() merges an overlay into its base device tree.
823 * This is the next to last step in the device tree overlay application
825 * you just have to merge overlay into the base device tree.
845 if (overlay == -FDT_ERR_NOTFOUND) in overlay_merge()
885 /* in case of root pretend it's "/" */ in get_path_len()
892 * overlay_symbol_update - Update the symbols of base tree after a merge
893 * @fdt: Base Device Tree blob
894 * @fdto: Device tree overlay blob
896 * overlay_symbol_update() updates the symbols of the base tree with the
899 * This is the last step in the device tree overlay application
929 if (root_sym == -FDT_ERR_NOTFOUND) in overlay_symbol_update()
943 if (path_len < 1 || memchr(path, '\0', path_len) != &path[path_len - 1]) in overlay_symbol_update()
944 return -FDT_ERR_BADVALUE; in overlay_symbol_update()
950 return -FDT_ERR_BADVALUE; in overlay_symbol_update()
956 * up in the target tree */ in overlay_symbol_update()
961 frag_name_len = s - path - 1; in overlay_symbol_update()
963 /* verify format; safe since "s" lies in \0 terminated prop */ in overlay_symbol_update()
964 len = sizeof("/__overlay__/") - 1; in overlay_symbol_update()
965 if ((e - s) > len && (memcmp(s, "/__overlay__/", len) == 0)) { in overlay_symbol_update()
966 /* /<fragment-name>/__overlay__/<relative-subnode-path> */ in overlay_symbol_update()
968 rel_path_len = e - rel_path - 1; in overlay_symbol_update()
969 } else if ((e - s) == len in overlay_symbol_update()
970 && (memcmp(s, "/__overlay__", len - 1) == 0)) { in overlay_symbol_update()
971 /* /<fragment-name>/__overlay__ */ in overlay_symbol_update()
976 * up in the target tree */ in overlay_symbol_update()
980 /* find the fragment index in which the symbol lies */ in overlay_symbol_update()
985 return -FDT_ERR_BADOVERLAY; in overlay_symbol_update()
991 return -FDT_ERR_BADOVERLAY; in overlay_symbol_update()
1015 /* again in case setprop_placeholder changed it */ in overlay_symbol_update()
1032 len--; in overlay_symbol_update()
1054 /* Increase all phandles in the fdto by delta */ in fdt_overlay_apply()
1059 /* Adapt the phandle values in fdto to the above increase */ in fdt_overlay_apply()
1069 /* Don't overwrite phandles in fdt */ in fdt_overlay_apply()
1096 * The base device tree might have been damaged, erase its in fdt_overlay_apply()