diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2012-12-20 18:36:41 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-01-03 07:09:37 -0500 |
commit | 0fc300b0537c6a6a7f2b261b6c339dc498cd1702 (patch) | |
tree | 38560515f89a302cbe721334abce59f5acf4bb4d /drivers/acpi/scan.c | |
parent | 92ef2a25c763338905dce8344a0584606f842920 (diff) |
ACPI: Make acpi_bus_add() and acpi_bus_start() visibly different
The current ACPI namespace scanning code suggests that acpi_bus_add()
and acpi_bus_start() share some code. In fact, however, they are
completely different code paths (except for the initial checks), so
refactor the code to make that distinction visibly clear.
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.c | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index a7e81ac2cd0c..f3bcaf6c6bd4 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -1623,10 +1623,9 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, | |||
1623 | return AE_OK; | 1623 | return AE_OK; |
1624 | } | 1624 | } |
1625 | 1625 | ||
1626 | static acpi_status acpi_bus_probe_start(acpi_handle handle, u32 lvl, | 1626 | static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, |
1627 | void *context, void **not_used) | 1627 | void *not_used, void **ret_not_used) |
1628 | { | 1628 | { |
1629 | struct acpi_bus_ops *ops = context; | ||
1630 | acpi_status status = AE_OK; | 1629 | acpi_status status = AE_OK; |
1631 | struct acpi_device *device; | 1630 | struct acpi_device *device; |
1632 | unsigned long long sta_not_used; | 1631 | unsigned long long sta_not_used; |
@@ -1642,16 +1641,11 @@ static acpi_status acpi_bus_probe_start(acpi_handle handle, u32 lvl, | |||
1642 | if (acpi_bus_get_device(handle, &device)) | 1641 | if (acpi_bus_get_device(handle, &device)) |
1643 | return AE_CTRL_DEPTH; | 1642 | return AE_CTRL_DEPTH; |
1644 | 1643 | ||
1645 | if (ops->acpi_op_add) { | 1644 | if (!acpi_match_device_ids(device, acpi_platform_device_ids)) { |
1646 | if (!acpi_match_device_ids(device, acpi_platform_device_ids)) { | 1645 | /* This is a known good platform device. */ |
1647 | /* This is a known good platform device. */ | 1646 | acpi_create_platform_device(device); |
1648 | acpi_create_platform_device(device); | 1647 | } else if (device_attach(&device->dev)) { |
1649 | } else if (device_attach(&device->dev)) { | 1648 | status = AE_CTRL_DEPTH; |
1650 | status = AE_CTRL_DEPTH; | ||
1651 | } | ||
1652 | } else if (ops->acpi_op_start) { | ||
1653 | if (ACPI_FAILURE(acpi_start_single_object(device))) | ||
1654 | status = AE_CTRL_DEPTH; | ||
1655 | } | 1649 | } |
1656 | return status; | 1650 | return status; |
1657 | } | 1651 | } |
@@ -1672,10 +1666,10 @@ static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops, | |||
1672 | goto out; | 1666 | goto out; |
1673 | 1667 | ||
1674 | ret = 0; | 1668 | ret = 0; |
1675 | status = acpi_bus_probe_start(handle, 0, ops, NULL); | 1669 | status = acpi_bus_device_attach(handle, 0, NULL, NULL); |
1676 | if (ACPI_SUCCESS(status)) | 1670 | if (ACPI_SUCCESS(status)) |
1677 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | 1671 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, |
1678 | acpi_bus_probe_start, NULL, ops, NULL); | 1672 | acpi_bus_device_attach, NULL, NULL, NULL); |
1679 | 1673 | ||
1680 | out: | 1674 | out: |
1681 | if (child) | 1675 | if (child) |
@@ -1700,31 +1694,44 @@ int | |||
1700 | acpi_bus_add(struct acpi_device **child, | 1694 | acpi_bus_add(struct acpi_device **child, |
1701 | struct acpi_device *parent, acpi_handle handle, int type) | 1695 | struct acpi_device *parent, acpi_handle handle, int type) |
1702 | { | 1696 | { |
1703 | struct acpi_bus_ops ops; | 1697 | struct acpi_bus_ops ops = { .acpi_op_add = 1, }; |
1704 | |||
1705 | memset(&ops, 0, sizeof(ops)); | ||
1706 | ops.acpi_op_add = 1; | ||
1707 | 1698 | ||
1708 | return acpi_bus_scan(handle, &ops, child); | 1699 | return acpi_bus_scan(handle, &ops, child); |
1709 | } | 1700 | } |
1710 | EXPORT_SYMBOL(acpi_bus_add); | 1701 | EXPORT_SYMBOL(acpi_bus_add); |
1711 | 1702 | ||
1712 | int acpi_bus_start(struct acpi_device *device) | 1703 | static acpi_status acpi_bus_start_device(acpi_handle handle, u32 lvl, |
1704 | void *not_used, void **ret_not_used) | ||
1713 | { | 1705 | { |
1714 | struct acpi_bus_ops ops; | 1706 | struct acpi_device *device; |
1715 | int result; | 1707 | unsigned long long sta_not_used; |
1708 | int type_not_used; | ||
1709 | |||
1710 | /* | ||
1711 | * Ignore errors ignored by acpi_bus_check_add() to avoid terminating | ||
1712 | * namespace walks prematurely. | ||
1713 | */ | ||
1714 | if (acpi_bus_type_and_status(handle, &type_not_used, &sta_not_used)) | ||
1715 | return AE_OK; | ||
1716 | |||
1717 | if (acpi_bus_get_device(handle, &device)) | ||
1718 | return AE_CTRL_DEPTH; | ||
1719 | |||
1720 | return acpi_start_single_object(device); | ||
1721 | } | ||
1716 | 1722 | ||
1723 | int acpi_bus_start(struct acpi_device *device) | ||
1724 | { | ||
1717 | if (!device) | 1725 | if (!device) |
1718 | return -EINVAL; | 1726 | return -EINVAL; |
1719 | 1727 | ||
1720 | memset(&ops, 0, sizeof(ops)); | 1728 | if (ACPI_SUCCESS(acpi_start_single_object(device))) |
1721 | ops.acpi_op_start = 1; | 1729 | acpi_walk_namespace(ACPI_TYPE_ANY, device->handle, |
1722 | 1730 | ACPI_UINT32_MAX, acpi_bus_start_device, | |
1723 | result = acpi_bus_scan(device->handle, &ops, NULL); | 1731 | NULL, NULL, NULL); |
1724 | 1732 | ||
1725 | acpi_update_all_gpes(); | 1733 | acpi_update_all_gpes(); |
1726 | 1734 | return 0; | |
1727 | return result; | ||
1728 | } | 1735 | } |
1729 | EXPORT_SYMBOL(acpi_bus_start); | 1736 | EXPORT_SYMBOL(acpi_bus_start); |
1730 | 1737 | ||