summaryrefslogtreecommitdiffstats
path: root/Util.pm
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2017-02-22 04:14:01 -0600
committerDeepak Kodihalli <dkodihal@in.ibm.com>2017-02-22 04:52:15 -0600
commit9283add2b13b43e50248c612a5b2dfbed9a39903 (patch)
treebfdfc4257d72fb3ca879a7265bdb1987cbdab1dc /Util.pm
parentc1b12a4d97e6fceb8206a46f43cf3d97ca070a19 (diff)
downloadphosphor-mrw-tools-9283add2b13b43e50248c612a5b2dfbed9a39903.tar.gz
phosphor-mrw-tools-9283add2b13b43e50248c612a5b2dfbed9a39903.zip
Util: add getEnclosingFru
getEnclosingFru determines the nearest FRU enclosing a given Target. Change-Id: I56533519c053171a98897a67368d1c1ba0d132b6 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'Util.pm')
-rw-r--r--Util.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/Util.pm b/Util.pm
index b9b2aef..050fee6 100644
--- a/Util.pm
+++ b/Util.pm
@@ -97,6 +97,31 @@ sub adjustI2CAddress
return $addr;
}
+#Return nearest FRU enclosing the input target
+# $targets = the Targets object
+# $targetName = the target name
+sub getEnclosingFru
+{
+ my ($targets, $targetName) = @_;
+
+ if (($targetName eq "") || (!defined $targetName))
+ {
+ return "";
+ }
+
+ if (!$targets->isBadAttribute($targetName, "RU_TYPE"))
+ {
+ my $ruType = $targets->getAttribute($targetName, "RU_TYPE");
+ if (($ruType eq "FRU") || ($ruType eq "CRU"))
+ {
+ return $targetName;
+ }
+ }
+
+ my $parent = $targets->getTargetParent($targetName);
+ return getEnclosingFru($targets, $parent);
+}
+
1;
=head1 NAME
@@ -134,6 +159,10 @@ undef if the Target name is not found.
Returns C<I2CAddress> converted from MRW format (8-bit) to the standard 7-bit
format.
+=item getEnclosingFru(C<TargetsObj>, C<Target>)
+
+Finds the nearest FRU enclosing the input Target.
+
=back
=cut
OpenPOWER on IntegriCloud