Skip to content

Commit 116f2b3

Browse files
committed
ACPI: EC: Simplify boot EC checks in acpi_ec_add()
Consolidate boot EC checks in acpi_ec_add(), put the acpi_is_boot_ec() checks directly into it and drop the latter. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent d2c62ae commit 116f2b3

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

drivers/acpi/ec.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,43 +1560,34 @@ static bool acpi_ec_ecdt_get_handle(acpi_handle *phandle)
15601560
return true;
15611561
}
15621562

1563-
static bool acpi_is_boot_ec(struct acpi_ec *ec)
1564-
{
1565-
if (!boot_ec)
1566-
return false;
1567-
if (ec->command_addr == boot_ec->command_addr &&
1568-
ec->data_addr == boot_ec->data_addr)
1569-
return true;
1570-
return false;
1571-
}
1572-
15731563
static int acpi_ec_add(struct acpi_device *device)
15741564
{
15751565
struct acpi_ec *ec = NULL;
1576-
int ret;
1577-
bool is_ecdt = false;
1566+
bool dep_update = true;
15781567
acpi_status status;
1568+
int ret;
15791569

15801570
strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
15811571
strcpy(acpi_device_class(device), ACPI_EC_CLASS);
15821572

15831573
if (!strcmp(acpi_device_hid(device), ACPI_ECDT_HID)) {
1584-
is_ecdt = true;
1574+
boot_ec_is_ecdt = true;
15851575
ec = boot_ec;
1576+
dep_update = false;
15861577
} else {
15871578
ec = acpi_ec_alloc();
15881579
if (!ec)
15891580
return -ENOMEM;
1581+
15901582
status = ec_parse_device(device->handle, 0, ec, NULL);
15911583
if (status != AE_CTRL_TERMINATE) {
15921584
ret = -EINVAL;
15931585
goto err_alloc;
15941586
}
1595-
}
15961587

1597-
if (acpi_is_boot_ec(ec)) {
1598-
boot_ec_is_ecdt = is_ecdt;
1599-
if (!is_ecdt) {
1588+
if (boot_ec && ec->command_addr == boot_ec->command_addr &&
1589+
ec->data_addr == boot_ec->data_addr) {
1590+
boot_ec_is_ecdt = false;
16001591
/*
16011592
* Trust PNP0C09 namespace location rather than
16021593
* ECDT ID. But trust ECDT GPE rather than _GPE
@@ -1617,7 +1608,7 @@ static int acpi_ec_add(struct acpi_device *device)
16171608
if (ec == boot_ec)
16181609
acpi_handle_info(boot_ec->handle,
16191610
"Boot %s EC used to handle transactions and events\n",
1620-
is_ecdt ? "ECDT" : "DSDT");
1611+
boot_ec_is_ecdt ? "ECDT" : "DSDT");
16211612

16221613
device->driver_data = ec;
16231614

@@ -1626,7 +1617,7 @@ static int acpi_ec_add(struct acpi_device *device)
16261617
ret = !!request_region(ec->command_addr, 1, "EC cmd");
16271618
WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr);
16281619

1629-
if (!is_ecdt) {
1620+
if (dep_update) {
16301621
/* Reprobe devices depending on the EC */
16311622
acpi_walk_dep_device_list(ec->handle);
16321623
}

0 commit comments

Comments
 (0)