[BOOTWRAPPER PATCH 2/3] FDT.pm: add helper to get a node's full path

Mark Rutland mark.rutland at arm.com
Fri Feb 17 04:32:50 PST 2017


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 at arm.com>
---
 FDT.pm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

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;
-- 
1.9.1




More information about the linux-arm-kernel mailing list