Skip to content

Commit 8601ca2

Browse files
aeglcasparant
authored andcommitted
EDAC, skx_common: Refactor so that we initialize "dev" in result of adxl decode.
fix #29902604 commit 29b8e84 upstream Simplifies the code a little. Acked-by: Aristeu Rozanski <aris@redhat.com> Signed-off-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
1 parent 6d91d57 commit 8601ca2

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

drivers/edac/skx_common.c

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ void __exit skx_adxl_put(void)
101101

102102
static bool skx_adxl_decode(struct decoded_addr *res)
103103
{
104+
struct skx_dev *d;
104105
int i, len = 0;
105106

106107
if (res->addr >= skx_tohm || (res->addr >= skx_tolm &&
@@ -119,6 +120,24 @@ static bool skx_adxl_decode(struct decoded_addr *res)
119120
res->channel = (int)adxl_values[component_indices[INDEX_CHANNEL]];
120121
res->dimm = (int)adxl_values[component_indices[INDEX_DIMM]];
121122

123+
if (res->imc > NUM_IMC - 1) {
124+
skx_printk(KERN_ERR, "Bad imc %d\n", res->imc);
125+
return false;
126+
}
127+
128+
list_for_each_entry(d, &dev_edac_list, list) {
129+
if (d->imc[0].src_id == res->socket) {
130+
res->dev = d;
131+
break;
132+
}
133+
}
134+
135+
if (!res->dev) {
136+
skx_printk(KERN_ERR, "No device for src_id %d imc %d\n",
137+
res->socket, res->imc);
138+
return false;
139+
}
140+
122141
for (i = 0; i < adxl_component_count; i++) {
123142
if (adxl_values[i] == ~0x0ull)
124143
continue;
@@ -453,24 +472,6 @@ static void skx_unregister_mci(struct skx_imc *imc)
453472
edac_mc_free(mci);
454473
}
455474

456-
static struct mem_ctl_info *get_mci(int src_id, int lmc)
457-
{
458-
struct skx_dev *d;
459-
460-
if (lmc > NUM_IMC - 1) {
461-
skx_printk(KERN_ERR, "Bad lmc %d\n", lmc);
462-
return NULL;
463-
}
464-
465-
list_for_each_entry(d, &dev_edac_list, list) {
466-
if (d->imc[0].src_id == src_id)
467-
return d->imc[lmc].mci;
468-
}
469-
470-
skx_printk(KERN_ERR, "No mci for src_id %d lmc %d\n", src_id, lmc);
471-
return NULL;
472-
}
473-
474475
static void skx_mce_output_error(struct mem_ctl_info *mci,
475476
const struct mce *m,
476477
struct decoded_addr *res)
@@ -591,15 +592,12 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,
591592
if (adxl_component_count) {
592593
if (!skx_adxl_decode(&res))
593594
return NOTIFY_DONE;
594-
595-
mci = get_mci(res.socket, res.imc);
596-
} else {
597-
if (!skx_decode || !skx_decode(&res))
598-
return NOTIFY_DONE;
599-
600-
mci = res.dev->imc[res.imc].mci;
595+
} else if (!skx_decode || !skx_decode(&res)) {
596+
return NOTIFY_DONE;
601597
}
602598

599+
mci = res.dev->imc[res.imc].mci;
600+
603601
if (!mci)
604602
return NOTIFY_DONE;
605603

0 commit comments

Comments
 (0)