Skip to content

Commit 62a1281

Browse files
committed
Merge tag 'acpi-6.10-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI fixes from Rafael Wysocki: "These make the ACPI EC driver always install the EC address space handler at the root of the ACPI namespace which causes it to take care of all EC operation regions everywhere. This means that the custom EC address space handler in the WMI driver is not needed any more and accordingly it gets removed altogether" * tag 'acpi-6.10-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: platform/x86: wmi: Remove custom EC address space handler ACPI: EC: Install address space handler at the namespace root
2 parents 5b5a5ad + 98a83da commit 62a1281

File tree

3 files changed

+16
-102
lines changed

3 files changed

+16
-102
lines changed

drivers/acpi/ec.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,13 +1482,14 @@ static bool install_gpio_irq_event_handler(struct acpi_ec *ec)
14821482
static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,
14831483
bool call_reg)
14841484
{
1485+
acpi_handle scope_handle = ec == first_ec ? ACPI_ROOT_OBJECT : ec->handle;
14851486
acpi_status status;
14861487

14871488
acpi_ec_start(ec, false);
14881489

14891490
if (!test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) {
14901491
acpi_ec_enter_noirq(ec);
1491-
status = acpi_install_address_space_handler_no_reg(ec->handle,
1492+
status = acpi_install_address_space_handler_no_reg(scope_handle,
14921493
ACPI_ADR_SPACE_EC,
14931494
&acpi_ec_space_handler,
14941495
NULL, ec);
@@ -1497,11 +1498,10 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,
14971498
return -ENODEV;
14981499
}
14991500
set_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags);
1500-
ec->address_space_handler_holder = ec->handle;
15011501
}
15021502

15031503
if (call_reg && !test_bit(EC_FLAGS_EC_REG_CALLED, &ec->flags)) {
1504-
acpi_execute_reg_methods(ec->handle, ACPI_ADR_SPACE_EC);
1504+
acpi_execute_reg_methods(scope_handle, ACPI_ADR_SPACE_EC);
15051505
set_bit(EC_FLAGS_EC_REG_CALLED, &ec->flags);
15061506
}
15071507

@@ -1553,10 +1553,13 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,
15531553

15541554
static void ec_remove_handlers(struct acpi_ec *ec)
15551555
{
1556+
acpi_handle scope_handle = ec == first_ec ? ACPI_ROOT_OBJECT : ec->handle;
1557+
15561558
if (test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) {
15571559
if (ACPI_FAILURE(acpi_remove_address_space_handler(
1558-
ec->address_space_handler_holder,
1559-
ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
1560+
scope_handle,
1561+
ACPI_ADR_SPACE_EC,
1562+
&acpi_ec_space_handler)))
15601563
pr_err("failed to remove space handler\n");
15611564
clear_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags);
15621565
}
@@ -1595,14 +1598,18 @@ static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device, bool ca
15951598
{
15961599
int ret;
15971600

1598-
ret = ec_install_handlers(ec, device, call_reg);
1599-
if (ret)
1600-
return ret;
1601-
16021601
/* First EC capable of handling transactions */
16031602
if (!first_ec)
16041603
first_ec = ec;
16051604

1605+
ret = ec_install_handlers(ec, device, call_reg);
1606+
if (ret) {
1607+
if (ec == first_ec)
1608+
first_ec = NULL;
1609+
1610+
return ret;
1611+
}
1612+
16061613
pr_info("EC_CMD/EC_SC=0x%lx, EC_DATA=0x%lx\n", ec->command_addr,
16071614
ec->data_addr);
16081615

drivers/acpi/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ enum acpi_ec_event_state {
186186

187187
struct acpi_ec {
188188
acpi_handle handle;
189-
acpi_handle address_space_handler_holder;
190189
int gpe;
191190
int irq;
192191
unsigned long command_addr;

drivers/platform/x86/wmi.c

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,77 +1153,6 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev)
11531153
return 0;
11541154
}
11551155

1156-
static int ec_read_multiple(u8 address, u8 *buffer, size_t bytes)
1157-
{
1158-
size_t i;
1159-
int ret;
1160-
1161-
for (i = 0; i < bytes; i++) {
1162-
ret = ec_read(address + i, &buffer[i]);
1163-
if (ret < 0)
1164-
return ret;
1165-
}
1166-
1167-
return 0;
1168-
}
1169-
1170-
static int ec_write_multiple(u8 address, u8 *buffer, size_t bytes)
1171-
{
1172-
size_t i;
1173-
int ret;
1174-
1175-
for (i = 0; i < bytes; i++) {
1176-
ret = ec_write(address + i, buffer[i]);
1177-
if (ret < 0)
1178-
return ret;
1179-
}
1180-
1181-
return 0;
1182-
}
1183-
1184-
/*
1185-
* WMI can have EmbeddedControl access regions. In which case, we just want to
1186-
* hand these off to the EC driver.
1187-
*/
1188-
static acpi_status
1189-
acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,
1190-
u32 bits, u64 *value,
1191-
void *handler_context, void *region_context)
1192-
{
1193-
int bytes = bits / BITS_PER_BYTE;
1194-
int ret;
1195-
1196-
if (!value)
1197-
return AE_NULL_ENTRY;
1198-
1199-
if (!bytes || bytes > sizeof(*value))
1200-
return AE_BAD_PARAMETER;
1201-
1202-
if (address > U8_MAX || address + bytes - 1 > U8_MAX)
1203-
return AE_BAD_PARAMETER;
1204-
1205-
if (function != ACPI_READ && function != ACPI_WRITE)
1206-
return AE_BAD_PARAMETER;
1207-
1208-
if (function == ACPI_READ)
1209-
ret = ec_read_multiple(address, (u8 *)value, bytes);
1210-
else
1211-
ret = ec_write_multiple(address, (u8 *)value, bytes);
1212-
1213-
switch (ret) {
1214-
case -EINVAL:
1215-
return AE_BAD_PARAMETER;
1216-
case -ENODEV:
1217-
return AE_NOT_FOUND;
1218-
case -ETIME:
1219-
return AE_TIME;
1220-
case 0:
1221-
return AE_OK;
1222-
default:
1223-
return AE_ERROR;
1224-
}
1225-
}
1226-
12271156
static int wmi_get_notify_data(struct wmi_block *wblock, union acpi_object **obj)
12281157
{
12291158
struct acpi_buffer data = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -1338,14 +1267,6 @@ static void acpi_wmi_remove_notify_handler(void *data)
13381267
acpi_remove_notify_handler(acpi_device->handle, ACPI_ALL_NOTIFY, acpi_wmi_notify_handler);
13391268
}
13401269

1341-
static void acpi_wmi_remove_address_space_handler(void *data)
1342-
{
1343-
struct acpi_device *acpi_device = data;
1344-
1345-
acpi_remove_address_space_handler(acpi_device->handle, ACPI_ADR_SPACE_EC,
1346-
&acpi_wmi_ec_space_handler);
1347-
}
1348-
13491270
static void acpi_wmi_remove_bus_device(void *data)
13501271
{
13511272
struct device *wmi_bus_dev = data;
@@ -1377,19 +1298,6 @@ static int acpi_wmi_probe(struct platform_device *device)
13771298

13781299
dev_set_drvdata(&device->dev, wmi_bus_dev);
13791300

1380-
status = acpi_install_address_space_handler(acpi_device->handle,
1381-
ACPI_ADR_SPACE_EC,
1382-
&acpi_wmi_ec_space_handler,
1383-
NULL, NULL);
1384-
if (ACPI_FAILURE(status)) {
1385-
dev_err(&device->dev, "Error installing EC region handler\n");
1386-
return -ENODEV;
1387-
}
1388-
error = devm_add_action_or_reset(&device->dev, acpi_wmi_remove_address_space_handler,
1389-
acpi_device);
1390-
if (error < 0)
1391-
return error;
1392-
13931301
status = acpi_install_notify_handler(acpi_device->handle, ACPI_ALL_NOTIFY,
13941302
acpi_wmi_notify_handler, wmi_bus_dev);
13951303
if (ACPI_FAILURE(status)) {

0 commit comments

Comments
 (0)