OSDN Git Service

ACPI / scan: Change the meaning of missing .attach() in scan handlers
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 30 May 2014 02:27:31 +0000 (04:27 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 30 May 2014 14:04:36 +0000 (16:04 +0200)
Currently, some scan handlers can be compiled out entirely, which
leaves the device objects they normally attach to without a scan
handler.  This isn't a problem as long as we don't have any default
enumeration mechanism that applies to all devices without a scan
handler.  However, if such a default enumeration is added, it still
should not be applied to devices that are normally attached to by
scan handlers, because that may result in creating "physical" device
objects of a wrong type for them.

Since we are going to create platform device objects for all ACPI
device objects with pnp.type.platform_id set by default, clear
pnp.type.platform_id where there is a matching scan handler without
an .attach() callback and otherwise simply treat that scan handler
as though the .attach() callback was present but always returned 0.

This will allow us to compile out scan handler callbacks and leave
the device ID lists used by them so as to prevent creating platform
device objects for the matching ACPI devices.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/acpi/scan.c

index ebbd23c..611bb5d 100644 (file)
@@ -84,7 +84,7 @@ EXPORT_SYMBOL_GPL(acpi_initialize_hp_context);
 
 int acpi_scan_add_handler(struct acpi_scan_handler *handler)
 {
-       if (!handler || !handler->attach)
+       if (!handler)
                return -EINVAL;
 
        list_add_tail(&handler->list_node, &acpi_scan_handlers_list);
@@ -2081,6 +2081,10 @@ static int acpi_scan_attach_handler(struct acpi_device *device)
 
                handler = acpi_scan_match_handler(hwid->id, &devid);
                if (handler) {
+                       if (!handler->attach) {
+                               device->pnp.type.platform_id = 0;
+                               continue;
+                       }
                        device->handler = handler;
                        ret = handler->attach(device, devid);
                        if (ret > 0)