Commit fdb3c177 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

ACPI: EC: Clean up probing for early EC

Both acpi_ec_dsdt_probe() and acpi_ec_ecdt_probe() may be void as
their return values are ignored anyway.  This allows a couple of
gotos and labels to go away from there.

Moreover, acpi_ec_ecdt_probe() only needs to allocate the ec
object after getting the ECDT pointer and checking it, so the
pointless memory allocation and release on systems without the
ECDT can be avoided by reordering it.

No intentional functional impact.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent f17b5f06
...@@ -1730,10 +1730,10 @@ static const struct acpi_device_id ec_device_ids[] = { ...@@ -1730,10 +1730,10 @@ static const struct acpi_device_id ec_device_ids[] = {
* namespace EC before the main ACPI device enumeration process. It is * namespace EC before the main ACPI device enumeration process. It is
* retained for historical reason and will be deprecated in the future. * retained for historical reason and will be deprecated in the future.
*/ */
int __init acpi_ec_dsdt_probe(void) void __init acpi_ec_dsdt_probe(void)
{ {
acpi_status status;
struct acpi_ec *ec; struct acpi_ec *ec;
acpi_status status;
int ret; int ret;
/* /*
...@@ -1743,21 +1743,22 @@ int __init acpi_ec_dsdt_probe(void) ...@@ -1743,21 +1743,22 @@ int __init acpi_ec_dsdt_probe(void)
* picking up an invalid EC device. * picking up an invalid EC device.
*/ */
if (boot_ec) if (boot_ec)
return -ENODEV; return;
ec = acpi_ec_alloc(); ec = acpi_ec_alloc();
if (!ec) if (!ec)
return -ENOMEM; return;
/* /*
* At this point, the namespace is initialized, so start to find * At this point, the namespace is initialized, so start to find
* the namespace objects. * the namespace objects.
*/ */
status = acpi_get_devices(ec_device_ids[0].id, status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device, ec, NULL);
ec_parse_device, ec, NULL);
if (ACPI_FAILURE(status) || !ec->handle) { if (ACPI_FAILURE(status) || !ec->handle) {
ret = -ENODEV; acpi_ec_free(ec);
goto error; return;
} }
/* /*
* When the DSDT EC is available, always re-configure boot EC to * When the DSDT EC is available, always re-configure boot EC to
* have _REG evaluated. _REG can only be evaluated after the * have _REG evaluated. _REG can only be evaluated after the
...@@ -1766,10 +1767,8 @@ int __init acpi_ec_dsdt_probe(void) ...@@ -1766,10 +1767,8 @@ int __init acpi_ec_dsdt_probe(void)
* handle the events. * handle the events.
*/ */
ret = acpi_config_boot_ec(ec, ec->handle, false, false); ret = acpi_config_boot_ec(ec, ec->handle, false, false);
error:
if (ret) if (ret)
acpi_ec_free(ec); acpi_ec_free(ec);
return ret;
} }
/* /*
...@@ -1872,36 +1871,32 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = { ...@@ -1872,36 +1871,32 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = {
{}, {},
}; };
int __init acpi_ec_ecdt_probe(void) void __init acpi_ec_ecdt_probe(void)
{ {
int ret;
acpi_status status;
struct acpi_table_ecdt *ecdt_ptr; struct acpi_table_ecdt *ecdt_ptr;
struct acpi_ec *ec; struct acpi_ec *ec;
acpi_status status;
int ret;
ec = acpi_ec_alloc(); /* Generate a boot ec context. */
if (!ec)
return -ENOMEM;
/*
* Generate a boot ec context
*/
dmi_check_system(ec_dmi_table); dmi_check_system(ec_dmi_table);
status = acpi_get_table(ACPI_SIG_ECDT, 1, status = acpi_get_table(ACPI_SIG_ECDT, 1,
(struct acpi_table_header **)&ecdt_ptr); (struct acpi_table_header **)&ecdt_ptr);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status))
ret = -ENODEV; return;
goto error;
}
if (!ecdt_ptr->control.address || !ecdt_ptr->data.address) { if (!ecdt_ptr->control.address || !ecdt_ptr->data.address) {
/* /*
* Asus X50GL: * Asus X50GL:
* https://bugzilla.kernel.org/show_bug.cgi?id=11880 * https://bugzilla.kernel.org/show_bug.cgi?id=11880
*/ */
ret = -ENODEV; return;
goto error;
} }
ec = acpi_ec_alloc();
if (!ec)
return;
if (EC_FLAGS_CORRECT_ECDT) { if (EC_FLAGS_CORRECT_ECDT) {
ec->command_addr = ecdt_ptr->data.address; ec->command_addr = ecdt_ptr->data.address;
ec->data_addr = ecdt_ptr->control.address; ec->data_addr = ecdt_ptr->control.address;
...@@ -1916,10 +1911,8 @@ int __init acpi_ec_ecdt_probe(void) ...@@ -1916,10 +1911,8 @@ int __init acpi_ec_ecdt_probe(void)
* the namespace objects, or handle the events. * the namespace objects, or handle the events.
*/ */
ret = acpi_config_boot_ec(ec, ACPI_ROOT_OBJECT, false, true); ret = acpi_config_boot_ec(ec, ACPI_ROOT_OBJECT, false, true);
error:
if (ret) if (ret)
acpi_ec_free(ec); acpi_ec_free(ec);
return ret;
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
......
...@@ -192,8 +192,8 @@ extern struct acpi_ec *first_ec; ...@@ -192,8 +192,8 @@ extern struct acpi_ec *first_ec;
typedef int (*acpi_ec_query_func) (void *data); typedef int (*acpi_ec_query_func) (void *data);
int acpi_ec_init(void); int acpi_ec_init(void);
int acpi_ec_ecdt_probe(void); void acpi_ec_ecdt_probe(void);
int acpi_ec_dsdt_probe(void); void acpi_ec_dsdt_probe(void);
void acpi_ec_block_transactions(void); void acpi_ec_block_transactions(void);
void acpi_ec_unblock_transactions(void); void acpi_ec_unblock_transactions(void);
void acpi_ec_mark_gpe_for_wake(void); void acpi_ec_mark_gpe_for_wake(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment