Skip to content

Commit ab06eb9

Browse files
committed
ACPI: scan: Register platform devices for fixed event buttons
On platforms using ACPI, power and sleep buttons may be so called "fixed event devices" in which case they are hooked up directly to the Fixed Events register in the platform via dedicated lines and there are no corresponding device objects in the ACPI namespace. Nevertheless, in Linux they get corresponding struct acpi_device objects with special device IDs, either LNXPWRBN or LNXSLPBN, which are then used for driver binding in a ususal way. However, the function creating those struct acpi_device objects for "fixed event device" buttons, acpi_bus_scan_fixed(), does not register platform devices for them, unlike the generic code handling device enumeration based on the ACPI namespace. Consequently, if an ACPI power or sleep button is represented by a device object in the ACPI namespace, it will get a corresponding platform device, but if it is a "fixed event device", it will not get one, which is inconsistent and prevents the ACPI power button driver from being converted into a platform driver. For the sake of consistency and to allow the ACPI power button driver to become a platform one going forward, modify acpi_bus_scan_fixed() to register platform devices for "fixed event device" buttons and update ACPI platform device registration code to work with non-device ACPI object types, so it can handle the buttons in question. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/3731144.R56niFO833@rafael.j.wysocki
1 parent 03667e1 commit ab06eb9

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

drivers/acpi/acpi_platform.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,8 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
114114
struct platform_device *pdev = NULL;
115115
struct platform_device_info pdevinfo;
116116
const struct acpi_device_id *match;
117-
struct resource_entry *rentry;
118-
struct list_head resource_list;
119117
struct resource *resources = NULL;
120-
int count;
118+
int count = 0;
121119

122120
/* If the ACPI node already has a physical device attached, skip it. */
123121
if (adev->physical_node_count)
@@ -137,22 +135,28 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
137135
}
138136
}
139137

140-
INIT_LIST_HEAD(&resource_list);
141-
count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
142-
if (count < 0)
143-
return NULL;
144-
if (count > 0) {
145-
resources = kcalloc(count, sizeof(*resources), GFP_KERNEL);
146-
if (!resources) {
138+
if (adev->device_type == ACPI_BUS_TYPE_DEVICE) {
139+
struct list_head resource_list = LIST_HEAD_INIT(resource_list);
140+
141+
count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
142+
if (count < 0)
143+
return ERR_PTR(-ENODATA);
144+
145+
if (count > 0) {
146+
struct resource_entry *rentry;
147+
148+
resources = kcalloc(count, sizeof(*resources), GFP_KERNEL);
149+
if (!resources) {
150+
acpi_dev_free_resource_list(&resource_list);
151+
return ERR_PTR(-ENOMEM);
152+
}
153+
count = 0;
154+
list_for_each_entry(rentry, &resource_list, node)
155+
acpi_platform_fill_resource(adev, rentry->res,
156+
&resources[count++]);
157+
147158
acpi_dev_free_resource_list(&resource_list);
148-
return ERR_PTR(-ENOMEM);
149159
}
150-
count = 0;
151-
list_for_each_entry(rentry, &resource_list, node)
152-
acpi_platform_fill_resource(adev, rentry->res,
153-
&resources[count++]);
154-
155-
acpi_dev_free_resource_list(&resource_list);
156160
}
157161

158162
memset(&pdevinfo, 0, sizeof(pdevinfo));

drivers/acpi/scan.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,6 +2772,8 @@ static void acpi_bus_scan_fixed(void)
27722772
device_init_wakeup(&adev->dev, true);
27732773
else
27742774
dev_dbg(&adev->dev, "No driver\n");
2775+
2776+
acpi_default_enumeration(adev);
27752777
}
27762778
}
27772779

@@ -2784,6 +2786,8 @@ static void acpi_bus_scan_fixed(void)
27842786
adev->flags.match_driver = true;
27852787
if (device_attach(&adev->dev) < 0)
27862788
dev_dbg(&adev->dev, "No driver\n");
2789+
2790+
acpi_default_enumeration(adev);
27872791
}
27882792
}
27892793
}

0 commit comments

Comments
 (0)