EDAC/mc: Carve out error increment into a separate function
authorRobert Richter <rrichter@marvell.com>
Fri, 14 Feb 2020 14:17:56 +0000 (15:17 +0100)
committerBorislav Petkov <bp@suse.de>
Mon, 17 Feb 2020 12:07:50 +0000 (13:07 +0100)
Carve out the error_count increment into a separate function
edac_inc_csrow(). This better separates code and reduces the indentation
level.

Implementation note: The function edac_inc_csrow() counts the same
as before, ->ce_count is only incremented if row >= 0. This is esp.
true for the case of (!e->enable_per_layer_report). Here, a DIMM was
not found, variable row still has a value of -1 and ->ce_count is not
incremented.

 [ bp: Massage commit message. ]

Signed-off-by: Robert Richter <rrichter@marvell.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Acked-by: Aristeu Rozanski <aris@redhat.com>
Link: https://lkml.kernel.org/r/20200214141757.8976-1-rrichter@marvell.com
drivers/edac/edac_mc.c

index bc8d1d7b21a0c072d4685226f12b44893fa8dede..35d2824925051d6fccfc15c1a7ac7dd15cb3850e 100644 (file)
@@ -1089,6 +1089,26 @@ static void edac_ue_error(struct mem_ctl_info *mci,
        edac_inc_ue_error(mci, enable_per_layer_report, pos, error_count);
 }
 
+static void edac_inc_csrow(struct edac_raw_error_desc *e, int row, int chan)
+{
+       struct mem_ctl_info *mci = error_desc_to_mci(e);
+       enum hw_event_mc_err_type type = e->type;
+       u16 count = e->error_count;
+
+       if (row < 0)
+               return;
+
+       edac_dbg(4, "csrow/channel to increment: (%d,%d)\n", row, chan);
+
+       if (type == HW_EVENT_ERR_CORRECTED) {
+               mci->csrows[row]->ce_count += count;
+               if (chan >= 0)
+                       mci->csrows[row]->channels[chan]->ce_count += count;
+       } else {
+               mci->csrows[row]->ue_count += count;
+       }
+}
+
 void edac_raw_mc_handle_error(struct edac_raw_error_desc *e)
 {
        struct mem_ctl_info *mci = error_desc_to_mci(e);
@@ -1256,22 +1276,12 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,
                        chan = -2;
        }
 
-       if (!e->enable_per_layer_report) {
+       if (!e->enable_per_layer_report)
                strcpy(e->label, "any memory");
-       } else {
-               edac_dbg(4, "csrow/channel to increment: (%d,%d)\n", row, chan);
-               if (p == e->label)
-                       strcpy(e->label, "unknown memory");
-               if (type == HW_EVENT_ERR_CORRECTED) {
-                       if (row >= 0) {
-                               mci->csrows[row]->ce_count += error_count;
-                               if (chan >= 0)
-                                       mci->csrows[row]->channels[chan]->ce_count += error_count;
-                       }
-               } else
-                       if (row >= 0)
-                               mci->csrows[row]->ue_count += error_count;
-       }
+       else if (!*e->label)
+               strcpy(e->label, "unknown memory");
+
+       edac_inc_csrow(e, row, chan);
 
        /* Fill the RAM location data */
        p = e->location;