diff options
author | Matt Spinler <spinler@us.ibm.com> | 2017-02-08 11:42:51 -0600 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2017-02-08 11:54:36 -0600 |
commit | e3e0b720a06ed8fa8bfec834d597d2010412fbe7 (patch) | |
tree | 95ed140a5fe46d264632b20bc0ddeb52b6ec3f5d | |
parent | 036ab93a055a5e189d1a86ae9db5073dd54e9447 (diff) | |
download | phosphor-mrw-tools-e3e0b720a06ed8fa8bfec834d597d2010412fbe7.tar.gz phosphor-mrw-tools-e3e0b720a06ed8fa8bfec834d597d2010412fbe7.zip |
hwmon.pl remove hwmon entries with no name
It turns out that the MRW XML may have empty HWMON
units, in which case we don't want to show them since
they wouldn't have a label anyway.
Change-Id: If253de98caf4e493ec8112618dc97b43ae911733
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
-rwxr-xr-x | hwmon.pl | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -54,6 +54,10 @@ sub getI2CSensors "unit-hwmon-feature", $chip); + #If the MRW doesn't specify a label for a particular hwmon + #feature, then we don't want to use it. + removeUnusedHwmons(\@hwmonUnits); + #If chip didn't have hwmon units, it isn't hwmon enabled. next unless (scalar @hwmonUnits > 0); @@ -68,6 +72,31 @@ sub getI2CSensors } +#Removes entries from the list of hwmon units passed in that have +#an empty HWMON_NAME or DESCRIPTIVE_NAME attribute. +sub removeUnusedHwmons +{ + my ($units) = @_; + my $i = 0; + + while ($i <= $#$units) { + + my $hwmon = $g_targetObj->getAttributeField($$units[$i], + "HWMON_FEATURE", + "HWMON_NAME"); + my $name = $g_targetObj->getAttributeField($$units[$i], + "HWMON_FEATURE", + "DESCRIPTIVE_NAME"); + if (($hwmon eq "") || ($name eq "")) { + splice(@$units, $i, 1); + } + else { + $i++; + } + } +} + + #Reads the hwmon related attributes from the HWMON_FEATURE #complex attribute and adds them to the hash. sub getHwmonAttributes |