Skip to content

Commit a2b6917

Browse files
committed
ACPI: EC: Avoid passing redundant argument to functions
After commit 406857f ("ACPI: EC: add support for hardware-reduced systems") the handle_events argument passed to ec_install_handlers() and acpi_ec_setup() is redundant, because it is always 'false' when the device argument passed to them in NULL and it is always 'true' otherwise, so the device argument can be tested against NULL instead of testing the handle_events one. Accordingly, modify ec_install_handlers() and acpi_ec_setup() to take two arguments and reduce the number of checks in the former. Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent c823c17 commit a2b6917

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

drivers/acpi/ec.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,8 +1476,7 @@ static int install_gpio_irq_event_handler(struct acpi_ec *ec,
14761476
* handler is not installed, which means "not able to handle
14771477
* transactions".
14781478
*/
1479-
static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,
1480-
bool handle_events)
1479+
static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device)
14811480
{
14821481
acpi_status status;
14831482

@@ -1507,7 +1506,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,
15071506
set_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags);
15081507
}
15091508

1510-
if (!handle_events)
1509+
if (!device)
15111510
return 0;
15121511

15131512
if (!test_bit(EC_FLAGS_QUERY_METHODS_INSTALLED, &ec->flags)) {
@@ -1520,13 +1519,10 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,
15201519
if (!test_bit(EC_FLAGS_EVENT_HANDLER_INSTALLED, &ec->flags)) {
15211520
if (ec->gpe >= 0) {
15221521
install_gpe_event_handler(ec);
1523-
} else if (device) {
1522+
} else {
15241523
int ret = install_gpio_irq_event_handler(ec, device);
1525-
15261524
if (ret)
15271525
return ret;
1528-
} else { /* No GPE and no GpioInt? */
1529-
return -ENODEV;
15301526
}
15311527
}
15321528
/* EC is fully operational, allow queries */
@@ -1574,12 +1570,11 @@ static void ec_remove_handlers(struct acpi_ec *ec)
15741570
}
15751571
}
15761572

1577-
static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device,
1578-
bool handle_events)
1573+
static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device)
15791574
{
15801575
int ret;
15811576

1582-
ret = ec_install_handlers(ec, device, handle_events);
1577+
ret = ec_install_handlers(ec, device);
15831578
if (ret)
15841579
return ret;
15851580

@@ -1660,7 +1655,7 @@ static int acpi_ec_add(struct acpi_device *device)
16601655
}
16611656
}
16621657

1663-
ret = acpi_ec_setup(ec, device, true);
1658+
ret = acpi_ec_setup(ec, device);
16641659
if (ret)
16651660
goto err_query;
16661661

@@ -1780,7 +1775,7 @@ void __init acpi_ec_dsdt_probe(void)
17801775
* At this point, the GPE is not fully initialized, so do not to
17811776
* handle the events.
17821777
*/
1783-
ret = acpi_ec_setup(ec, NULL, false);
1778+
ret = acpi_ec_setup(ec, NULL);
17841779
if (ret) {
17851780
acpi_ec_free(ec);
17861781
return;
@@ -1967,7 +1962,7 @@ void __init acpi_ec_ecdt_probe(void)
19671962
* At this point, the namespace is not initialized, so do not find
19681963
* the namespace objects, or handle the events.
19691964
*/
1970-
ret = acpi_ec_setup(ec, NULL, false);
1965+
ret = acpi_ec_setup(ec, NULL);
19711966
if (ret) {
19721967
acpi_ec_free(ec);
19731968
return;

0 commit comments

Comments
 (0)