diff options
author | Mark Rutland <mark.rutland@arm.com> | 2017-01-19 13:59:27 +0000 |
---|---|---|
committer | Mark Rutland <mark.rutland@arm.com> | 2017-01-19 14:41:52 +0000 |
commit | 6e7aa16562f8ac0a98087d48985b2f4a909e414f (patch) | |
tree | 4f98bc30666896cf26b6f800cb5ab7af3b98941c | |
parent | 1a0163135df878114e520beab207abde36eb2502 (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-x | FDT.pm | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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; |