Blob Blame History Raw
From 0d53728f9cbdca5a1bd32c51a121dd1162f50e95 Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <m.chehab@samsung.com>
Date: Thu, 15 Aug 2013 12:45:18 -0300
Subject: [PATCH 14/32] ras-mc-ctl: Fix label register with 2 layers

When there aren't 3 layers, label print/register weren't working.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
---
 util/ras-mc-ctl.in |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in
index f5a8ce5..a7137be 100755
--- a/util/ras-mc-ctl.in
+++ b/util/ras-mc-ctl.in
@@ -508,7 +508,6 @@ sub parse_dimm_labels_file
                     }
                     map { $lh->{$vendor}{lc $_}{$mc}{$top}{$mid}{$low} = $label }
                             @models;
-                        $n = 3;
                 }
                 if (!$num) {
                         $num = $n;
@@ -542,9 +541,13 @@ sub parse_dimm_labels
 
 sub read_dimm_label
 {
-    my ($mc, $top, $mid, $low) = @_;
+    my ($num_layers, $mc, $top, $mid, $low) = @_;
     my $sysfs = "/sys/devices/system/edac/mc";
-    my $pos = "$mc:$top:$mid:$low";
+    my $pos;
+
+    $pos = "$mc:$top:$mid:$low" if ($num_layers == 3);
+    $pos = "$mc:$top:$mid" if ($num_layers == 2);
+    $pos = "$mc:$top" if ($num_layers == 1);
 
     if (!defined($dimm_node{$pos})) {
         my $label = "$pos missing";
@@ -574,10 +577,14 @@ sub read_dimm_label
 
 sub get_dimm_label_node
 {
-    my ($mc, $top, $mid, $low) = @_;
+    my ($num_layers, $mc, $top, $mid, $low) = @_;
     my $sysfs = "/sys/devices/system/edac/mc";
     my $pos = "$mc:$top:$mid:$low";
 
+    $pos = "$mc:$top:$mid:$low" if ($num_layers == 3);
+    $pos = "$mc:$top:$mid" if ($num_layers == 2);
+    $pos = "$mc:$top" if ($num_layers == 1);
+
     return "" if (!defined($dimm_node{$pos}));
 
     my $dimm = $dimm_node{$pos};
@@ -611,7 +618,7 @@ sub print_dimm_labels
             for my $mid (sort keys %{$$lref{$vendor}{$model}{$mc}{$top}}) {
                 for my $low (sort keys %{$$lref{$vendor}{$model}{$mc}{$top}{$mid}}) {
                     my $label = $$lref{$vendor}{$model}{$mc}{$top}{$mid}{$low};
-                    my ($rlabel,$loc) = read_dimm_label ($mc, $top, $mid, $low);
+                    my ($rlabel,$loc) = read_dimm_label ($$num_layers{$vendor}{$model}, $mc, $top, $mid, $low);
 
                     printf $fh $format, $loc, $label, $rlabel;
                 }
@@ -645,7 +652,7 @@ sub register_dimm_labels
             for my $mid (sort keys %{$$lref{$vendor}{$model}{$mc}{$top}}) {
                 for my $low (sort keys %{$$lref{$vendor}{$model}{$mc}{$top}{$mid}}) {
 
-                    my $file = get_dimm_label_node($mc, $top, $mid, $low);
+                    my $file = get_dimm_label_node($$num_layers{$vendor}{$model}, $mc, $top, $mid, $low);
 
                     # Ignore sysfs files that don't exist. Might just be
                     #  unpopulated bank.
-- 
1.7.1