diff options
Diffstat (limited to 'drivers/acpi/power.c')
-rw-r--r-- | drivers/acpi/power.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 224f729f700e..5d3447f4582c 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -70,7 +70,7 @@ static struct acpi_driver acpi_power_driver = { | |||
70 | }; | 70 | }; |
71 | 71 | ||
72 | struct acpi_power_resource { | 72 | struct acpi_power_resource { |
73 | acpi_handle handle; | 73 | struct acpi_device * device; |
74 | acpi_bus_id name; | 74 | acpi_bus_id name; |
75 | u32 system_level; | 75 | u32 system_level; |
76 | u32 order; | 76 | u32 order; |
@@ -124,7 +124,7 @@ static int acpi_power_get_state(struct acpi_power_resource *resource) | |||
124 | if (!resource) | 124 | if (!resource) |
125 | return -EINVAL; | 125 | return -EINVAL; |
126 | 126 | ||
127 | status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta); | 127 | status = acpi_evaluate_integer(resource->device->handle, "_STA", NULL, &sta); |
128 | if (ACPI_FAILURE(status)) | 128 | if (ACPI_FAILURE(status)) |
129 | return -ENODEV; | 129 | return -ENODEV; |
130 | 130 | ||
@@ -192,7 +192,7 @@ static int acpi_power_on(acpi_handle handle) | |||
192 | return 0; | 192 | return 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL); | 195 | status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL); |
196 | if (ACPI_FAILURE(status)) | 196 | if (ACPI_FAILURE(status)) |
197 | return -ENODEV; | 197 | return -ENODEV; |
198 | 198 | ||
@@ -203,10 +203,8 @@ static int acpi_power_on(acpi_handle handle) | |||
203 | return -ENOEXEC; | 203 | return -ENOEXEC; |
204 | 204 | ||
205 | /* Update the power resource's _device_ power state */ | 205 | /* Update the power resource's _device_ power state */ |
206 | result = acpi_bus_get_device(resource->handle, &device); | 206 | device = resource->device; |
207 | if (result) | 207 | resource->device->power.state = ACPI_STATE_D0; |
208 | return result; | ||
209 | device->power.state = ACPI_STATE_D0; | ||
210 | 208 | ||
211 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n", | 209 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n", |
212 | resource->name)); | 210 | resource->name)); |
@@ -242,7 +240,7 @@ static int acpi_power_off_device(acpi_handle handle) | |||
242 | return 0; | 240 | return 0; |
243 | } | 241 | } |
244 | 242 | ||
245 | status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL); | 243 | status = acpi_evaluate_object(resource->device->handle, "_OFF", NULL, NULL); |
246 | if (ACPI_FAILURE(status)) | 244 | if (ACPI_FAILURE(status)) |
247 | return -ENODEV; | 245 | return -ENODEV; |
248 | 246 | ||
@@ -253,9 +251,7 @@ static int acpi_power_off_device(acpi_handle handle) | |||
253 | return -ENOEXEC; | 251 | return -ENOEXEC; |
254 | 252 | ||
255 | /* Update the power resource's _device_ power state */ | 253 | /* Update the power resource's _device_ power state */ |
256 | result = acpi_bus_get_device(resource->handle, &device); | 254 | device = resource->device; |
257 | if (result) | ||
258 | return result; | ||
259 | device->power.state = ACPI_STATE_D3; | 255 | device->power.state = ACPI_STATE_D3; |
260 | 256 | ||
261 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", | 257 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", |
@@ -544,14 +540,14 @@ static int acpi_power_add(struct acpi_device *device) | |||
544 | return -ENOMEM; | 540 | return -ENOMEM; |
545 | memset(resource, 0, sizeof(struct acpi_power_resource)); | 541 | memset(resource, 0, sizeof(struct acpi_power_resource)); |
546 | 542 | ||
547 | resource->handle = device->handle; | 543 | resource->device = device; |
548 | strcpy(resource->name, device->pnp.bus_id); | 544 | strcpy(resource->name, device->pnp.bus_id); |
549 | strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); | 545 | strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); |
550 | strcpy(acpi_device_class(device), ACPI_POWER_CLASS); | 546 | strcpy(acpi_device_class(device), ACPI_POWER_CLASS); |
551 | acpi_driver_data(device) = resource; | 547 | acpi_driver_data(device) = resource; |
552 | 548 | ||
553 | /* Evalute the object to get the system level and resource order. */ | 549 | /* Evalute the object to get the system level and resource order. */ |
554 | status = acpi_evaluate_object(resource->handle, NULL, NULL, &buffer); | 550 | status = acpi_evaluate_object(device->handle, NULL, NULL, &buffer); |
555 | if (ACPI_FAILURE(status)) { | 551 | if (ACPI_FAILURE(status)) { |
556 | result = -ENODEV; | 552 | result = -ENODEV; |
557 | goto end; | 553 | goto end; |