dtoverlay: allow top-level phandles to optionally be preserved#198
Merged
Conversation
Collaborator
|
I think we can make it shorter (and more efficient): @@ -564,6 +564,7 @@ int dtoverlay_merge_fragment(DTBLOB_T *base_dtb, int target_off,
int overlay_off, int depth)
{
int prop_off, subnode_off;
+ int preserve_phandles;
int err = 0;
if (dtoverlay_debug_enabled)
@@ -578,6 +579,10 @@ int dtoverlay_merge_fragment(DTBLOB_T *base_dtb, int target_off,
overlay_path);
}
+ // Check for a property flag to indicate preserving top-level phandles
+ preserve_phandles = depth > 0 ||
+ fdt_getprop(overlay_dtb->fdt, overlay_off, "dtoverlay,preserve-phandle", NULL);
+
// Merge each property of the node
for (prop_off = fdt_first_property_offset(overlay_dtb->fdt, overlay_off);
(prop_off >= 0) && (err == 0);
@@ -592,10 +597,11 @@ int dtoverlay_merge_fragment(DTBLOB_T *base_dtb, int target_off,
prop_val = fdt_getprop_by_offset(overlay_dtb->fdt, prop_off,
&prop_name, &prop_len);
- /* Skip these system properties (only phandles in the first level) */
+ // Skip system properties and top-level phandles unless preserved
if ((strcmp(prop_name, "name") == 0) ||
- ((depth == 0) && ((strcmp(prop_name, "phandle") == 0) ||
- (strcmp(prop_name, "linux,phandle") == 0))))
+ (strcmp(prop_name, "dtoverlay,preserve-phandle") == 0) ||
+ (!preserve_phandles && ((strcmp(prop_name, "phandle") == 0) ||
+ (strcmp(prop_name, "linux,phandle") == 0))))
continue;
dtoverlay_debug(" +prop(%s)", prop_name); |
Look for the 'dtoverlay,preserve-phandle' flag in the overlay and, if it's present, keep and merge the phandle.
Contributor
Author
|
Updated with your suggestions (I like your way a lot better). |
pelwell
added a commit
that referenced
this pull request
Jun 12, 2026
Look for the 'dtoverlay,preserve-phandle' flag in the overlay payloads, preserving the label on any payloads where it is present. This is the ovmerge equivalent of #198. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Collaborator
|
Thanks! BTW, #199 is the equivalent change to ovmerge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Look for the
dtoverlay,preserve-phandleflag in the overlay and, if it's present, keep and merge the phandle.This is useful with ethernet PHYs, like so:
Without this patch the top-level
phandleis not preserved, so thephy-handledoes not match the node for the PHY.