Commit c5698074 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

ACPI / scan: Introduce acpi_scan_match_handler()

Introduce helper routine acpi_scan_match_handler() that will find the
ACPI scan handler matching a given device ID, if there is one, and
rework acpi_scan_attach_handler() to use the new routine (that
routine will also be useful for other purposes going forward).
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Acked-by: default avatarToshi Kani <toshi.kani@hp.com>
Tested-by: default avatarToshi Kani <toshi.kani@hp.com>
parent 6dbe51c2
...@@ -1536,6 +1536,25 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type, ...@@ -1536,6 +1536,25 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,
return 0; return 0;
} }
static struct acpi_scan_handler *acpi_scan_match_handler(char *idstr,
const struct acpi_device_id **matchid)
{
struct acpi_scan_handler *handler;
list_for_each_entry(handler, &acpi_scan_handlers_list, list_node) {
const struct acpi_device_id *devid;
for (devid = handler->ids; devid->id[0]; devid++)
if (!strcmp((char *)devid->id, idstr)) {
if (matchid)
*matchid = devid;
return handler;
}
}
return NULL;
}
static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
void *not_used, void **return_value) void *not_used, void **return_value)
{ {
...@@ -1583,41 +1602,25 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, ...@@ -1583,41 +1602,25 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
return AE_OK; return AE_OK;
} }
static int acpi_scan_do_attach_handler(struct acpi_device *device, char *id) static int acpi_scan_attach_handler(struct acpi_device *device)
{ {
struct acpi_scan_handler *handler; struct acpi_hardware_id *hwid;
int ret = 0;
list_for_each_entry(handler, &acpi_scan_handlers_list, list_node) { list_for_each_entry(hwid, &device->pnp.ids, list) {
const struct acpi_device_id *devid; const struct acpi_device_id *devid;
struct acpi_scan_handler *handler;
for (devid = handler->ids; devid->id[0]; devid++) { handler = acpi_scan_match_handler(hwid->id, &devid);
int ret; if (handler) {
if (strcmp((char *)devid->id, id))
continue;
ret = handler->attach(device, devid); ret = handler->attach(device, devid);
if (ret > 0) { if (ret > 0) {
device->handler = handler; device->handler = handler;
return ret; break;
} else if (ret < 0) { } else if (ret < 0) {
return ret; break;
}
} }
} }
return 0;
}
static int acpi_scan_attach_handler(struct acpi_device *device)
{
struct acpi_hardware_id *hwid;
int ret = 0;
list_for_each_entry(hwid, &device->pnp.ids, list) {
ret = acpi_scan_do_attach_handler(device, hwid->id);
if (ret)
break;
} }
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment