660989
commit 9415b7449c70f5ea4a0209ddb89c2f5f392d3b4b
660989
Author: Muralidhara M K <muralimk@amd.com>
660989
Date:   Tue Jul 27 06:36:45 2021 -0500
660989
660989
    rasdaemon: ras-mc-ctl: Fix script to parse dimm sizes
660989
    
660989
    Removes trailing spaces at the end of a line from
660989
    file location and fixes --layout option to parse dimm nodes
660989
    to get the size of each dimm from ras-mc-ctl.
660989
    
660989
    Issue is reported https://github.com/mchehab/rasdaemon/issues/43
660989
    Where '> ras-mc-ctl --layout' reports all 0s
660989
    
660989
    With this change the layout option prints the correct dimm sizes
660989
    > sudo ras-mc-ctl --layout
660989
              +-----------------------------------------------+
660989
              |                      mc0                      |
660989
              |  csrow0   |  csrow1   |  csrow2   |  csrow3   |
660989
    ----------+-----------------------------------------------+
660989
    ...
660989
    channel7: |  16384 MB  |     0 MB  |     0 MB  |     0 MB |
660989
    channel6: |  16384 MB  |     0 MB  |     0 MB  |     0 MB |
660989
    ...
660989
    ----------+-----------------------------------------------+
660989
    
660989
    Signed-off-by: Muralidhara M K <muralimk@amd.com>
660989
    Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com>
660989
    Cc: Yazen Ghannam <yazen.ghannam@amd.com>
660989
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
660989
    Link: https://lkml.kernel.org/r/20210810183855.129076-1-nchatrad@amd.com/
660989
660989
diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in
660989
index 1e3aeb7..b22dd60 100755
660989
--- a/util/ras-mc-ctl.in
660989
+++ b/util/ras-mc-ctl.in
660989
@@ -246,6 +246,7 @@ sub parse_dimm_nodes
660989
     if (($file =~ /max_location$/)) {
660989
         open IN, $file;
660989
         my $location = <IN>;
660989
+        $location =~ s/\s+$//;
660989
         close IN;
660989
         my @temp = split(/ /, $location);
660989
 
660989
@@ -288,6 +289,7 @@ sub parse_dimm_nodes
660989
 
660989
         open IN, $file;
660989
         my $location = <IN>;
660989
+        $location =~ s/\s+$//;
660989
         close IN;
660989
 
660989
         my @pos;