[PATCH 11/25] x86/MCE/AMD: Simplify function parameters

From: Yazen Ghannam
Date: Fri May 07 2021 - 15:02:35 EST


From: Yazen Ghannam <yazen.ghannam@xxxxxxx>

Use a single address parameter for input and result to reduce the number
of parameters.

Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
---
arch/x86/include/asm/mce.h | 5 ++---
arch/x86/kernel/cpu/mce/amd.c | 6 +++---
drivers/edac/amd64_edac.c | 4 ++--
3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index ddfb3cad8dff..991ba48a4c0c 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -351,7 +351,7 @@ extern int mce_threshold_create_device(unsigned int cpu);
extern int mce_threshold_remove_device(unsigned int cpu);

void mce_amd_feature_init(struct cpuinfo_x86 *c);
-int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr);
+int umc_normaddr_to_sysaddr(u64 *addr, u16 nid, u8 umc);

#else

@@ -359,8 +359,7 @@ static inline int mce_threshold_create_device(unsigned int cpu) { return 0; };
static inline int mce_threshold_remove_device(unsigned int cpu) { return 0; };
static inline bool amd_mce_is_memory_error(struct mce *m) { return false; };
static inline void mce_amd_feature_init(struct cpuinfo_x86 *c) { }
-static inline int
-umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { return -EINVAL; };
+static inline int umc_normaddr_to_sysaddr(u64 *addr, u16 nid, u8 umc) { return -EINVAL; };
#endif

static inline void mce_hygon_feature_init(struct cpuinfo_x86 *c) { return mce_amd_feature_init(c); }
diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index d51ec5c2f319..58899c57eb76 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -997,14 +997,14 @@ static int addr_over_limit(struct addr_ctx *ctx)
return 0;
}

-int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr)
+int umc_normaddr_to_sysaddr(u64 *addr, u16 nid, u8 umc)
{
struct addr_ctx ctx;

memset(&ctx, 0, sizeof(ctx));

/* We start from the normalized address */
- ctx.ret_addr = norm_addr;
+ ctx.ret_addr = *addr;

ctx.nid = nid;
ctx.umc = umc;
@@ -1032,7 +1032,7 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr)
if (addr_over_limit(&ctx))
return -EINVAL;

- *sys_addr = ctx.ret_addr;
+ *addr = ctx.ret_addr;
return 0;
}
EXPORT_SYMBOL_GPL(umc_normaddr_to_sysaddr);
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 9fa4dfc6ebee..dc4a642d5d7c 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -2896,7 +2896,7 @@ static void decode_umc_error(int node_id, struct mce *m)
struct mem_ctl_info *mci;
struct amd64_pvt *pvt;
struct err_info err;
- u64 sys_addr;
+ u64 sys_addr = m->addr;

mci = edac_mc_find(node_id);
if (!mci)
@@ -2927,7 +2927,7 @@ static void decode_umc_error(int node_id, struct mce *m)

err.csrow = m->synd & 0x7;

- if (umc_normaddr_to_sysaddr(m->addr, pvt->mc_node_id, err.channel, &sys_addr)) {
+ if (umc_normaddr_to_sysaddr(&sys_addr, pvt->mc_node_id, err.channel)) {
err.err_code = ERR_NORM_ADDR;
goto log_error;
}
--
2.25.1