aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-02-06 07:05:22 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-02-13 07:41:38 -0500
commit87b85b3c8a4ac286d41a1c6419014b7562e4663b (patch)
tree292ec2771ebf354cd096f7396f06cd12d2806f9b /drivers/acpi/scan.c
parent73ce873a898ff385cd18e9068d38a35ff48e7585 (diff)
ACPI / scan: Follow priorities of IDs when matching scan handlers
The IDs of ACPI device nodes stored in their pnp.ids member arrays are sorted by decreasing priority (i.e. the highest-priority ID is the first entry). This means that when matching scan handlers to device nodes, the namespace scanning code should walk the list of scan handlers for each device node ID instead of walking the list of device node IDs for each handler (the latter causes the first handler matching any of the device node IDs to be chosen, although there may be another handler matching an ID of a higher priority which should be preferred). Make the code follow this observation. This change has been suggested and justified by Toshi Kani. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Toshi Kani <toshi.kani@hp.com>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r--drivers/acpi/scan.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 360f1338749b..688b7f7c23dd 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1553,26 +1553,42 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1553 return AE_OK; 1553 return AE_OK;
1554} 1554}
1555 1555
1556static int acpi_scan_attach_handler(struct acpi_device *device) 1556static int acpi_scan_do_attach_handler(struct acpi_device *device, char *id)
1557{ 1557{
1558 struct acpi_scan_handler *handler; 1558 struct acpi_scan_handler *handler;
1559 int ret = 0;
1560 1559
1561 list_for_each_entry(handler, &acpi_scan_handlers_list, list_node) { 1560 list_for_each_entry(handler, &acpi_scan_handlers_list, list_node) {
1562 const struct acpi_device_id *id; 1561 const struct acpi_device_id *devid;
1563 1562
1564 id = __acpi_match_device(device, handler->ids); 1563 for (devid = handler->ids; devid->id[0]; devid++) {
1565 if (!id) 1564 int ret;
1566 continue;
1567 1565
1568 ret = handler->attach(device, id); 1566 if (strcmp((char *)devid->id, id))
1569 if (ret > 0) { 1567 continue;
1570 device->handler = handler; 1568
1571 break; 1569 ret = handler->attach(device, devid);
1572 } else if (ret < 0) { 1570 if (ret > 0) {
1573 break; 1571 device->handler = handler;
1572 return ret;
1573 } else if (ret < 0) {
1574 return ret;
1575 }
1574 } 1576 }
1575 } 1577 }
1578 return 0;
1579}
1580
1581static int acpi_scan_attach_handler(struct acpi_device *device)
1582{
1583 struct acpi_hardware_id *hwid;
1584 int ret = 0;
1585
1586 list_for_each_entry(hwid, &device->pnp.ids, list) {
1587 ret = acpi_scan_do_attach_handler(device, hwid->id);
1588 if (ret)
1589 break;
1590
1591 }
1576 return ret; 1592 return ret;
1577} 1593}
1578 1594