Skip to content

Commit 1853ee7

Browse files
Robert Richtersuryasaimadhu
authored andcommitted
EDAC/mc: Remove detail[] string and cleanup error string generation
The error descriptor is passed to the error reporting functions, so the error details can be directly generated there. Move string generation from edac_raw_mc_handle_error() to edac_ce_error() and edac_ue_error(). The intermediate detail[] string can be removed then. Also, cleanup the string generation by switching to a single variant only using the ternary operator. [ bp: put ternary operators on a separate line for better readability and use the short-form "inline if" in edac_mc_handle_error(). ] Signed-off-by: Robert Richter <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Aristeu Rozanski <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 6ab7617 commit 1853ee7

File tree

1 file changed

+32
-58
lines changed

1 file changed

+32
-58
lines changed

drivers/edac/edac_mc.c

Lines changed: 32 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -993,27 +993,20 @@ static void edac_inc_ue_error(struct edac_raw_error_desc *e)
993993
}
994994
}
995995

996-
static void edac_ce_error(struct edac_raw_error_desc *e,
997-
const char *detail)
996+
static void edac_ce_error(struct edac_raw_error_desc *e)
998997
{
999998
struct mem_ctl_info *mci = error_desc_to_mci(e);
1000999
unsigned long remapped_page;
1001-
char *msg_aux = "";
1002-
1003-
if (*e->msg)
1004-
msg_aux = " ";
10051000

10061001
if (edac_mc_get_log_ce()) {
1007-
if (e->other_detail && *e->other_detail)
1008-
edac_mc_printk(mci, KERN_WARNING,
1009-
"%d CE %s%son %s (%s %s - %s)\n",
1010-
e->error_count, e->msg, msg_aux, e->label,
1011-
e->location, detail, e->other_detail);
1012-
else
1013-
edac_mc_printk(mci, KERN_WARNING,
1014-
"%d CE %s%son %s (%s %s)\n",
1015-
e->error_count, e->msg, msg_aux, e->label,
1016-
e->location, detail);
1002+
edac_mc_printk(mci, KERN_WARNING,
1003+
"%d CE %s%son %s (%s page:0x%lx offset:0x%lx grain:%ld syndrome:0x%lx%s%s)\n",
1004+
e->error_count, e->msg,
1005+
*e->msg ? " " : "",
1006+
e->label, e->location, e->page_frame_number, e->offset_in_page,
1007+
e->grain, e->syndrome,
1008+
*e->other_detail ? " - " : "",
1009+
e->other_detail);
10171010
}
10181011

10191012
edac_inc_ce_error(e);
@@ -1038,36 +1031,29 @@ static void edac_ce_error(struct edac_raw_error_desc *e,
10381031
}
10391032
}
10401033

1041-
static void edac_ue_error(struct edac_raw_error_desc *e,
1042-
const char *detail)
1034+
static void edac_ue_error(struct edac_raw_error_desc *e)
10431035
{
10441036
struct mem_ctl_info *mci = error_desc_to_mci(e);
1045-
char *msg_aux = "";
1046-
1047-
if (*e->msg)
1048-
msg_aux = " ";
10491037

10501038
if (edac_mc_get_log_ue()) {
1051-
if (e->other_detail && *e->other_detail)
1052-
edac_mc_printk(mci, KERN_WARNING,
1053-
"%d UE %s%son %s (%s %s - %s)\n",
1054-
e->error_count, e->msg, msg_aux, e->label,
1055-
e->location, detail, e->other_detail);
1056-
else
1057-
edac_mc_printk(mci, KERN_WARNING,
1058-
"%d UE %s%son %s (%s %s)\n",
1059-
e->error_count, e->msg, msg_aux, e->label,
1060-
e->location, detail);
1039+
edac_mc_printk(mci, KERN_WARNING,
1040+
"%d UE %s%son %s (%s page:0x%lx offset:0x%lx grain:%ld%s%s)\n",
1041+
e->error_count, e->msg,
1042+
*e->msg ? " " : "",
1043+
e->label, e->location, e->page_frame_number, e->offset_in_page,
1044+
e->grain,
1045+
*e->other_detail ? " - " : "",
1046+
e->other_detail);
10611047
}
10621048

10631049
if (edac_mc_get_panic_on_ue()) {
1064-
if (e->other_detail && *e->other_detail)
1065-
panic("UE %s%son %s (%s%s - %s)\n",
1066-
e->msg, msg_aux, e->label, e->location, detail,
1067-
e->other_detail);
1068-
else
1069-
panic("UE %s%son %s (%s%s)\n",
1070-
e->msg, msg_aux, e->label, e->location, detail);
1050+
panic("UE %s%son %s (%s page:0x%lx offset:0x%lx grain:%ld%s%s)\n",
1051+
e->msg,
1052+
*e->msg ? " " : "",
1053+
e->label, e->location, e->page_frame_number, e->offset_in_page,
1054+
e->grain,
1055+
*e->other_detail ? " - " : "",
1056+
e->other_detail);
10711057
}
10721058

10731059
edac_inc_ue_error(e);
@@ -1096,7 +1082,6 @@ static void edac_inc_csrow(struct edac_raw_error_desc *e, int row, int chan)
10961082
void edac_raw_mc_handle_error(struct edac_raw_error_desc *e)
10971083
{
10981084
struct mem_ctl_info *mci = error_desc_to_mci(e);
1099-
char detail[80];
11001085
u8 grain_bits;
11011086

11021087
/* Sanity-check driver-supplied grain value. */
@@ -1113,22 +1098,10 @@ void edac_raw_mc_handle_error(struct edac_raw_error_desc *e)
11131098
(e->page_frame_number << PAGE_SHIFT) | e->offset_in_page,
11141099
grain_bits, e->syndrome, e->other_detail);
11151100

1116-
/* Memory type dependent details about the error */
1117-
if (e->type == HW_EVENT_ERR_CORRECTED) {
1118-
snprintf(detail, sizeof(detail),
1119-
"page:0x%lx offset:0x%lx grain:%ld syndrome:0x%lx",
1120-
e->page_frame_number, e->offset_in_page,
1121-
e->grain, e->syndrome);
1122-
edac_ce_error(e, detail);
1123-
} else {
1124-
snprintf(detail, sizeof(detail),
1125-
"page:0x%lx offset:0x%lx grain:%ld",
1126-
e->page_frame_number, e->offset_in_page, e->grain);
1127-
1128-
edac_ue_error(e, detail);
1129-
}
1130-
1131-
1101+
if (e->type == HW_EVENT_ERR_CORRECTED)
1102+
edac_ce_error(e);
1103+
else
1104+
edac_ue_error(e);
11321105
}
11331106
EXPORT_SYMBOL_GPL(edac_raw_mc_handle_error);
11341107

@@ -1164,8 +1137,9 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,
11641137
e->page_frame_number = page_frame_number;
11651138
e->offset_in_page = offset_in_page;
11661139
e->syndrome = syndrome;
1167-
e->msg = msg;
1168-
e->other_detail = other_detail;
1140+
/* need valid strings here for both: */
1141+
e->msg = msg ?: "";
1142+
e->other_detail = other_detail ?: "";
11691143

11701144
/*
11711145
* Check if the event report is consistent and if the memory location is

0 commit comments

Comments
 (0)