.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * ACPI support for platform bus type. |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * Authors: Mika Westerberg <mika.westerberg@linux.intel.com> |
---|
6 | 7 | * Mathias Nyman <mathias.nyman@linux.intel.com> |
---|
7 | 8 | * 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. |
---|
12 | 9 | */ |
---|
13 | 10 | |
---|
14 | 11 | #include <linux/acpi.h> |
---|
.. | .. |
---|
22 | 19 | |
---|
23 | 20 | #include "internal.h" |
---|
24 | 21 | |
---|
25 | | -ACPI_MODULE_NAME("platform"); |
---|
26 | | - |
---|
27 | 22 | static const struct acpi_device_id forbidden_id_list[] = { |
---|
28 | 23 | {"PNP0000", 0}, /* PIC */ |
---|
29 | 24 | {"PNP0100", 0}, /* Timer */ |
---|
.. | .. |
---|
32 | 27 | {"ACPI000A", 0}, /* IOAPIC */ |
---|
33 | 28 | {"SMB0001", 0}, /* ACPI SMBUS virtual device */ |
---|
34 | 29 | {"", 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, |
---|
35 | 68 | }; |
---|
36 | 69 | |
---|
37 | 70 | static void acpi_platform_fill_resource(struct acpi_device *adev, |
---|
.. | .. |
---|
133 | 166 | return pdev; |
---|
134 | 167 | } |
---|
135 | 168 | 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 | +} |
---|