hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/acpi/acpi_platform.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ACPI support for platform bus type.
34 *
....@@ -5,10 +6,6 @@
56 * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
67 * Mathias Nyman <mathias.nyman@linux.intel.com>
78 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
129 */
1310
1411 #include <linux/acpi.h>
....@@ -22,8 +19,6 @@
2219
2320 #include "internal.h"
2421
25
-ACPI_MODULE_NAME("platform");
26
-
2722 static const struct acpi_device_id forbidden_id_list[] = {
2823 {"PNP0000", 0}, /* PIC */
2924 {"PNP0100", 0}, /* Timer */
....@@ -32,6 +27,44 @@
3227 {"ACPI000A", 0}, /* IOAPIC */
3328 {"SMB0001", 0}, /* ACPI SMBUS virtual device */
3429 {"", 0},
30
+};
31
+
32
+static struct platform_device *acpi_platform_device_find_by_companion(struct acpi_device *adev)
33
+{
34
+ struct device *dev;
35
+
36
+ dev = bus_find_device_by_acpi_dev(&platform_bus_type, adev);
37
+ return dev ? to_platform_device(dev) : NULL;
38
+}
39
+
40
+static int acpi_platform_device_remove_notify(struct notifier_block *nb,
41
+ unsigned long value, void *arg)
42
+{
43
+ struct acpi_device *adev = arg;
44
+ struct platform_device *pdev;
45
+
46
+ switch (value) {
47
+ case ACPI_RECONFIG_DEVICE_ADD:
48
+ /* Nothing to do here */
49
+ break;
50
+ case ACPI_RECONFIG_DEVICE_REMOVE:
51
+ if (!acpi_device_enumerated(adev))
52
+ break;
53
+
54
+ pdev = acpi_platform_device_find_by_companion(adev);
55
+ if (!pdev)
56
+ break;
57
+
58
+ platform_device_unregister(pdev);
59
+ put_device(&pdev->dev);
60
+ break;
61
+ }
62
+
63
+ return NOTIFY_OK;
64
+}
65
+
66
+static struct notifier_block acpi_platform_notifier = {
67
+ .notifier_call = acpi_platform_device_remove_notify,
3568 };
3669
3770 static void acpi_platform_fill_resource(struct acpi_device *adev,
....@@ -133,3 +166,8 @@
133166 return pdev;
134167 }
135168 EXPORT_SYMBOL_GPL(acpi_create_platform_device);
169
+
170
+void __init acpi_platform_init(void)
171
+{
172
+ acpi_reconfig_notifier_register(&acpi_platform_notifier);
173
+}