FDT.pm: add helper to get a node's full path This will be useful for subsequent patches where we want to automatically configure properties for nodes which may have arbitrary names. Signed-off-by: Mark Rutland <mark.rutland@arm.com>
diff --git a/FDT.pm b/FDT.pm index f498f09..9adf70b 100755 --- a/FDT.pm +++ b/FDT.pm
@@ -278,6 +278,25 @@ return @found; } +sub get_full_path +{ + my $self = shift; + my $cur = $self; + my @elems = (); + + # root node + if (not defined($cur->{parent})) { + return '/'; + } + + while (defined($cur->{parent})) { + unshift @elems, $cur->{name}; + unshift @elems, '/'; + $cur = $cur->{parent}; + } + return join ('', @elems); +} + sub get_property { my $self = shift;