Lines Matching +full:device +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
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
321 * a node in the base device tree.
323 * This is part of the device tree overlay application process, when
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
365 * in use in the base device tree.
367 * This is part of the device tree overlay application process, when
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
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
649 * @fdto: Device tree overlay blob
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
725 if (overlay == -FDT_ERR_NOTFOUND) in overlay_prevent_phandle_overwrite()
732 if (target == -FDT_ERR_NOTFOUND) 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
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
762 * resolved and you just have to merge overlay into the base device
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()
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()
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()
985 return -FDT_ERR_BADOVERLAY; in overlay_symbol_update()
991 return -FDT_ERR_BADOVERLAY; in overlay_symbol_update()
1032 len--; in overlay_symbol_update()
1096 * The base device tree might have been damaged, erase its in fdt_overlay_apply()