diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2009-09-21 15:30:01 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-09-25 14:24:30 -0400 |
commit | 402ac53614bce0c273c73a80339556bf56dd3d39 (patch) | |
tree | ee08b782ad49532e52712c077333ee88a042019c | |
parent | 51a85faf2d4ffecd8384b3f501f9f7ee2b05ee53 (diff) |
ACPI: add acpi_bus_get_status_handle()
Add acpi_bus_get_status_handle() so we can get the status of a namespace
object before building a struct acpi_device.
This removes a use of "device->flags.dynamic_status", a cached indicator of
whether _STA exists. It seems simpler and more reliable to just evaluate
_STA and catch AE_NOT_FOUND errors.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | drivers/acpi/bus.c | 49 | ||||
-rw-r--r-- | include/acpi/acpi_bus.h | 2 |
2 files changed, 24 insertions, 27 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 135fbfe1825c..741191524353 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -94,36 +94,33 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) | |||
94 | 94 | ||
95 | EXPORT_SYMBOL(acpi_bus_get_device); | 95 | EXPORT_SYMBOL(acpi_bus_get_device); |
96 | 96 | ||
97 | int acpi_bus_get_status(struct acpi_device *device) | 97 | acpi_status acpi_bus_get_status_handle(acpi_handle handle, |
98 | unsigned long long *sta) | ||
98 | { | 99 | { |
99 | acpi_status status = AE_OK; | 100 | acpi_status status; |
100 | unsigned long long sta = 0; | ||
101 | |||
102 | 101 | ||
103 | if (!device) | 102 | status = acpi_evaluate_integer(handle, "_STA", NULL, sta); |
104 | return -EINVAL; | 103 | if (ACPI_SUCCESS(status)) |
104 | return AE_OK; | ||
105 | 105 | ||
106 | /* | 106 | if (status == AE_NOT_FOUND) { |
107 | * Evaluate _STA if present. | 107 | *sta = ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | |
108 | */ | 108 | ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; |
109 | if (device->flags.dynamic_status) { | 109 | return AE_OK; |
110 | status = | ||
111 | acpi_evaluate_integer(device->handle, "_STA", NULL, &sta); | ||
112 | if (ACPI_FAILURE(status)) | ||
113 | return -ENODEV; | ||
114 | STRUCT_TO_INT(device->status) = (int)sta; | ||
115 | } | 110 | } |
111 | return status; | ||
112 | } | ||
116 | 113 | ||
117 | /* | 114 | int acpi_bus_get_status(struct acpi_device *device) |
118 | * According to ACPI spec some device can be present and functional | 115 | { |
119 | * even if the parent is not present but functional. | 116 | acpi_status status; |
120 | * In such conditions the child device should not inherit the status | 117 | unsigned long long sta; |
121 | * from the parent. | 118 | |
122 | */ | 119 | status = acpi_bus_get_status_handle(device->handle, &sta); |
123 | else | 120 | if (ACPI_FAILURE(status)) |
124 | STRUCT_TO_INT(device->status) = | 121 | return -ENODEV; |
125 | ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | | 122 | |
126 | ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; | 123 | STRUCT_TO_INT(device->status) = (int) sta; |
127 | 124 | ||
128 | if (device->status.functional && !device->status.present) { | 125 | if (device->status.functional && !device->status.present) { |
129 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " | 126 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " |
@@ -135,10 +132,8 @@ int acpi_bus_get_status(struct acpi_device *device) | |||
135 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", | 132 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", |
136 | device->pnp.bus_id, | 133 | device->pnp.bus_id, |
137 | (u32) STRUCT_TO_INT(device->status))); | 134 | (u32) STRUCT_TO_INT(device->status))); |
138 | |||
139 | return 0; | 135 | return 0; |
140 | } | 136 | } |
141 | |||
142 | EXPORT_SYMBOL(acpi_bus_get_status); | 137 | EXPORT_SYMBOL(acpi_bus_get_status); |
143 | 138 | ||
144 | void acpi_bus_private_data_handler(acpi_handle handle, | 139 | void acpi_bus_private_data_handler(acpi_handle handle, |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index bc7a69516dce..670f7f33837e 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -322,6 +322,8 @@ extern void unregister_acpi_bus_notifier(struct notifier_block *nb); | |||
322 | 322 | ||
323 | int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); | 323 | int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); |
324 | void acpi_bus_data_handler(acpi_handle handle, void *context); | 324 | void acpi_bus_data_handler(acpi_handle handle, void *context); |
325 | acpi_status acpi_bus_get_status_handle(acpi_handle handle, | ||
326 | unsigned long long *sta); | ||
325 | int acpi_bus_get_status(struct acpi_device *device); | 327 | int acpi_bus_get_status(struct acpi_device *device); |
326 | int acpi_bus_get_power(acpi_handle handle, int *state); | 328 | int acpi_bus_get_power(acpi_handle handle, int *state); |
327 | int acpi_bus_set_power(acpi_handle handle, int state); | 329 | int acpi_bus_set_power(acpi_handle handle, int state); |