]> Git Repo - u-boot.git/commitdiff
x86: acpi: Remove header length check when writing tables
authorBin Meng <[email protected]>
Wed, 11 May 2016 14:45:05 +0000 (07:45 -0700)
committerBin Meng <[email protected]>
Mon, 23 May 2016 07:18:00 +0000 (15:18 +0800)
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 <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
arch/x86/lib/acpi_table.c

index 1c57094f0fe01e595217be4803e710245b97abb0..ffb4678e510b38e9249db3209bf0dd8666155613 100644 (file)
@@ -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);
 
This page took 0.036205 seconds and 4 git commands to generate.