From b0a9c5ccf31514630755e9a5d15204a55a47740f Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Fri, 7 Oct 2011 23:01:55 +0200 Subject: mptable: Refactor mptable generation some more The last couple of lines of every mptable function were mostly identical. Refactor into common code, a new function mptable_finalize. Coccinelle script: @@ identifier mc; @@ ( -mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); -mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); -printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", mc, smp_next_mpe_entry(mc)); -return smp_next_mpe_entry(mc); +return mptable_finalize(mc); | -mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); -mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); -return smp_next_mpe_entry(mc); +return mptable_finalize(mc); ) Change-Id: Ib2270d800bdd486c5eb49b328544d36bd2298c9e Signed-off-by: Patrick Georgi Reviewed-on: http://review.coreboot.org/246 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones --- src/mainboard/amd/bimini_fam10/mptable.c | 7 +------ src/mainboard/amd/dbm690t/mptable.c | 7 +------ src/mainboard/amd/inagua/mptable.c | 7 +------ src/mainboard/amd/mahogany/mptable.c | 7 +------ src/mainboard/amd/mahogany_fam10/mptable.c | 7 +------ src/mainboard/amd/persimmon/mptable.c | 7 +------ src/mainboard/amd/pistachio/mptable.c | 7 +------ src/mainboard/amd/serengeti_cheetah/mptable.c | 6 +----- src/mainboard/amd/serengeti_cheetah_fam10/mptable.c | 6 +----- src/mainboard/amd/tilapia_fam10/mptable.c | 7 +------ src/mainboard/amd/torpedo/mptable.c | 7 +------ 11 files changed, 11 insertions(+), 64 deletions(-) (limited to 'src/mainboard/amd') diff --git a/src/mainboard/amd/bimini_fam10/mptable.c b/src/mainboard/amd/bimini_fam10/mptable.c index 65852af366..2ab3f24ee9 100644 --- a/src/mainboard/amd/bimini_fam10/mptable.c +++ b/src/mainboard/amd/bimini_fam10/mptable.c @@ -144,12 +144,7 @@ static void *smp_write_config_table(void *v) /* There is no extension information... */ /* Compute the checksums */ - mc->mpe_checksum = - smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); - mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); - printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", - mc, smp_next_mpe_entry(mc)); - return smp_next_mpe_entry(mc); + return mptable_finalize(mc); } unsigned long write_smp_table(unsigned long addr) diff --git a/src/mainboard/amd/dbm690t/mptable.c b/src/mainboard/amd/dbm690t/mptable.c index 6d2c53502d..901591adbb 100644 --- a/src/mainboard/amd/dbm690t/mptable.c +++ b/src/mainboard/amd/dbm690t/mptable.c @@ -154,12 +154,7 @@ static void *smp_write_config_table(void *v) /* There is no extension information... */ /* Compute the checksums */ - mc->mpe_checksum = - smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); - mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); - printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", - mc, smp_next_mpe_entry(mc)); - return smp_next_mpe_entry(mc); + return mptable_finalize(mc); } unsigned long write_smp_table(unsigned long addr) diff --git a/src/mainboard/amd/inagua/mptable.c b/src/mainboard/amd/inagua/mptable.c index 1fc69cb00c..fa7de7d122 100644 --- a/src/mainboard/amd/inagua/mptable.c +++ b/src/mainboard/amd/inagua/mptable.c @@ -229,12 +229,7 @@ static void *smp_write_config_table(void *v) /* There is no extension information... */ /* Compute the checksums */ - mc->mpe_checksum = - smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); - mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); - printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", - mc, smp_next_mpe_entry(mc)); - return smp_next_mpe_entry(mc); + return mptable_finalize(mc); } unsigned long write_smp_table(unsigned long addr) diff --git a/src/mainboard/amd/mahogany/mptable.c b/src/mainboard/amd/mahogany/mptable.c index e31bce77cc..f79a5791ab 100644 --- a/src/mainboard/amd/mahogany/mptable.c +++ b/src/mainboard/amd/mahogany/mptable.c @@ -161,12 +161,7 @@ static void *smp_write_config_table(void *v) /* There is no extension information... */ /* Compute the checksums */ - mc->mpe_checksum = - smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); - mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); - printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", - mc, smp_next_mpe_entry(mc)); - return smp_next_mpe_entry(mc); + return mptable_finalize(mc); } unsigned long write_smp_table(unsigned long addr) diff --git a/src/mainboard/amd/mahogany_fam10/mptable.c b/src/mainboard/amd/mahogany_fam10/mptable.c index 024e87a015..4bf3480fcf 100644 --- a/src/mainboard/amd/mahogany_fam10/mptable.c +++ b/src/mainboard/amd/mahogany_fam10/mptable.c @@ -160,12 +160,7 @@ static void *smp_write_config_table(void *v) /* There is no extension information... */ /* Compute the checksums */ - mc->mpe_checksum = - smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); - mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); - printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", - mc, smp_next_mpe_entry(mc)); - return smp_next_mpe_entry(mc); + return mptable_finalize(mc); } unsigned long write_smp_table(unsigned long addr) diff --git a/src/mainboard/amd/persimmon/mptable.c b/src/mainboard/amd/persimmon/mptable.c index 3e57ea03db..a3b4b5c95e 100644 --- a/src/mainboard/amd/persimmon/mptable.c +++ b/src/mainboard/amd/persimmon/mptable.c @@ -147,12 +147,7 @@ static void *smp_write_config_table(void *v) /* There is no extension information... */ /* Compute the checksums */ - mc->mpe_checksum = - smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); - mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); - printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", - mc, smp_next_mpe_entry(mc)); - return smp_next_mpe_entry(mc); + return mptable_finalize(mc); } unsigned long write_smp_table(unsigned long addr) diff --git a/src/mainboard/amd/pistachio/mptable.c b/src/mainboard/amd/pistachio/mptable.c index 6d2c53502d..901591adbb 100644 --- a/src/mainboard/amd/pistachio/mptable.c +++ b/src/mainboard/amd/pistachio/mptable.c @@ -154,12 +154,7 @@ static void *smp_write_config_table(void *v) /* There is no extension information... */ /* Compute the checksums */ - mc->mpe_checksum = - smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); - mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); - printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", - mc, smp_next_mpe_entry(mc)); - return smp_next_mpe_entry(mc); + return mptable_finalize(mc); } unsigned long write_smp_table(unsigned long addr) diff --git a/src/mainboard/amd/serengeti_cheetah/mptable.c b/src/mainboard/amd/serengeti_cheetah/mptable.c index 71e2d0e9b9..ebd4cbc60f 100644 --- a/src/mainboard/amd/serengeti_cheetah/mptable.c +++ b/src/mainboard/amd/serengeti_cheetah/mptable.c @@ -159,11 +159,7 @@ static void *smp_write_config_table(void *v) /* There is no extension information... */ /* Compute the checksums */ - mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); - mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); - printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", - mc, smp_next_mpe_entry(mc)); - return smp_next_mpe_entry(mc); + return mptable_finalize(mc); } unsigned long write_smp_table(unsigned long addr) diff --git a/src/mainboard/amd/serengeti_cheetah_fam10/mptable.c b/src/mainboard/amd/serengeti_cheetah_fam10/mptable.c index d3ebafb9d9..d527f9c505 100644 --- a/src/mainboard/amd/serengeti_cheetah_fam10/mptable.c +++ b/src/mainboard/amd/serengeti_cheetah_fam10/mptable.c @@ -183,11 +183,7 @@ static void *smp_write_config_table(void *v) /* There is no extension information... */ /* Compute the checksums */ - mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); - mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); - printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", - mc, smp_next_mpe_entry(mc)); - return smp_next_mpe_entry(mc); + return mptable_finalize(mc); } unsigned long write_smp_table(unsigned long addr) diff --git a/src/mainboard/amd/tilapia_fam10/mptable.c b/src/mainboard/amd/tilapia_fam10/mptable.c index 024e87a015..4bf3480fcf 100644 --- a/src/mainboard/amd/tilapia_fam10/mptable.c +++ b/src/mainboard/amd/tilapia_fam10/mptable.c @@ -160,12 +160,7 @@ static void *smp_write_config_table(void *v) /* There is no extension information... */ /* Compute the checksums */ - mc->mpe_checksum = - smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); - mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); - printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", - mc, smp_next_mpe_entry(mc)); - return smp_next_mpe_entry(mc); + return mptable_finalize(mc); } unsigned long write_smp_table(unsigned long addr) diff --git a/src/mainboard/amd/torpedo/mptable.c b/src/mainboard/amd/torpedo/mptable.c index 91213d86c3..03812060c8 100755 --- a/src/mainboard/amd/torpedo/mptable.c +++ b/src/mainboard/amd/torpedo/mptable.c @@ -236,12 +236,7 @@ static void *smp_write_config_table(void *v) /* There is no extension information... */ /* Compute the checksums */ - mc->mpe_checksum = - smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); - mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); - printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", - mc, smp_next_mpe_entry(mc)); - return smp_next_mpe_entry(mc); + return mptable_finalize(mc); } unsigned long write_smp_table(unsigned long addr) -- cgit v1.2.3