diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-03-03 17:05:14 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-03-04 08:25:32 -0500 |
commit | c56980744ed99994799850903627c4bbb5fed006 (patch) | |
tree | 4ddd5c620e3e43e5a66926516fb476b4ee92f7fe /drivers | |
parent | 6dbe51c251a327e012439c4772097a13df43c5b8 (diff) |
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: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Acked-by: Toshi Kani <toshi.kani@hp.com>
Tested-by: Toshi Kani <toshi.kani@hp.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/acpi/scan.c | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 5e7e991717d7..cc1b0020478b 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -1536,6 +1536,25 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type, | |||
1536 | return 0; | 1536 | return 0; |
1537 | } | 1537 | } |
1538 | 1538 | ||
1539 | static struct acpi_scan_handler *acpi_scan_match_handler(char *idstr, | ||
1540 | const struct acpi_device_id **matchid) | ||
1541 | { | ||
1542 | struct acpi_scan_handler *handler; | ||
1543 | |||
1544 | list_for_each_entry(handler, &acpi_scan_handlers_list, list_node) { | ||
1545 | const struct acpi_device_id *devid; | ||
1546 | |||
1547 | for (devid = handler->ids; devid->id[0]; devid++) | ||
1548 | if (!strcmp((char *)devid->id, idstr)) { | ||
1549 | if (matchid) | ||
1550 | *matchid = devid; | ||
1551 | |||
1552 | return handler; | ||
1553 | } | ||
1554 | } | ||
1555 | return NULL; | ||
1556 | } | ||
1557 | |||
1539 | static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | 1558 | static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, |
1540 | void *not_used, void **return_value) | 1559 | void *not_used, void **return_value) |
1541 | { | 1560 | { |
@@ -1583,42 +1602,26 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | |||
1583 | return AE_OK; | 1602 | return AE_OK; |
1584 | } | 1603 | } |
1585 | 1604 | ||
1586 | static int acpi_scan_do_attach_handler(struct acpi_device *device, char *id) | 1605 | static int acpi_scan_attach_handler(struct acpi_device *device) |
1587 | { | 1606 | { |
1588 | struct acpi_scan_handler *handler; | 1607 | struct acpi_hardware_id *hwid; |
1608 | int ret = 0; | ||
1589 | 1609 | ||
1590 | list_for_each_entry(handler, &acpi_scan_handlers_list, list_node) { | 1610 | list_for_each_entry(hwid, &device->pnp.ids, list) { |
1591 | const struct acpi_device_id *devid; | 1611 | const struct acpi_device_id *devid; |
1612 | struct acpi_scan_handler *handler; | ||
1592 | 1613 | ||
1593 | for (devid = handler->ids; devid->id[0]; devid++) { | 1614 | handler = acpi_scan_match_handler(hwid->id, &devid); |
1594 | int ret; | 1615 | if (handler) { |
1595 | |||
1596 | if (strcmp((char *)devid->id, id)) | ||
1597 | continue; | ||
1598 | |||
1599 | ret = handler->attach(device, devid); | 1616 | ret = handler->attach(device, devid); |
1600 | if (ret > 0) { | 1617 | if (ret > 0) { |
1601 | device->handler = handler; | 1618 | device->handler = handler; |
1602 | return ret; | 1619 | break; |
1603 | } else if (ret < 0) { | 1620 | } else if (ret < 0) { |
1604 | return ret; | 1621 | break; |
1605 | } | 1622 | } |
1606 | } | 1623 | } |
1607 | } | 1624 | } |
1608 | return 0; | ||
1609 | } | ||
1610 | |||
1611 | static int acpi_scan_attach_handler(struct acpi_device *device) | ||
1612 | { | ||
1613 | struct acpi_hardware_id *hwid; | ||
1614 | int ret = 0; | ||
1615 | |||
1616 | list_for_each_entry(hwid, &device->pnp.ids, list) { | ||
1617 | ret = acpi_scan_do_attach_handler(device, hwid->id); | ||
1618 | if (ret) | ||
1619 | break; | ||
1620 | |||
1621 | } | ||
1622 | return ret; | 1625 | return ret; |
1623 | } | 1626 | } |
1624 | 1627 | ||