aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-12-20 18:36:42 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-03 07:09:37 -0500
commitca7b3c4f3d85bf7ec225eebb43b6af0a25499c6c (patch)
tree82203954bc46948c502ef9e9d5d1d88efd5ca807 /drivers/acpi/scan.c
parent0fc300b0537c6a6a7f2b261b6c339dc498cd1702 (diff)
ACPI: Reduce the usage of struct acpi_bus_ops
Objects of type struct acpi_bus_ops are currently used to pass information between different parts of the ACPI namespace scanning code, sometimes in quite convoluted ways. It turns out that that is not necessary in some cases, so simplify the code by reducing the utilization of struct acpi_bus_ops objects where clearly possible. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Yinghai Lu <yinghai@kernel.org> 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, 16 insertions, 24 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index f3bcaf6c6bd4..8dde0e7f68d8 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1527,7 +1527,6 @@ end:
1527static void acpi_bus_add_power_resource(acpi_handle handle) 1527static void acpi_bus_add_power_resource(acpi_handle handle)
1528{ 1528{
1529 struct acpi_bus_ops ops = { 1529 struct acpi_bus_ops ops = {
1530 .acpi_op_add = 1,
1531 .acpi_op_start = 1, 1530 .acpi_op_start = 1,
1532 .acpi_op_match = 1, 1531 .acpi_op_match = 1,
1533 }; 1532 };
@@ -1581,7 +1580,6 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,
1581static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, 1580static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl,
1582 void *context, void **return_value) 1581 void *context, void **return_value)
1583{ 1582{
1584 struct acpi_bus_ops *ops = context;
1585 struct acpi_device *device = NULL; 1583 struct acpi_device *device = NULL;
1586 int type; 1584 int type;
1587 unsigned long long sta; 1585 unsigned long long sta;
@@ -1605,11 +1603,13 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl,
1605 } 1603 }
1606 1604
1607 acpi_bus_get_device(handle, &device); 1605 acpi_bus_get_device(handle, &device);
1608 if (ops->acpi_op_add && !device) { 1606 if (!device) {
1609 struct acpi_bus_ops add_ops = *ops; 1607 struct acpi_bus_ops ops = {
1608 .acpi_op_start = !!context,
1609 .acpi_op_match = 0,
1610 };
1610 1611
1611 add_ops.acpi_op_match = 0; 1612 acpi_add_single_object(&device, handle, type, sta, &ops);
1612 acpi_add_single_object(&device, handle, type, sta, &add_ops);
1613 if (!device) 1613 if (!device)
1614 return AE_CTRL_DEPTH; 1614 return AE_CTRL_DEPTH;
1615 1615
@@ -1650,17 +1650,18 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
1650 return status; 1650 return status;
1651} 1651}
1652 1652
1653static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops, 1653static int acpi_bus_scan(acpi_handle handle, bool start,
1654 struct acpi_device **child) 1654 struct acpi_device **child)
1655{ 1655{
1656 void *device = NULL; 1656 void *device = NULL;
1657 acpi_status status; 1657 acpi_status status;
1658 int ret = -ENODEV; 1658 int ret = -ENODEV;
1659 1659
1660 status = acpi_bus_check_add(handle, 0, ops, &device); 1660 status = acpi_bus_check_add(handle, 0, (void *)start, &device);
1661 if (ACPI_SUCCESS(status)) 1661 if (ACPI_SUCCESS(status))
1662 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 1662 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1663 acpi_bus_check_add, NULL, ops, &device); 1663 acpi_bus_check_add, NULL, (void *)start,
1664 &device);
1664 1665
1665 if (!device) 1666 if (!device)
1666 goto out; 1667 goto out;
@@ -1694,9 +1695,7 @@ int
1694acpi_bus_add(struct acpi_device **child, 1695acpi_bus_add(struct acpi_device **child,
1695 struct acpi_device *parent, acpi_handle handle, int type) 1696 struct acpi_device *parent, acpi_handle handle, int type)
1696{ 1697{
1697 struct acpi_bus_ops ops = { .acpi_op_add = 1, }; 1698 return acpi_bus_scan(handle, false, child);
1698
1699 return acpi_bus_scan(handle, &ops, child);
1700} 1699}
1701EXPORT_SYMBOL(acpi_bus_add); 1700EXPORT_SYMBOL(acpi_bus_add);
1702 1701
@@ -1794,12 +1793,10 @@ static int acpi_bus_scan_fixed(void)
1794{ 1793{
1795 int result = 0; 1794 int result = 0;
1796 struct acpi_device *device = NULL; 1795 struct acpi_device *device = NULL;
1797 struct acpi_bus_ops ops; 1796 struct acpi_bus_ops ops = {
1798 1797 .acpi_op_start = 1,
1799 memset(&ops, 0, sizeof(ops)); 1798 .acpi_op_match = 1,
1800 ops.acpi_op_add = 1; 1799 };
1801 ops.acpi_op_start = 1;
1802 ops.acpi_op_match = 1;
1803 1800
1804 /* 1801 /*
1805 * Enumerate all fixed-feature devices. 1802 * Enumerate all fixed-feature devices.
@@ -1825,11 +1822,6 @@ static int acpi_bus_scan_fixed(void)
1825int __init acpi_scan_init(void) 1822int __init acpi_scan_init(void)
1826{ 1823{
1827 int result; 1824 int result;
1828 struct acpi_bus_ops ops;
1829
1830 memset(&ops, 0, sizeof(ops));
1831 ops.acpi_op_add = 1;
1832 ops.acpi_op_start = 1;
1833 1825
1834 result = bus_register(&acpi_bus_type); 1826 result = bus_register(&acpi_bus_type);
1835 if (result) { 1827 if (result) {
@@ -1843,7 +1835,7 @@ int __init acpi_scan_init(void)
1843 /* 1835 /*
1844 * Enumerate devices in the ACPI namespace. 1836 * Enumerate devices in the ACPI namespace.
1845 */ 1837 */
1846 result = acpi_bus_scan(ACPI_ROOT_OBJECT, &ops, &acpi_root); 1838 result = acpi_bus_scan(ACPI_ROOT_OBJECT, true, &acpi_root);
1847 1839
1848 if (!result) 1840 if (!result)
1849 result = acpi_bus_scan_fixed(); 1841 result = acpi_bus_scan_fixed();