aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2017-01-19 13:59:27 +0000
committerMark Rutland <mark.rutland@arm.com>2017-01-19 14:41:52 +0000
commit6e7aa16562f8ac0a98087d48985b2f4a909e414f (patch)
tree4f98bc30666896cf26b6f800cb5ab7af3b98941c
parent1a0163135df878114e520beab207abde36eb2502 (diff)
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>
-rwxr-xr-xFDT.pm19
1 files changed, 19 insertions, 0 deletions
diff --git a/FDT.pm b/FDT.pm
index f498f09..9adf70b 100755
--- a/FDT.pm
+++ b/FDT.pm
@@ -278,6 +278,25 @@ sub find_by_device_type
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;