diff mbox

[U-Boot,v2,11/18] x86: acpi: Remove header length check when writing tables

Message ID 1462977912-13666-12-git-send-email-bmeng.cn@gmail.com
State Accepted
Commit 10fcabed8857d2c12a5806c68cf884802f975aae
Delegated to: Bin Meng
Headers show

Commit Message

Bin Meng May 11, 2016, 2:45 p.m. UTC
Before moving 'current' pointer during ACPI table writing, we always
check the table length to see if it is larger than the table header.
Since our purpose is to generate valid tables, the check logic is
always true, which can be avoided.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

---

Changes in v2:
- New patch to remove header length check when writing tables

 arch/x86/lib/acpi_table.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

Comments

Simon Glass May 19, 2016, 4 a.m. UTC | #1
On 11 May 2016 at 08:45, Bin Meng <bmeng.cn@gmail.com> wrote:
> Before moving 'current' pointer during ACPI table writing, we always
> check the table length to see if it is larger than the table header.
> Since our purpose is to generate valid tables, the check logic is
> always true, which can be avoided.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>
> ---
>
> Changes in v2:
> - New patch to remove header length check when writing tables
>
>  arch/x86/lib/acpi_table.c | 26 ++++++++++----------------
>  1 file changed, 10 insertions(+), 16 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Bin Meng May 23, 2016, 7:01 a.m. UTC | #2
On Thu, May 19, 2016 at 12:00 PM, Simon Glass <sjg@chromium.org> wrote:
> On 11 May 2016 at 08:45, Bin Meng <bmeng.cn@gmail.com> wrote:
>> Before moving 'current' pointer during ACPI table writing, we always
>> check the table length to see if it is larger than the table header.
>> Since our purpose is to generate valid tables, the check logic is
>> always true, which can be avoided.
>>
>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>>
>> ---
>>
>> Changes in v2:
>> - New patch to remove header length check when writing tables
>>
>>  arch/x86/lib/acpi_table.c | 26 ++++++++++----------------
>>  1 file changed, 10 insertions(+), 16 deletions(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>

applied to u-boot-x86, thanks!
diff mbox

Patch

diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index 05c958d..f959f5d 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -376,13 +376,11 @@  u32 write_acpi_tables(u32 start)
 	debug("ACPI:    * DSDT\n");
 	dsdt = (struct acpi_table_header *)current;
 	memcpy(dsdt, &AmlCode, sizeof(struct acpi_table_header));
-	if (dsdt->length >= sizeof(struct acpi_table_header)) {
-		current += sizeof(struct acpi_table_header);
-		memcpy((char *)current,
-			(char *)&AmlCode + sizeof(struct acpi_table_header),
-			dsdt->length - sizeof(struct acpi_table_header));
-		current += dsdt->length - sizeof(struct acpi_table_header);
-	}
+	current += sizeof(struct acpi_table_header);
+	memcpy((char *)current,
+	       (char *)&AmlCode + sizeof(struct acpi_table_header),
+	       dsdt->length - sizeof(struct acpi_table_header));
+	current += dsdt->length - sizeof(struct acpi_table_header);
 	current = ALIGN(current, 16);
 
 	debug("ACPI:    * FADT\n");
@@ -395,20 +393,16 @@  u32 write_acpi_tables(u32 start)
 	debug("ACPI:    * MADT\n");
 	madt = (struct acpi_madt *)current;
 	acpi_create_madt(madt);
-	if (madt->header.length > sizeof(struct acpi_madt)) {
-		current += madt->header.length;
-		acpi_add_table(rsdp, madt);
-	}
+	current += madt->header.length;
+	acpi_add_table(rsdp, madt);
 	current = ALIGN(current, 16);
 
 	debug("ACPI:    * MCFG\n");
 	mcfg = (struct acpi_mcfg *)current;
 	acpi_create_mcfg(mcfg);
-	if (mcfg->header.length > sizeof(struct acpi_mcfg)) {
-		current += mcfg->header.length;
-		current = ALIGN(current, 16);
-		acpi_add_table(rsdp, mcfg);
-	}
+	current += mcfg->header.length;
+	acpi_add_table(rsdp, mcfg);
+	current = ALIGN(current, 16);
 
 	debug("current = %x\n", current);