aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/power.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/power.c')
-rw-r--r--drivers/acpi/power.c165
1 files changed, 70 insertions, 95 deletions
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 62a5595ed8bc..fec225d1b6b7 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
72struct acpi_power_resource { 72struct 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;
@@ -80,7 +80,7 @@ struct acpi_power_resource {
80 80
81static struct list_head acpi_power_resource_list; 81static struct list_head acpi_power_resource_list;
82 82
83static struct file_operations acpi_power_fops = { 83static const struct file_operations acpi_power_fops = {
84 .open = acpi_power_open_fs, 84 .open = acpi_power_open_fs,
85 .read = seq_read, 85 .read = seq_read,
86 .llseek = seq_lseek, 86 .llseek = seq_lseek,
@@ -98,23 +98,21 @@ acpi_power_get_context(acpi_handle handle,
98 int result = 0; 98 int result = 0;
99 struct acpi_device *device = NULL; 99 struct acpi_device *device = NULL;
100 100
101 ACPI_FUNCTION_TRACE("acpi_power_get_context");
102 101
103 if (!resource) 102 if (!resource)
104 return_VALUE(-ENODEV); 103 return -ENODEV;
105 104
106 result = acpi_bus_get_device(handle, &device); 105 result = acpi_bus_get_device(handle, &device);
107 if (result) { 106 if (result) {
108 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n", 107 printk(KERN_WARNING PREFIX "Getting context [%p]\n", handle);
109 handle)); 108 return result;
110 return_VALUE(result);
111 } 109 }
112 110
113 *resource = (struct acpi_power_resource *)acpi_driver_data(device); 111 *resource = (struct acpi_power_resource *)acpi_driver_data(device);
114 if (!resource) 112 if (!resource)
115 return_VALUE(-ENODEV); 113 return -ENODEV;
116 114
117 return_VALUE(0); 115 return 0;
118} 116}
119 117
120static int acpi_power_get_state(struct acpi_power_resource *resource) 118static int acpi_power_get_state(struct acpi_power_resource *resource)
@@ -122,14 +120,13 @@ static int acpi_power_get_state(struct acpi_power_resource *resource)
122 acpi_status status = AE_OK; 120 acpi_status status = AE_OK;
123 unsigned long sta = 0; 121 unsigned long sta = 0;
124 122
125 ACPI_FUNCTION_TRACE("acpi_power_get_state");
126 123
127 if (!resource) 124 if (!resource)
128 return_VALUE(-EINVAL); 125 return -EINVAL;
129 126
130 status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta); 127 status = acpi_evaluate_integer(resource->device->handle, "_STA", NULL, &sta);
131 if (ACPI_FAILURE(status)) 128 if (ACPI_FAILURE(status))
132 return_VALUE(-ENODEV); 129 return -ENODEV;
133 130
134 if (sta & 0x01) 131 if (sta & 0x01)
135 resource->state = ACPI_POWER_RESOURCE_STATE_ON; 132 resource->state = ACPI_POWER_RESOURCE_STATE_ON;
@@ -139,7 +136,7 @@ static int acpi_power_get_state(struct acpi_power_resource *resource)
139 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", 136 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
140 resource->name, resource->state ? "on" : "off")); 137 resource->name, resource->state ? "on" : "off"));
141 138
142 return_VALUE(0); 139 return 0;
143} 140}
144 141
145static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) 142static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
@@ -148,20 +145,19 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
148 struct acpi_power_resource *resource = NULL; 145 struct acpi_power_resource *resource = NULL;
149 u32 i = 0; 146 u32 i = 0;
150 147
151 ACPI_FUNCTION_TRACE("acpi_power_get_list_state");
152 148
153 if (!list || !state) 149 if (!list || !state)
154 return_VALUE(-EINVAL); 150 return -EINVAL;
155 151
156 /* The state of the list is 'on' IFF all resources are 'on'. */ 152 /* The state of the list is 'on' IFF all resources are 'on'. */
157 153
158 for (i = 0; i < list->count; i++) { 154 for (i = 0; i < list->count; i++) {
159 result = acpi_power_get_context(list->handles[i], &resource); 155 result = acpi_power_get_context(list->handles[i], &resource);
160 if (result) 156 if (result)
161 return_VALUE(result); 157 return result;
162 result = acpi_power_get_state(resource); 158 result = acpi_power_get_state(resource);
163 if (result) 159 if (result)
164 return_VALUE(result); 160 return result;
165 161
166 *state = resource->state; 162 *state = resource->state;
167 163
@@ -172,7 +168,7 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
172 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n", 168 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n",
173 *state ? "on" : "off")); 169 *state ? "on" : "off"));
174 170
175 return_VALUE(result); 171 return result;
176} 172}
177 173
178static int acpi_power_on(acpi_handle handle) 174static int acpi_power_on(acpi_handle handle)
@@ -182,11 +178,10 @@ static int acpi_power_on(acpi_handle handle)
182 struct acpi_device *device = NULL; 178 struct acpi_device *device = NULL;
183 struct acpi_power_resource *resource = NULL; 179 struct acpi_power_resource *resource = NULL;
184 180
185 ACPI_FUNCTION_TRACE("acpi_power_on");
186 181
187 result = acpi_power_get_context(handle, &resource); 182 result = acpi_power_get_context(handle, &resource);
188 if (result) 183 if (result)
189 return_VALUE(result); 184 return result;
190 185
191 resource->references++; 186 resource->references++;
192 187
@@ -194,29 +189,27 @@ static int acpi_power_on(acpi_handle handle)
194 || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) { 189 || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) {
195 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n", 190 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n",
196 resource->name)); 191 resource->name));
197 return_VALUE(0); 192 return 0;
198 } 193 }
199 194
200 status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL); 195 status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL);
201 if (ACPI_FAILURE(status)) 196 if (ACPI_FAILURE(status))
202 return_VALUE(-ENODEV); 197 return -ENODEV;
203 198
204 result = acpi_power_get_state(resource); 199 result = acpi_power_get_state(resource);
205 if (result) 200 if (result)
206 return_VALUE(result); 201 return result;
207 if (resource->state != ACPI_POWER_RESOURCE_STATE_ON) 202 if (resource->state != ACPI_POWER_RESOURCE_STATE_ON)
208 return_VALUE(-ENOEXEC); 203 return -ENOEXEC;
209 204
210 /* Update the power resource's _device_ power state */ 205 /* Update the power resource's _device_ power state */
211 result = acpi_bus_get_device(resource->handle, &device); 206 device = resource->device;
212 if (result) 207 resource->device->power.state = ACPI_STATE_D0;
213 return_VALUE(result);
214 device->power.state = ACPI_STATE_D0;
215 208
216 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n", 209 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n",
217 resource->name)); 210 resource->name));
218 211
219 return_VALUE(0); 212 return 0;
220} 213}
221 214
222static int acpi_power_off_device(acpi_handle handle) 215static int acpi_power_off_device(acpi_handle handle)
@@ -226,11 +219,10 @@ static int acpi_power_off_device(acpi_handle handle)
226 struct acpi_device *device = NULL; 219 struct acpi_device *device = NULL;
227 struct acpi_power_resource *resource = NULL; 220 struct acpi_power_resource *resource = NULL;
228 221
229 ACPI_FUNCTION_TRACE("acpi_power_off_device");
230 222
231 result = acpi_power_get_context(handle, &resource); 223 result = acpi_power_get_context(handle, &resource);
232 if (result) 224 if (result)
233 return_VALUE(result); 225 return result;
234 226
235 if (resource->references) 227 if (resource->references)
236 resource->references--; 228 resource->references--;
@@ -239,35 +231,33 @@ static int acpi_power_off_device(acpi_handle handle)
239 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 231 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
240 "Resource [%s] is still in use, dereferencing\n", 232 "Resource [%s] is still in use, dereferencing\n",
241 device->pnp.bus_id)); 233 device->pnp.bus_id));
242 return_VALUE(0); 234 return 0;
243 } 235 }
244 236
245 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { 237 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) {
246 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", 238 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n",
247 device->pnp.bus_id)); 239 device->pnp.bus_id));
248 return_VALUE(0); 240 return 0;
249 } 241 }
250 242
251 status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL); 243 status = acpi_evaluate_object(resource->device->handle, "_OFF", NULL, NULL);
252 if (ACPI_FAILURE(status)) 244 if (ACPI_FAILURE(status))
253 return_VALUE(-ENODEV); 245 return -ENODEV;
254 246
255 result = acpi_power_get_state(resource); 247 result = acpi_power_get_state(resource);
256 if (result) 248 if (result)
257 return_VALUE(result); 249 return result;
258 if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF) 250 if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF)
259 return_VALUE(-ENOEXEC); 251 return -ENOEXEC;
260 252
261 /* Update the power resource's _device_ power state */ 253 /* Update the power resource's _device_ power state */
262 result = acpi_bus_get_device(resource->handle, &device); 254 device = resource->device;
263 if (result)
264 return_VALUE(result);
265 device->power.state = ACPI_STATE_D3; 255 device->power.state = ACPI_STATE_D3;
266 256
267 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", 257 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n",
268 resource->name)); 258 resource->name));
269 259
270 return_VALUE(0); 260 return 0;
271} 261}
272 262
273/* 263/*
@@ -283,31 +273,29 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev)
283 int i; 273 int i;
284 int ret = 0; 274 int ret = 0;
285 275
286 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_power");
287 if (!dev || !dev->wakeup.flags.valid) 276 if (!dev || !dev->wakeup.flags.valid)
288 return_VALUE(-1); 277 return -1;
289 278
290 arg.integer.value = 1; 279 arg.integer.value = 1;
291 /* Open power resource */ 280 /* Open power resource */
292 for (i = 0; i < dev->wakeup.resources.count; i++) { 281 for (i = 0; i < dev->wakeup.resources.count; i++) {
293 ret = acpi_power_on(dev->wakeup.resources.handles[i]); 282 ret = acpi_power_on(dev->wakeup.resources.handles[i]);
294 if (ret) { 283 if (ret) {
295 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 284 printk(KERN_ERR PREFIX "Transition power state\n");
296 "Error transition power state\n"));
297 dev->wakeup.flags.valid = 0; 285 dev->wakeup.flags.valid = 0;
298 return_VALUE(-1); 286 return -1;
299 } 287 }
300 } 288 }
301 289
302 /* Execute PSW */ 290 /* Execute PSW */
303 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); 291 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL);
304 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 292 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
305 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n")); 293 printk(KERN_ERR PREFIX "Evaluate _PSW\n");
306 dev->wakeup.flags.valid = 0; 294 dev->wakeup.flags.valid = 0;
307 ret = -1; 295 ret = -1;
308 } 296 }
309 297
310 return_VALUE(ret); 298 return ret;
311} 299}
312 300
313/* 301/*
@@ -323,32 +311,30 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
323 int i; 311 int i;
324 int ret = 0; 312 int ret = 0;
325 313
326 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device_power");
327 314
328 if (!dev || !dev->wakeup.flags.valid) 315 if (!dev || !dev->wakeup.flags.valid)
329 return_VALUE(-1); 316 return -1;
330 317
331 arg.integer.value = 0; 318 arg.integer.value = 0;
332 /* Execute PSW */ 319 /* Execute PSW */
333 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); 320 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL);
334 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 321 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
335 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n")); 322 printk(KERN_ERR PREFIX "Evaluate _PSW\n");
336 dev->wakeup.flags.valid = 0; 323 dev->wakeup.flags.valid = 0;
337 return_VALUE(-1); 324 return -1;
338 } 325 }
339 326
340 /* Close power resource */ 327 /* Close power resource */
341 for (i = 0; i < dev->wakeup.resources.count; i++) { 328 for (i = 0; i < dev->wakeup.resources.count; i++) {
342 ret = acpi_power_off_device(dev->wakeup.resources.handles[i]); 329 ret = acpi_power_off_device(dev->wakeup.resources.handles[i]);
343 if (ret) { 330 if (ret) {
344 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 331 printk(KERN_ERR PREFIX "Transition power state\n");
345 "Error transition power state\n"));
346 dev->wakeup.flags.valid = 0; 332 dev->wakeup.flags.valid = 0;
347 return_VALUE(-1); 333 return -1;
348 } 334 }
349 } 335 }
350 336
351 return_VALUE(ret); 337 return ret;
352} 338}
353 339
354/* -------------------------------------------------------------------------- 340/* --------------------------------------------------------------------------
@@ -362,10 +348,9 @@ int acpi_power_get_inferred_state(struct acpi_device *device)
362 int list_state = 0; 348 int list_state = 0;
363 int i = 0; 349 int i = 0;
364 350
365 ACPI_FUNCTION_TRACE("acpi_power_get_inferred_state");
366 351
367 if (!device) 352 if (!device)
368 return_VALUE(-EINVAL); 353 return -EINVAL;
369 354
370 device->power.state = ACPI_STATE_UNKNOWN; 355 device->power.state = ACPI_STATE_UNKNOWN;
371 356
@@ -380,17 +365,17 @@ int acpi_power_get_inferred_state(struct acpi_device *device)
380 365
381 result = acpi_power_get_list_state(list, &list_state); 366 result = acpi_power_get_list_state(list, &list_state);
382 if (result) 367 if (result)
383 return_VALUE(result); 368 return result;
384 369
385 if (list_state == ACPI_POWER_RESOURCE_STATE_ON) { 370 if (list_state == ACPI_POWER_RESOURCE_STATE_ON) {
386 device->power.state = i; 371 device->power.state = i;
387 return_VALUE(0); 372 return 0;
388 } 373 }
389 } 374 }
390 375
391 device->power.state = ACPI_STATE_D3; 376 device->power.state = ACPI_STATE_D3;
392 377
393 return_VALUE(0); 378 return 0;
394} 379}
395 380
396int acpi_power_transition(struct acpi_device *device, int state) 381int acpi_power_transition(struct acpi_device *device, int state)
@@ -400,14 +385,13 @@ int acpi_power_transition(struct acpi_device *device, int state)
400 struct acpi_handle_list *tl = NULL; /* Target Resources */ 385 struct acpi_handle_list *tl = NULL; /* Target Resources */
401 int i = 0; 386 int i = 0;
402 387
403 ACPI_FUNCTION_TRACE("acpi_power_transition");
404 388
405 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) 389 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
406 return_VALUE(-EINVAL); 390 return -EINVAL;
407 391
408 if ((device->power.state < ACPI_STATE_D0) 392 if ((device->power.state < ACPI_STATE_D0)
409 || (device->power.state > ACPI_STATE_D3)) 393 || (device->power.state > ACPI_STATE_D3))
410 return_VALUE(-ENODEV); 394 return -ENODEV;
411 395
412 cl = &device->power.states[device->power.state].resources; 396 cl = &device->power.states[device->power.state].resources;
413 tl = &device->power.states[state].resources; 397 tl = &device->power.states[state].resources;
@@ -444,11 +428,10 @@ int acpi_power_transition(struct acpi_device *device, int state)
444 device->power.state = state; 428 device->power.state = state;
445 end: 429 end:
446 if (result) 430 if (result)
447 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 431 printk(KERN_WARNING PREFIX "Transitioning device [%s] to D%d\n",
448 "Error transitioning device [%s] to D%d\n", 432 device->pnp.bus_id, state);
449 device->pnp.bus_id, state));
450 433
451 return_VALUE(result); 434 return result;
452} 435}
453 436
454/* -------------------------------------------------------------------------- 437/* --------------------------------------------------------------------------
@@ -461,7 +444,6 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
461{ 444{
462 struct acpi_power_resource *resource = NULL; 445 struct acpi_power_resource *resource = NULL;
463 446
464 ACPI_FUNCTION_TRACE("acpi_power_seq_show");
465 447
466 resource = (struct acpi_power_resource *)seq->private; 448 resource = (struct acpi_power_resource *)seq->private;
467 449
@@ -488,7 +470,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
488 resource->order, resource->references); 470 resource->order, resource->references);
489 471
490 end: 472 end:
491 return_VALUE(0); 473 return 0;
492} 474}
493 475
494static int acpi_power_open_fs(struct inode *inode, struct file *file) 476static int acpi_power_open_fs(struct inode *inode, struct file *file)
@@ -500,36 +482,32 @@ static int acpi_power_add_fs(struct acpi_device *device)
500{ 482{
501 struct proc_dir_entry *entry = NULL; 483 struct proc_dir_entry *entry = NULL;
502 484
503 ACPI_FUNCTION_TRACE("acpi_power_add_fs");
504 485
505 if (!device) 486 if (!device)
506 return_VALUE(-EINVAL); 487 return -EINVAL;
507 488
508 if (!acpi_device_dir(device)) { 489 if (!acpi_device_dir(device)) {
509 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 490 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
510 acpi_power_dir); 491 acpi_power_dir);
511 if (!acpi_device_dir(device)) 492 if (!acpi_device_dir(device))
512 return_VALUE(-ENODEV); 493 return -ENODEV;
513 } 494 }
514 495
515 /* 'status' [R] */ 496 /* 'status' [R] */
516 entry = create_proc_entry(ACPI_POWER_FILE_STATUS, 497 entry = create_proc_entry(ACPI_POWER_FILE_STATUS,
517 S_IRUGO, acpi_device_dir(device)); 498 S_IRUGO, acpi_device_dir(device));
518 if (!entry) 499 if (!entry)
519 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 500 return -EIO;
520 "Unable to create '%s' fs entry\n",
521 ACPI_POWER_FILE_STATUS));
522 else { 501 else {
523 entry->proc_fops = &acpi_power_fops; 502 entry->proc_fops = &acpi_power_fops;
524 entry->data = acpi_driver_data(device); 503 entry->data = acpi_driver_data(device);
525 } 504 }
526 505
527 return_VALUE(0); 506 return 0;
528} 507}
529 508
530static int acpi_power_remove_fs(struct acpi_device *device) 509static int acpi_power_remove_fs(struct acpi_device *device)
531{ 510{
532 ACPI_FUNCTION_TRACE("acpi_power_remove_fs");
533 511
534 if (acpi_device_dir(device)) { 512 if (acpi_device_dir(device)) {
535 remove_proc_entry(ACPI_POWER_FILE_STATUS, 513 remove_proc_entry(ACPI_POWER_FILE_STATUS,
@@ -538,7 +516,7 @@ static int acpi_power_remove_fs(struct acpi_device *device)
538 acpi_device_dir(device) = NULL; 516 acpi_device_dir(device) = NULL;
539 } 517 }
540 518
541 return_VALUE(0); 519 return 0;
542} 520}
543 521
544/* -------------------------------------------------------------------------- 522/* --------------------------------------------------------------------------
@@ -553,24 +531,23 @@ static int acpi_power_add(struct acpi_device *device)
553 union acpi_object acpi_object; 531 union acpi_object acpi_object;
554 struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object }; 532 struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
555 533
556 ACPI_FUNCTION_TRACE("acpi_power_add");
557 534
558 if (!device) 535 if (!device)
559 return_VALUE(-EINVAL); 536 return -EINVAL;
560 537
561 resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL); 538 resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
562 if (!resource) 539 if (!resource)
563 return_VALUE(-ENOMEM); 540 return -ENOMEM;
564 memset(resource, 0, sizeof(struct acpi_power_resource)); 541 memset(resource, 0, sizeof(struct acpi_power_resource));
565 542
566 resource->handle = device->handle; 543 resource->device = device;
567 strcpy(resource->name, device->pnp.bus_id); 544 strcpy(resource->name, device->pnp.bus_id);
568 strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); 545 strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
569 strcpy(acpi_device_class(device), ACPI_POWER_CLASS); 546 strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
570 acpi_driver_data(device) = resource; 547 acpi_driver_data(device) = resource;
571 548
572 /* Evalute the object to get the system level and resource order. */ 549 /* Evalute the object to get the system level and resource order. */
573 status = acpi_evaluate_object(resource->handle, NULL, NULL, &buffer); 550 status = acpi_evaluate_object(device->handle, NULL, NULL, &buffer);
574 if (ACPI_FAILURE(status)) { 551 if (ACPI_FAILURE(status)) {
575 result = -ENODEV; 552 result = -ENODEV;
576 goto end; 553 goto end;
@@ -605,17 +582,16 @@ static int acpi_power_add(struct acpi_device *device)
605 if (result) 582 if (result)
606 kfree(resource); 583 kfree(resource);
607 584
608 return_VALUE(result); 585 return result;
609} 586}
610 587
611static int acpi_power_remove(struct acpi_device *device, int type) 588static int acpi_power_remove(struct acpi_device *device, int type)
612{ 589{
613 struct acpi_power_resource *resource = NULL; 590 struct acpi_power_resource *resource = NULL;
614 591
615 ACPI_FUNCTION_TRACE("acpi_power_remove");
616 592
617 if (!device || !acpi_driver_data(device)) 593 if (!device || !acpi_driver_data(device))
618 return_VALUE(-EINVAL); 594 return -EINVAL;
619 595
620 resource = (struct acpi_power_resource *)acpi_driver_data(device); 596 resource = (struct acpi_power_resource *)acpi_driver_data(device);
621 597
@@ -623,31 +599,30 @@ static int acpi_power_remove(struct acpi_device *device, int type)
623 599
624 kfree(resource); 600 kfree(resource);
625 601
626 return_VALUE(0); 602 return 0;
627} 603}
628 604
629static int __init acpi_power_init(void) 605static int __init acpi_power_init(void)
630{ 606{
631 int result = 0; 607 int result = 0;
632 608
633 ACPI_FUNCTION_TRACE("acpi_power_init");
634 609
635 if (acpi_disabled) 610 if (acpi_disabled)
636 return_VALUE(0); 611 return 0;
637 612
638 INIT_LIST_HEAD(&acpi_power_resource_list); 613 INIT_LIST_HEAD(&acpi_power_resource_list);
639 614
640 acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir); 615 acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir);
641 if (!acpi_power_dir) 616 if (!acpi_power_dir)
642 return_VALUE(-ENODEV); 617 return -ENODEV;
643 618
644 result = acpi_bus_register_driver(&acpi_power_driver); 619 result = acpi_bus_register_driver(&acpi_power_driver);
645 if (result < 0) { 620 if (result < 0) {
646 remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir); 621 remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir);
647 return_VALUE(-ENODEV); 622 return -ENODEV;
648 } 623 }
649 624
650 return_VALUE(0); 625 return 0;
651} 626}
652 627
653subsys_initcall(acpi_power_init); 628subsys_initcall(acpi_power_init);