Commit 239642fe19adc19ba0a69e96f3b1904dfd6a3b9f

Authored by Borislav Petkov
1 parent cec7924f56

edac: add memory types strings for debugging

Instead of using deeply-nested conditionals for dumping the DIMM type in
debug mode, add a strings array of the supported DIMM types.

This is useful in cases where an edac driver supports multiple DRAM
types and is only defined in debug builds.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>

Showing 3 changed files with 26 additions and 4 deletions Side-by-side Diff

drivers/edac/amd64_edac.c
... ... @@ -1024,10 +1024,7 @@
1024 1024 type = (pvt->dclr0 & BIT(18)) ? MEM_DDR : MEM_RDDR;
1025 1025 }
1026 1026  
1027   - debugf1(" Memory type is: %s\n",
1028   - (type == MEM_DDR2) ? "MEM_DDR2" :
1029   - (type == MEM_RDDR2) ? "MEM_RDDR2" :
1030   - (type == MEM_DDR) ? "MEM_DDR" : "MEM_RDDR");
  1027 + debugf1(" Memory type is: %s\n", edac_mem_types[type]);
1031 1028  
1032 1029 return type;
1033 1030 }
drivers/edac/edac_core.h
... ... @@ -74,6 +74,7 @@
74 74  
75 75 #ifdef CONFIG_EDAC_DEBUG
76 76 extern int edac_debug_level;
  77 +extern const char *edac_mem_types[];
77 78  
78 79 #ifndef CONFIG_EDAC_DEBUG_VERBOSE
79 80 #define edac_debug_printk(level, fmt, arg...) \
drivers/edac/edac_mc.c
... ... @@ -76,6 +76,30 @@
76 76 debugf3("\tpvt_info = %p\n\n", mci->pvt_info);
77 77 }
78 78  
  79 +/*
  80 + * keep those in sync with the enum mem_type
  81 + */
  82 +const char *edac_mem_types[] = {
  83 + "Empty csrow",
  84 + "Reserved csrow type",
  85 + "Unknown csrow type",
  86 + "Fast page mode RAM",
  87 + "Extended data out RAM",
  88 + "Burst Extended data out RAM",
  89 + "Single data rate SDRAM",
  90 + "Registered single data rate SDRAM",
  91 + "Double data rate SDRAM",
  92 + "Registered Double data rate SDRAM",
  93 + "Rambus DRAM",
  94 + "Unbuffered DDR2 RAM",
  95 + "Fully buffered DDR2",
  96 + "Registered DDR2 RAM",
  97 + "Rambus XDR",
  98 + "Unbuffered DDR3 RAM",
  99 + "Registered DDR3 RAM",
  100 +};
  101 +EXPORT_SYMBOL_GPL(edac_mem_types);
  102 +
79 103 #endif /* CONFIG_EDAC_DEBUG */
80 104  
81 105 /* 'ptr' points to a possibly unaligned item X such that sizeof(X) is 'size'.