diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2009-09-21 15:29:50 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-09-25 14:24:29 -0400 |
commit | 859ac9a4be0c753cece0e30a2e4a65fd2cdcaeee (patch) | |
tree | 10962790433ee0865ab6506c69981e8248368e46 | |
parent | adc08e2035f1859d4b129f42b2c2305ef090d226 (diff) |
ACPI: identify device tree root by null parent pointer, not ACPI_BUS_TYPE
We can identify the root of the ACPI device tree by the fact that it
has no parent. This is simpler than passing around ACPI_BUS_TYPE_SYSTEM
and will help remove special treatment of the device tree root.
Currently, we add the root by hand with ACPI_BUS_TYPE_SYSTEM. If we
traverse the tree treating the root as just another device and use
acpi_get_type(), the root shows up as ACPI_TYPE_DEVICE.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | drivers/acpi/scan.c | 20 | ||||
-rw-r--r-- | include/acpi/acpi_bus.h | 1 |
2 files changed, 13 insertions, 8 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 27d2dec55c6c..0b5aaf059c9b 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -22,6 +22,8 @@ extern struct acpi_device *acpi_root; | |||
22 | #define ACPI_BUS_HID "LNXSYBUS" | 22 | #define ACPI_BUS_HID "LNXSYBUS" |
23 | #define ACPI_BUS_DEVICE_NAME "System Bus" | 23 | #define ACPI_BUS_DEVICE_NAME "System Bus" |
24 | 24 | ||
25 | #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) | ||
26 | |||
25 | static LIST_HEAD(acpi_device_list); | 27 | static LIST_HEAD(acpi_device_list); |
26 | static LIST_HEAD(acpi_bus_id_list); | 28 | static LIST_HEAD(acpi_bus_id_list); |
27 | DEFINE_MUTEX(acpi_device_lock); | 29 | DEFINE_MUTEX(acpi_device_lock); |
@@ -955,10 +957,12 @@ static void acpi_device_get_busid(struct acpi_device *device) | |||
955 | * The device's Bus ID is simply the object name. | 957 | * The device's Bus ID is simply the object name. |
956 | * TBD: Shouldn't this value be unique (within the ACPI namespace)? | 958 | * TBD: Shouldn't this value be unique (within the ACPI namespace)? |
957 | */ | 959 | */ |
958 | switch (device->device_type) { | 960 | if (ACPI_IS_ROOT_DEVICE(device)) { |
959 | case ACPI_BUS_TYPE_SYSTEM: | ||
960 | strcpy(device->pnp.bus_id, "ACPI"); | 961 | strcpy(device->pnp.bus_id, "ACPI"); |
961 | break; | 962 | return; |
963 | } | ||
964 | |||
965 | switch (device->device_type) { | ||
962 | case ACPI_BUS_TYPE_POWER_BUTTON: | 966 | case ACPI_BUS_TYPE_POWER_BUTTON: |
963 | strcpy(device->pnp.bus_id, "PWRF"); | 967 | strcpy(device->pnp.bus_id, "PWRF"); |
964 | break; | 968 | break; |
@@ -1093,6 +1097,11 @@ static void acpi_device_set_id(struct acpi_device *device) | |||
1093 | 1097 | ||
1094 | switch (device->device_type) { | 1098 | switch (device->device_type) { |
1095 | case ACPI_BUS_TYPE_DEVICE: | 1099 | case ACPI_BUS_TYPE_DEVICE: |
1100 | if (ACPI_IS_ROOT_DEVICE(device)) { | ||
1101 | hid = ACPI_SYSTEM_HID; | ||
1102 | break; | ||
1103 | } | ||
1104 | |||
1096 | status = acpi_get_object_info(device->handle, &info); | 1105 | status = acpi_get_object_info(device->handle, &info); |
1097 | if (ACPI_FAILURE(status)) { | 1106 | if (ACPI_FAILURE(status)) { |
1098 | printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__); | 1107 | printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__); |
@@ -1129,9 +1138,6 @@ static void acpi_device_set_id(struct acpi_device *device) | |||
1129 | case ACPI_BUS_TYPE_PROCESSOR: | 1138 | case ACPI_BUS_TYPE_PROCESSOR: |
1130 | hid = ACPI_PROCESSOR_OBJECT_HID; | 1139 | hid = ACPI_PROCESSOR_OBJECT_HID; |
1131 | break; | 1140 | break; |
1132 | case ACPI_BUS_TYPE_SYSTEM: | ||
1133 | hid = ACPI_SYSTEM_HID; | ||
1134 | break; | ||
1135 | case ACPI_BUS_TYPE_THERMAL: | 1141 | case ACPI_BUS_TYPE_THERMAL: |
1136 | hid = ACPI_THERMAL_HID; | 1142 | hid = ACPI_THERMAL_HID; |
1137 | break; | 1143 | break; |
@@ -1643,7 +1649,7 @@ int __init acpi_scan_init(void) | |||
1643 | * Create the root device in the bus's device tree | 1649 | * Create the root device in the bus's device tree |
1644 | */ | 1650 | */ |
1645 | result = acpi_add_single_object(&acpi_root, ACPI_ROOT_OBJECT, | 1651 | result = acpi_add_single_object(&acpi_root, ACPI_ROOT_OBJECT, |
1646 | ACPI_BUS_TYPE_SYSTEM, &ops); | 1652 | ACPI_BUS_TYPE_DEVICE, &ops); |
1647 | if (result) | 1653 | if (result) |
1648 | goto Done; | 1654 | goto Done; |
1649 | 1655 | ||
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 8456e8cbf9fd..bc7a69516dce 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -70,7 +70,6 @@ enum acpi_bus_device_type { | |||
70 | ACPI_BUS_TYPE_POWER, | 70 | ACPI_BUS_TYPE_POWER, |
71 | ACPI_BUS_TYPE_PROCESSOR, | 71 | ACPI_BUS_TYPE_PROCESSOR, |
72 | ACPI_BUS_TYPE_THERMAL, | 72 | ACPI_BUS_TYPE_THERMAL, |
73 | ACPI_BUS_TYPE_SYSTEM, | ||
74 | ACPI_BUS_TYPE_POWER_BUTTON, | 73 | ACPI_BUS_TYPE_POWER_BUTTON, |
75 | ACPI_BUS_TYPE_SLEEP_BUTTON, | 74 | ACPI_BUS_TYPE_SLEEP_BUTTON, |
76 | ACPI_BUS_DEVICE_TYPE_COUNT | 75 | ACPI_BUS_DEVICE_TYPE_COUNT |