Skip to content

Commit c5279de

Browse files
Alexey Starikovskiylenb
authored andcommitted
ACPI: EC: Add some basic check for ECDT data
One more ASUS comes with empty ECDT, add a guard for it... http://bugzilla.kernel.org/show_bug.cgi?id=11880 Signed-off-by: Alexey Starikovskiy <[email protected]> Signed-off-by: Len Brown <[email protected]>
1 parent ed31348 commit c5279de

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

drivers/acpi/ec.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,6 @@ static const struct acpi_device_id ec_device_ids[] = {
977977

978978
int __init acpi_ec_ecdt_probe(void)
979979
{
980-
int ret;
981980
acpi_status status;
982981
struct acpi_table_ecdt *ecdt_ptr;
983982

@@ -1005,30 +1004,32 @@ int __init acpi_ec_ecdt_probe(void)
10051004
boot_ec->gpe = ecdt_ptr->gpe;
10061005
boot_ec->handle = ACPI_ROOT_OBJECT;
10071006
acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle);
1008-
} else {
1009-
/* This workaround is needed only on some broken machines,
1010-
* which require early EC, but fail to provide ECDT */
1011-
acpi_handle x;
1012-
printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
1013-
status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
1014-
boot_ec, NULL);
1015-
/* Check that acpi_get_devices actually find something */
1016-
if (ACPI_FAILURE(status) || !boot_ec->handle)
1017-
goto error;
1018-
/* We really need to limit this workaround, the only ASUS,
1019-
* which needs it, has fake EC._INI method, so use it as flag.
1020-
* Keep boot_ec struct as it will be needed soon.
1021-
*/
1022-
if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x)))
1023-
return -ENODEV;
1007+
/* Add some basic check against completely broken table */
1008+
if (boot_ec->data_addr != boot_ec->command_addr)
1009+
goto install;
1010+
/* fall through */
10241011
}
1025-
1026-
ret = ec_install_handlers(boot_ec);
1027-
if (!ret) {
1012+
/* This workaround is needed only on some broken machines,
1013+
* which require early EC, but fail to provide ECDT */
1014+
acpi_handle x;
1015+
printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
1016+
status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
1017+
boot_ec, NULL);
1018+
/* Check that acpi_get_devices actually find something */
1019+
if (ACPI_FAILURE(status) || !boot_ec->handle)
1020+
goto error;
1021+
/* We really need to limit this workaround, the only ASUS,
1022+
* which needs it, has fake EC._INI method, so use it as flag.
1023+
* Keep boot_ec struct as it will be needed soon.
1024+
*/
1025+
if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x)))
1026+
return -ENODEV;
1027+
install:
1028+
if (!ec_install_handlers(boot_ec)) {
10281029
first_ec = boot_ec;
10291030
return 0;
10301031
}
1031-
error:
1032+
error:
10321033
kfree(boot_ec);
10331034
boot_ec = NULL;
10341035
return -ENODEV;

0 commit comments

Comments
 (0)