From b8bb2ed4a751516d32373e478e5c9ea9f16b524d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 15 Aug 2013 17:13:43 -0300 Subject: [PATCH 17/32] ras-mc-ctl: Fix the DIMM layout display The items weren't being presented at the right order. Fix it. Signed-off-by: Mauro Carvalho Chehab --- util/ras-mc-ctl.in | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-) diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in index a7137be..196a643 100755 --- a/util/ras-mc-ctl.in +++ b/util/ras-mc-ctl.in @@ -673,15 +673,15 @@ sub register_dimm_labels return 1; } -sub dimm_display_layer($@); +sub dimm_display_layer_rev($@); -sub dimm_display_layer($@) +sub dimm_display_layer_rev($@) { my $layer = shift; my @pos = @_; - $layer--; - if ($layer < 0) { + $layer++; + if ($layer >= scalar(@pos) - 1) { my $str_loc = join(':', @pos); my $size = $dimm_size{$str_loc}; if (!$size) { @@ -695,12 +695,26 @@ sub dimm_display_layer($@) my $s; for (my $i = 0; $i <= $max_pos[$layer]; $i++) { $pos[$layer] = $i; - $s .= dimm_display_layer($layer, @pos); + $s .= dimm_display_layer_rev($layer, @pos); } return $s; } +sub dimm_display_layer(@) +{ + my @pos = @_; + + my $s; + for (my $i = 0; $i <= $max_pos[0]; $i++) { + $pos[0] = $i; + $s .= dimm_display_layer_rev(0, @pos); + } + + return $s; +} + + sub dimm_display_layer_header($$) { my $n_items = 1; @@ -753,7 +767,7 @@ sub dimm_display_mem() my $p1 = length($s) - 1; $pos[scalar(@pos) - 1] = $d; - $s .= dimm_display_layer(scalar(@pos) - 1, @pos); + $s .= dimm_display_layer(@pos); $len += length($s); $sep = "-" x $p1; -- 1.7.1