summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-18 19:27:35 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-18 19:27:35 -0500
commitb8bd759acd05281abf88cddef30c57313c109697 (patch)
tree9ccbf63ea93bd2c41b8060987b8e670176090cbf /drivers/acpi/scan.c
parent5993c4670ea2453ef5abb45b312f150e994e6eb9 (diff)
ACPI / scan: Drop acpi_bus_add() and use acpi_bus_scan() instead
The only difference between acpi_bus_scan() and acpi_bus_add() is the invocation of acpi_update_all_gpes() in the latter which in fact is unnecessary, because acpi_update_all_gpes() has already been called by acpi_scan_init() and the way it is implemented guarantees the next invocations of it to do nothing. For this reason, drop acpi_bus_add() and make all its callers use acpi_bus_scan() directly instead of it. Additionally, rearrange the code in acpi_scan_init() slightly to improve the visibility of the acpi_update_all_gpes() call in there. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Yinghai Lu <yinghai@kernel.org>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r--drivers/acpi/scan.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 388b59c096dc..7c43bdc36abc 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1577,26 +1577,8 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
1577 return status; 1577 return status;
1578} 1578}
1579 1579
1580static int acpi_bus_scan(acpi_handle handle)
1581{
1582 void *device = NULL;
1583
1584 if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
1585 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1586 acpi_bus_check_add, NULL, NULL, &device);
1587
1588 if (!device)
1589 return -ENODEV;
1590
1591 if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL)))
1592 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1593 acpi_bus_device_attach, NULL, NULL, NULL);
1594
1595 return 0;
1596}
1597
1598/** 1580/**
1599 * acpi_bus_add - Add ACPI device node objects in a given namespace scope. 1581 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
1600 * @handle: Root of the namespace scope to scan. 1582 * @handle: Root of the namespace scope to scan.
1601 * 1583 *
1602 * Scan a given ACPI tree (probably recently hot-plugged) and create and add 1584 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
@@ -1607,18 +1589,24 @@ static int acpi_bus_scan(acpi_handle handle)
1607 * in the table trunk from which the kernel could create a device and add an 1589 * in the table trunk from which the kernel could create a device and add an
1608 * appropriate driver. 1590 * appropriate driver.
1609 */ 1591 */
1610int acpi_bus_add(acpi_handle handle) 1592int acpi_bus_scan(acpi_handle handle)
1611{ 1593{
1612 int err; 1594 void *device = NULL;
1613 1595
1614 err = acpi_bus_scan(handle); 1596 if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
1615 if (err) 1597 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1616 return err; 1598 acpi_bus_check_add, NULL, NULL, &device);
1599
1600 if (!device)
1601 return -ENODEV;
1602
1603 if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL)))
1604 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1605 acpi_bus_device_attach, NULL, NULL, NULL);
1617 1606
1618 acpi_update_all_gpes();
1619 return 0; 1607 return 0;
1620} 1608}
1621EXPORT_SYMBOL(acpi_bus_add); 1609EXPORT_SYMBOL(acpi_bus_scan);
1622 1610
1623static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used, 1611static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
1624 void *not_used, void **ret_not_used) 1612 void *not_used, void **ret_not_used)
@@ -1708,13 +1696,15 @@ int __init acpi_scan_init(void)
1708 return result; 1696 return result;
1709 1697
1710 result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root); 1698 result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
1711 if (!result)
1712 result = acpi_bus_scan_fixed();
1713
1714 if (result) 1699 if (result)
1700 return result;
1701
1702 result = acpi_bus_scan_fixed();
1703 if (result) {
1715 acpi_device_unregister(acpi_root); 1704 acpi_device_unregister(acpi_root);
1716 else 1705 return result;
1717 acpi_update_all_gpes(); 1706 }
1718 1707
1719 return result; 1708 acpi_update_all_gpes();
1709 return 0;
1720} 1710}