Remove module card segment from the inventory path

The MRW doesn't plug a processor directly on the
motherboard, there is an intermediate module card
present instead.  We don't need that intermediate
card so shorten motherboard/cpu-module/cpu to
motherboard-cpu.

Change-Id: Iaf5b617f32dbf3df25de99a3be6103f961e90c1b
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/Inventory.pm b/Inventory.pm
index dc8fba4..91ed2b6 100644
--- a/Inventory.pm
+++ b/Inventory.pm
@@ -113,6 +113,8 @@
     #Remove connector segments from the OBMC_NAME
     removeConnectors($targetObj, $inventory);
 
+    #Don't need the card instance of a PROC/GPU module
+    removeModuleFromPath($targetObj, $inventory);
 }
 
 
@@ -150,6 +152,34 @@
     }
 }
 
+
+#Removes the card portion of a module from OBMC_NAME.
+#For example, .../motherboard-0/module-1/proc-0 ->
+#.../motherboard-0/proc-1.
+#This needs to be revisited if multi-processor modules
+#ever come into plan.
+sub removeModuleFromPath
+{
+    my ($targetObj, $inventory) = @_;
+    my %chipNames;
+
+    #Find the names of the chips on the modules
+    for my $item (@$inventory) {
+        if (exists $MODULE_TYPES{$targetObj->getType($item->{TARGET})}) {
+            $chipNames{$targetObj->getInstanceName($item->{TARGET})} = 1;
+        }
+    }
+
+    #Now convert module-A/name-B to name-A
+    #Note that the -B isn't always present
+    for my $item (@$inventory) {
+
+        for my $name (keys %chipNames) {
+            $item->{OBMC_NAME} =~ s/\w+-(\d+)\/$name(-\d+)*/$name-$1/;
+        }
+    }
+}
+
 1;
 
 =head1 NAME