summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2020-02-27 17:00:51 +0300
committerBin Meng <bmeng.cn@gmail.com>2020-04-04 17:08:44 +0300
commitddcccb2b2c1251ee9cd658c340d722a716d75a96 (patch)
tree55b7e23ab6f63dd2c9718a341fade9dc52b9627a
parente0718b3ab754860bd47677e6b4fc5b70da42c4ab (diff)
downloadu-boot-ddcccb2b2c1251ee9cd658c340d722a716d75a96.tar.xz
x86: acpi: Refactor XSDT handling in acpi_add_table()
There is no need to have an assignment to NULL for XSDT pointer. Therefore, no need to assign it when rsdt_address is not set. Because of above changes we may decrease indentation level as well. While here, drop unnecessary parentheses. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
-rw-r--r--arch/x86/lib/acpi_table.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index 0d69cf271f..66e32f21bd 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -109,14 +109,11 @@ static void acpi_add_table(struct acpi_rsdp *rsdp, void *table)
{
int i, entries_num;
struct acpi_rsdt *rsdt;
- struct acpi_xsdt *xsdt = NULL;
+ struct acpi_xsdt *xsdt;
/* The RSDT is mandatory while the XSDT is not */
rsdt = (struct acpi_rsdt *)rsdp->rsdt_address;
- if (rsdp->xsdt_address)
- xsdt = (struct acpi_xsdt *)((u32)rsdp->xsdt_address);
-
/* This should always be MAX_ACPI_TABLES */
entries_num = ARRAY_SIZE(rsdt->entry);
@@ -135,30 +132,34 @@ static void acpi_add_table(struct acpi_rsdp *rsdp, void *table)
/* Fix RSDT length or the kernel will assume invalid entries */
rsdt->header.length = sizeof(struct acpi_table_header) +
- (sizeof(u32) * (i + 1));
+ sizeof(u32) * (i + 1);
/* Re-calculate checksum */
rsdt->header.checksum = 0;
rsdt->header.checksum = table_compute_checksum((u8 *)rsdt,
rsdt->header.length);
+ /* The RSDT is mandatory while the XSDT is not */
+ if (!rsdp->xsdt_address)
+ return;
+
/*
* And now the same thing for the XSDT. We use the same index as for
* now we want the XSDT and RSDT to always be in sync in U-Boot
*/
- if (xsdt) {
- /* Add table to the XSDT */
- xsdt->entry[i] = (u64)(u32)table;
-
- /* Fix XSDT length */
- xsdt->header.length = sizeof(struct acpi_table_header) +
- (sizeof(u64) * (i + 1));
-
- /* Re-calculate checksum */
- xsdt->header.checksum = 0;
- xsdt->header.checksum = table_compute_checksum((u8 *)xsdt,
- xsdt->header.length);
- }
+ xsdt = (struct acpi_xsdt *)((u32)rsdp->xsdt_address);
+
+ /* Add table to the XSDT */
+ xsdt->entry[i] = (u64)(u32)table;
+
+ /* Fix XSDT length */
+ xsdt->header.length = sizeof(struct acpi_table_header) +
+ sizeof(u64) * (i + 1);
+
+ /* Re-calculate checksum */
+ xsdt->header.checksum = 0;
+ xsdt->header.checksum = table_compute_checksum((u8 *)xsdt,
+ xsdt->header.length);
}
static void acpi_create_facs(struct acpi_facs *facs)