Skip to content

Commit ac9bc85

Browse files
Wer-Wolfij-intel
authored andcommitted
platform/x86: wmi: Decouple WMI device removal from wmi_block_list
Use device_for_each_child_reverse() to find and unregister WMI devices belonging to a WMI bus device instead of iterating thru the entire wmi_block_list. Signed-off-by: Armin Wolf <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent eba9ac7 commit ac9bc85

File tree

1 file changed

+14
-15
lines changed
  • drivers/platform/x86

1 file changed

+14
-15
lines changed

drivers/platform/x86/wmi.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,19 +1280,6 @@ static int wmi_add_device(struct platform_device *pdev, struct wmi_device *wdev)
12801280
return device_add(&wdev->dev);
12811281
}
12821282

1283-
static void wmi_free_devices(struct acpi_device *device)
1284-
{
1285-
struct wmi_block *wblock, *next;
1286-
1287-
/* Delete devices for all the GUIDs */
1288-
list_for_each_entry_safe(wblock, next, &wmi_block_list, list) {
1289-
if (wblock->acpi_device == device) {
1290-
list_del(&wblock->list);
1291-
device_unregister(&wblock->dev.dev);
1292-
}
1293-
}
1294-
}
1295-
12961283
static bool guid_already_parsed_for_legacy(struct acpi_device *device, const guid_t *guid)
12971284
{
12981285
struct wmi_block *wblock;
@@ -1487,16 +1474,28 @@ static void acpi_wmi_notify_handler(acpi_handle handle, u32 event,
14871474
event, 0);
14881475
}
14891476

1477+
static int wmi_remove_device(struct device *dev, void *data)
1478+
{
1479+
struct wmi_block *wblock = dev_to_wblock(dev);
1480+
1481+
list_del(&wblock->list);
1482+
device_unregister(dev);
1483+
1484+
return 0;
1485+
}
1486+
14901487
static void acpi_wmi_remove(struct platform_device *device)
14911488
{
14921489
struct acpi_device *acpi_device = ACPI_COMPANION(&device->dev);
1490+
struct device *wmi_bus_device = dev_get_drvdata(&device->dev);
14931491

14941492
acpi_remove_notify_handler(acpi_device->handle, ACPI_ALL_NOTIFY,
14951493
acpi_wmi_notify_handler);
14961494
acpi_remove_address_space_handler(acpi_device->handle,
14971495
ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler);
1498-
wmi_free_devices(acpi_device);
1499-
device_unregister(dev_get_drvdata(&device->dev));
1496+
1497+
device_for_each_child_reverse(wmi_bus_device, NULL, wmi_remove_device);
1498+
device_unregister(wmi_bus_device);
15001499
}
15011500

15021501
static int acpi_wmi_probe(struct platform_device *device)

0 commit comments

Comments
 (0)