Blame SOURCES/0014-ras-mc-ctl-Fix-label-register-with-2-layers.patch

ac32bf
From 0d53728f9cbdca5a1bd32c51a121dd1162f50e95 Mon Sep 17 00:00:00 2001
ac32bf
From: Mauro Carvalho Chehab <m.chehab@samsung.com>
ac32bf
Date: Thu, 15 Aug 2013 12:45:18 -0300
ac32bf
Subject: [PATCH 14/32] ras-mc-ctl: Fix label register with 2 layers
ac32bf
ac32bf
When there aren't 3 layers, label print/register weren't working.
ac32bf
ac32bf
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
ac32bf
---
ac32bf
 util/ras-mc-ctl.in |   19 +++++++++++++------
ac32bf
 1 files changed, 13 insertions(+), 6 deletions(-)
ac32bf
ac32bf
diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in
ac32bf
index f5a8ce5..a7137be 100755
ac32bf
--- a/util/ras-mc-ctl.in
ac32bf
+++ b/util/ras-mc-ctl.in
ac32bf
@@ -508,7 +508,6 @@ sub parse_dimm_labels_file
ac32bf
                     }
ac32bf
                     map { $lh->{$vendor}{lc $_}{$mc}{$top}{$mid}{$low} = $label }
ac32bf
                             @models;
ac32bf
-                        $n = 3;
ac32bf
                 }
ac32bf
                 if (!$num) {
ac32bf
                         $num = $n;
ac32bf
@@ -542,9 +541,13 @@ sub parse_dimm_labels
ac32bf
 
ac32bf
 sub read_dimm_label
ac32bf
 {
ac32bf
-    my ($mc, $top, $mid, $low) = @_;
ac32bf
+    my ($num_layers, $mc, $top, $mid, $low) = @_;
ac32bf
     my $sysfs = "/sys/devices/system/edac/mc";
ac32bf
-    my $pos = "$mc:$top:$mid:$low";
ac32bf
+    my $pos;
ac32bf
+
ac32bf
+    $pos = "$mc:$top:$mid:$low" if ($num_layers == 3);
ac32bf
+    $pos = "$mc:$top:$mid" if ($num_layers == 2);
ac32bf
+    $pos = "$mc:$top" if ($num_layers == 1);
ac32bf
 
ac32bf
     if (!defined($dimm_node{$pos})) {
ac32bf
         my $label = "$pos missing";
ac32bf
@@ -574,10 +577,14 @@ sub read_dimm_label
ac32bf
 
ac32bf
 sub get_dimm_label_node
ac32bf
 {
ac32bf
-    my ($mc, $top, $mid, $low) = @_;
ac32bf
+    my ($num_layers, $mc, $top, $mid, $low) = @_;
ac32bf
     my $sysfs = "/sys/devices/system/edac/mc";
ac32bf
     my $pos = "$mc:$top:$mid:$low";
ac32bf
 
ac32bf
+    $pos = "$mc:$top:$mid:$low" if ($num_layers == 3);
ac32bf
+    $pos = "$mc:$top:$mid" if ($num_layers == 2);
ac32bf
+    $pos = "$mc:$top" if ($num_layers == 1);
ac32bf
+
ac32bf
     return "" if (!defined($dimm_node{$pos}));
ac32bf
 
ac32bf
     my $dimm = $dimm_node{$pos};
ac32bf
@@ -611,7 +618,7 @@ sub print_dimm_labels
ac32bf
             for my $mid (sort keys %{$$lref{$vendor}{$model}{$mc}{$top}}) {
ac32bf
                 for my $low (sort keys %{$$lref{$vendor}{$model}{$mc}{$top}{$mid}}) {
ac32bf
                     my $label = $$lref{$vendor}{$model}{$mc}{$top}{$mid}{$low};
ac32bf
-                    my ($rlabel,$loc) = read_dimm_label ($mc, $top, $mid, $low);
ac32bf
+                    my ($rlabel,$loc) = read_dimm_label ($$num_layers{$vendor}{$model}, $mc, $top, $mid, $low);
ac32bf
 
ac32bf
                     printf $fh $format, $loc, $label, $rlabel;
ac32bf
                 }
ac32bf
@@ -645,7 +652,7 @@ sub register_dimm_labels
ac32bf
             for my $mid (sort keys %{$$lref{$vendor}{$model}{$mc}{$top}}) {
ac32bf
                 for my $low (sort keys %{$$lref{$vendor}{$model}{$mc}{$top}{$mid}}) {
ac32bf
 
ac32bf
-                    my $file = get_dimm_label_node($mc, $top, $mid, $low);
ac32bf
+                    my $file = get_dimm_label_node($$num_layers{$vendor}{$model}, $mc, $top, $mid, $low);
ac32bf
 
ac32bf
                     # Ignore sysfs files that don't exist. Might just be
ac32bf
                     #  unpopulated bank.
ac32bf
-- 
ac32bf
1.7.1
ac32bf