Skip to content

Commit fdb3c17

Browse files
committed
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: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent f17b5f0 commit fdb3c17

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed

drivers/acpi/ec.c

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,10 +1730,10 @@ static const struct acpi_device_id ec_device_ids[] = {
17301730
* namespace EC before the main ACPI device enumeration process. It is
17311731
* retained for historical reason and will be deprecated in the future.
17321732
*/
1733-
int __init acpi_ec_dsdt_probe(void)
1733+
void __init acpi_ec_dsdt_probe(void)
17341734
{
1735-
acpi_status status;
17361735
struct acpi_ec *ec;
1736+
acpi_status status;
17371737
int ret;
17381738

17391739
/*
@@ -1743,21 +1743,22 @@ int __init acpi_ec_dsdt_probe(void)
17431743
* picking up an invalid EC device.
17441744
*/
17451745
if (boot_ec)
1746-
return -ENODEV;
1746+
return;
17471747

17481748
ec = acpi_ec_alloc();
17491749
if (!ec)
1750-
return -ENOMEM;
1750+
return;
1751+
17511752
/*
17521753
* At this point, the namespace is initialized, so start to find
17531754
* the namespace objects.
17541755
*/
1755-
status = acpi_get_devices(ec_device_ids[0].id,
1756-
ec_parse_device, ec, NULL);
1756+
status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device, ec, NULL);
17571757
if (ACPI_FAILURE(status) || !ec->handle) {
1758-
ret = -ENODEV;
1759-
goto error;
1758+
acpi_ec_free(ec);
1759+
return;
17601760
}
1761+
17611762
/*
17621763
* When the DSDT EC is available, always re-configure boot EC to
17631764
* have _REG evaluated. _REG can only be evaluated after the
@@ -1766,10 +1767,8 @@ int __init acpi_ec_dsdt_probe(void)
17661767
* handle the events.
17671768
*/
17681769
ret = acpi_config_boot_ec(ec, ec->handle, false, false);
1769-
error:
17701770
if (ret)
17711771
acpi_ec_free(ec);
1772-
return ret;
17731772
}
17741773

17751774
/*
@@ -1872,36 +1871,32 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = {
18721871
{},
18731872
};
18741873

1875-
int __init acpi_ec_ecdt_probe(void)
1874+
void __init acpi_ec_ecdt_probe(void)
18761875
{
1877-
int ret;
1878-
acpi_status status;
18791876
struct acpi_table_ecdt *ecdt_ptr;
18801877
struct acpi_ec *ec;
1878+
acpi_status status;
1879+
int ret;
18811880

1882-
ec = acpi_ec_alloc();
1883-
if (!ec)
1884-
return -ENOMEM;
1885-
/*
1886-
* Generate a boot ec context
1887-
*/
1881+
/* Generate a boot ec context. */
18881882
dmi_check_system(ec_dmi_table);
18891883
status = acpi_get_table(ACPI_SIG_ECDT, 1,
18901884
(struct acpi_table_header **)&ecdt_ptr);
1891-
if (ACPI_FAILURE(status)) {
1892-
ret = -ENODEV;
1893-
goto error;
1894-
}
1885+
if (ACPI_FAILURE(status))
1886+
return;
18951887

18961888
if (!ecdt_ptr->control.address || !ecdt_ptr->data.address) {
18971889
/*
18981890
* Asus X50GL:
18991891
* https://bugzilla.kernel.org/show_bug.cgi?id=11880
19001892
*/
1901-
ret = -ENODEV;
1902-
goto error;
1893+
return;
19031894
}
19041895

1896+
ec = acpi_ec_alloc();
1897+
if (!ec)
1898+
return;
1899+
19051900
if (EC_FLAGS_CORRECT_ECDT) {
19061901
ec->command_addr = ecdt_ptr->data.address;
19071902
ec->data_addr = ecdt_ptr->control.address;
@@ -1916,10 +1911,8 @@ int __init acpi_ec_ecdt_probe(void)
19161911
* the namespace objects, or handle the events.
19171912
*/
19181913
ret = acpi_config_boot_ec(ec, ACPI_ROOT_OBJECT, false, true);
1919-
error:
19201914
if (ret)
19211915
acpi_ec_free(ec);
1922-
return ret;
19231916
}
19241917

19251918
#ifdef CONFIG_PM_SLEEP

drivers/acpi/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ extern struct acpi_ec *first_ec;
192192
typedef int (*acpi_ec_query_func) (void *data);
193193

194194
int acpi_ec_init(void);
195-
int acpi_ec_ecdt_probe(void);
196-
int acpi_ec_dsdt_probe(void);
195+
void acpi_ec_ecdt_probe(void);
196+
void acpi_ec_dsdt_probe(void);
197197
void acpi_ec_block_transactions(void);
198198
void acpi_ec_unblock_transactions(void);
199199
void acpi_ec_mark_gpe_for_wake(void);

0 commit comments

Comments
 (0)