diff options
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r-- | drivers/acpi/battery.c | 122 |
1 files changed, 47 insertions, 75 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 702e857e98c5..00b0728efe82 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -132,17 +132,16 @@ acpi_battery_get_info(struct acpi_battery *battery, | |||
132 | struct acpi_buffer data = { 0, NULL }; | 132 | struct acpi_buffer data = { 0, NULL }; |
133 | union acpi_object *package = NULL; | 133 | union acpi_object *package = NULL; |
134 | 134 | ||
135 | ACPI_FUNCTION_TRACE("acpi_battery_get_info"); | ||
136 | 135 | ||
137 | if (!battery || !bif) | 136 | if (!battery || !bif) |
138 | return_VALUE(-EINVAL); | 137 | return -EINVAL; |
139 | 138 | ||
140 | /* Evalute _BIF */ | 139 | /* Evalute _BIF */ |
141 | 140 | ||
142 | status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer); | 141 | status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer); |
143 | if (ACPI_FAILURE(status)) { | 142 | if (ACPI_FAILURE(status)) { |
144 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BIF\n")); | 143 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); |
145 | return_VALUE(-ENODEV); | 144 | return -ENODEV; |
146 | } | 145 | } |
147 | 146 | ||
148 | package = (union acpi_object *)buffer.pointer; | 147 | package = (union acpi_object *)buffer.pointer; |
@@ -151,7 +150,7 @@ acpi_battery_get_info(struct acpi_battery *battery, | |||
151 | 150 | ||
152 | status = acpi_extract_package(package, &format, &data); | 151 | status = acpi_extract_package(package, &format, &data); |
153 | if (status != AE_BUFFER_OVERFLOW) { | 152 | if (status != AE_BUFFER_OVERFLOW) { |
154 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n")); | 153 | ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF")); |
155 | result = -ENODEV; | 154 | result = -ENODEV; |
156 | goto end; | 155 | goto end; |
157 | } | 156 | } |
@@ -165,7 +164,7 @@ acpi_battery_get_info(struct acpi_battery *battery, | |||
165 | 164 | ||
166 | status = acpi_extract_package(package, &format, &data); | 165 | status = acpi_extract_package(package, &format, &data); |
167 | if (ACPI_FAILURE(status)) { | 166 | if (ACPI_FAILURE(status)) { |
168 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n")); | 167 | ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF")); |
169 | kfree(data.pointer); | 168 | kfree(data.pointer); |
170 | result = -ENODEV; | 169 | result = -ENODEV; |
171 | goto end; | 170 | goto end; |
@@ -177,7 +176,7 @@ acpi_battery_get_info(struct acpi_battery *battery, | |||
177 | if (!result) | 176 | if (!result) |
178 | (*bif) = (struct acpi_battery_info *)data.pointer; | 177 | (*bif) = (struct acpi_battery_info *)data.pointer; |
179 | 178 | ||
180 | return_VALUE(result); | 179 | return result; |
181 | } | 180 | } |
182 | 181 | ||
183 | static int | 182 | static int |
@@ -193,17 +192,16 @@ acpi_battery_get_status(struct acpi_battery *battery, | |||
193 | struct acpi_buffer data = { 0, NULL }; | 192 | struct acpi_buffer data = { 0, NULL }; |
194 | union acpi_object *package = NULL; | 193 | union acpi_object *package = NULL; |
195 | 194 | ||
196 | ACPI_FUNCTION_TRACE("acpi_battery_get_status"); | ||
197 | 195 | ||
198 | if (!battery || !bst) | 196 | if (!battery || !bst) |
199 | return_VALUE(-EINVAL); | 197 | return -EINVAL; |
200 | 198 | ||
201 | /* Evalute _BST */ | 199 | /* Evalute _BST */ |
202 | 200 | ||
203 | status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer); | 201 | status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer); |
204 | if (ACPI_FAILURE(status)) { | 202 | if (ACPI_FAILURE(status)) { |
205 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BST\n")); | 203 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST")); |
206 | return_VALUE(-ENODEV); | 204 | return -ENODEV; |
207 | } | 205 | } |
208 | 206 | ||
209 | package = (union acpi_object *)buffer.pointer; | 207 | package = (union acpi_object *)buffer.pointer; |
@@ -212,7 +210,7 @@ acpi_battery_get_status(struct acpi_battery *battery, | |||
212 | 210 | ||
213 | status = acpi_extract_package(package, &format, &data); | 211 | status = acpi_extract_package(package, &format, &data); |
214 | if (status != AE_BUFFER_OVERFLOW) { | 212 | if (status != AE_BUFFER_OVERFLOW) { |
215 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n")); | 213 | ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST")); |
216 | result = -ENODEV; | 214 | result = -ENODEV; |
217 | goto end; | 215 | goto end; |
218 | } | 216 | } |
@@ -226,7 +224,7 @@ acpi_battery_get_status(struct acpi_battery *battery, | |||
226 | 224 | ||
227 | status = acpi_extract_package(package, &format, &data); | 225 | status = acpi_extract_package(package, &format, &data); |
228 | if (ACPI_FAILURE(status)) { | 226 | if (ACPI_FAILURE(status)) { |
229 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n")); | 227 | ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST")); |
230 | kfree(data.pointer); | 228 | kfree(data.pointer); |
231 | result = -ENODEV; | 229 | result = -ENODEV; |
232 | goto end; | 230 | goto end; |
@@ -238,7 +236,7 @@ acpi_battery_get_status(struct acpi_battery *battery, | |||
238 | if (!result) | 236 | if (!result) |
239 | (*bst) = (struct acpi_battery_status *)data.pointer; | 237 | (*bst) = (struct acpi_battery_status *)data.pointer; |
240 | 238 | ||
241 | return_VALUE(result); | 239 | return result; |
242 | } | 240 | } |
243 | 241 | ||
244 | static int | 242 | static int |
@@ -248,25 +246,24 @@ acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm) | |||
248 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; | 246 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; |
249 | struct acpi_object_list arg_list = { 1, &arg0 }; | 247 | struct acpi_object_list arg_list = { 1, &arg0 }; |
250 | 248 | ||
251 | ACPI_FUNCTION_TRACE("acpi_battery_set_alarm"); | ||
252 | 249 | ||
253 | if (!battery) | 250 | if (!battery) |
254 | return_VALUE(-EINVAL); | 251 | return -EINVAL; |
255 | 252 | ||
256 | if (!battery->flags.alarm) | 253 | if (!battery->flags.alarm) |
257 | return_VALUE(-ENODEV); | 254 | return -ENODEV; |
258 | 255 | ||
259 | arg0.integer.value = alarm; | 256 | arg0.integer.value = alarm; |
260 | 257 | ||
261 | status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL); | 258 | status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL); |
262 | if (ACPI_FAILURE(status)) | 259 | if (ACPI_FAILURE(status)) |
263 | return_VALUE(-ENODEV); | 260 | return -ENODEV; |
264 | 261 | ||
265 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm)); | 262 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm)); |
266 | 263 | ||
267 | battery->alarm = alarm; | 264 | battery->alarm = alarm; |
268 | 265 | ||
269 | return_VALUE(0); | 266 | return 0; |
270 | } | 267 | } |
271 | 268 | ||
272 | static int acpi_battery_check(struct acpi_battery *battery) | 269 | static int acpi_battery_check(struct acpi_battery *battery) |
@@ -277,18 +274,17 @@ static int acpi_battery_check(struct acpi_battery *battery) | |||
277 | struct acpi_device *device = NULL; | 274 | struct acpi_device *device = NULL; |
278 | struct acpi_battery_info *bif = NULL; | 275 | struct acpi_battery_info *bif = NULL; |
279 | 276 | ||
280 | ACPI_FUNCTION_TRACE("acpi_battery_check"); | ||
281 | 277 | ||
282 | if (!battery) | 278 | if (!battery) |
283 | return_VALUE(-EINVAL); | 279 | return -EINVAL; |
284 | 280 | ||
285 | result = acpi_bus_get_device(battery->handle, &device); | 281 | result = acpi_bus_get_device(battery->handle, &device); |
286 | if (result) | 282 | if (result) |
287 | return_VALUE(result); | 283 | return result; |
288 | 284 | ||
289 | result = acpi_bus_get_status(device); | 285 | result = acpi_bus_get_status(device); |
290 | if (result) | 286 | if (result) |
291 | return_VALUE(result); | 287 | return result; |
292 | 288 | ||
293 | /* Insertion? */ | 289 | /* Insertion? */ |
294 | 290 | ||
@@ -300,7 +296,7 @@ static int acpi_battery_check(struct acpi_battery *battery) | |||
300 | 296 | ||
301 | result = acpi_battery_get_info(battery, &bif); | 297 | result = acpi_battery_get_info(battery, &bif); |
302 | if (result) | 298 | if (result) |
303 | return_VALUE(result); | 299 | return result; |
304 | 300 | ||
305 | battery->flags.power_unit = bif->power_unit; | 301 | battery->flags.power_unit = bif->power_unit; |
306 | battery->trips.warning = bif->design_capacity_warning; | 302 | battery->trips.warning = bif->design_capacity_warning; |
@@ -324,7 +320,7 @@ static int acpi_battery_check(struct acpi_battery *battery) | |||
324 | 320 | ||
325 | battery->flags.present = device->status.battery_present; | 321 | battery->flags.present = device->status.battery_present; |
326 | 322 | ||
327 | return_VALUE(result); | 323 | return result; |
328 | } | 324 | } |
329 | 325 | ||
330 | /* -------------------------------------------------------------------------- | 326 | /* -------------------------------------------------------------------------- |
@@ -339,7 +335,6 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset) | |||
339 | struct acpi_battery_info *bif = NULL; | 335 | struct acpi_battery_info *bif = NULL; |
340 | char *units = "?"; | 336 | char *units = "?"; |
341 | 337 | ||
342 | ACPI_FUNCTION_TRACE("acpi_battery_read_info"); | ||
343 | 338 | ||
344 | if (!battery) | 339 | if (!battery) |
345 | goto end; | 340 | goto end; |
@@ -409,7 +404,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset) | |||
409 | end: | 404 | end: |
410 | kfree(bif); | 405 | kfree(bif); |
411 | 406 | ||
412 | return_VALUE(0); | 407 | return 0; |
413 | } | 408 | } |
414 | 409 | ||
415 | static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) | 410 | static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) |
@@ -424,7 +419,6 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset) | |||
424 | struct acpi_battery_status *bst = NULL; | 419 | struct acpi_battery_status *bst = NULL; |
425 | char *units = "?"; | 420 | char *units = "?"; |
426 | 421 | ||
427 | ACPI_FUNCTION_TRACE("acpi_battery_read_state"); | ||
428 | 422 | ||
429 | if (!battery) | 423 | if (!battery) |
430 | goto end; | 424 | goto end; |
@@ -458,8 +452,6 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset) | |||
458 | if ((bst->state & 0x01) && (bst->state & 0x02)) { | 452 | if ((bst->state & 0x01) && (bst->state & 0x02)) { |
459 | seq_printf(seq, | 453 | seq_printf(seq, |
460 | "charging state: charging/discharging\n"); | 454 | "charging state: charging/discharging\n"); |
461 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
462 | "Battery Charging and Discharging?\n")); | ||
463 | } else if (bst->state & 0x01) | 455 | } else if (bst->state & 0x01) |
464 | seq_printf(seq, "charging state: discharging\n"); | 456 | seq_printf(seq, "charging state: discharging\n"); |
465 | else if (bst->state & 0x02) | 457 | else if (bst->state & 0x02) |
@@ -489,7 +481,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset) | |||
489 | end: | 481 | end: |
490 | kfree(bst); | 482 | kfree(bst); |
491 | 483 | ||
492 | return_VALUE(0); | 484 | return 0; |
493 | } | 485 | } |
494 | 486 | ||
495 | static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) | 487 | static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) |
@@ -502,7 +494,6 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) | |||
502 | struct acpi_battery *battery = (struct acpi_battery *)seq->private; | 494 | struct acpi_battery *battery = (struct acpi_battery *)seq->private; |
503 | char *units = "?"; | 495 | char *units = "?"; |
504 | 496 | ||
505 | ACPI_FUNCTION_TRACE("acpi_battery_read_alarm"); | ||
506 | 497 | ||
507 | if (!battery) | 498 | if (!battery) |
508 | goto end; | 499 | goto end; |
@@ -527,7 +518,7 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) | |||
527 | seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units); | 518 | seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units); |
528 | 519 | ||
529 | end: | 520 | end: |
530 | return_VALUE(0); | 521 | return 0; |
531 | } | 522 | } |
532 | 523 | ||
533 | static ssize_t | 524 | static ssize_t |
@@ -540,25 +531,24 @@ acpi_battery_write_alarm(struct file *file, | |||
540 | struct seq_file *m = (struct seq_file *)file->private_data; | 531 | struct seq_file *m = (struct seq_file *)file->private_data; |
541 | struct acpi_battery *battery = (struct acpi_battery *)m->private; | 532 | struct acpi_battery *battery = (struct acpi_battery *)m->private; |
542 | 533 | ||
543 | ACPI_FUNCTION_TRACE("acpi_battery_write_alarm"); | ||
544 | 534 | ||
545 | if (!battery || (count > sizeof(alarm_string) - 1)) | 535 | if (!battery || (count > sizeof(alarm_string) - 1)) |
546 | return_VALUE(-EINVAL); | 536 | return -EINVAL; |
547 | 537 | ||
548 | if (!battery->flags.present) | 538 | if (!battery->flags.present) |
549 | return_VALUE(-ENODEV); | 539 | return -ENODEV; |
550 | 540 | ||
551 | if (copy_from_user(alarm_string, buffer, count)) | 541 | if (copy_from_user(alarm_string, buffer, count)) |
552 | return_VALUE(-EFAULT); | 542 | return -EFAULT; |
553 | 543 | ||
554 | alarm_string[count] = '\0'; | 544 | alarm_string[count] = '\0'; |
555 | 545 | ||
556 | result = acpi_battery_set_alarm(battery, | 546 | result = acpi_battery_set_alarm(battery, |
557 | simple_strtoul(alarm_string, NULL, 0)); | 547 | simple_strtoul(alarm_string, NULL, 0)); |
558 | if (result) | 548 | if (result) |
559 | return_VALUE(result); | 549 | return result; |
560 | 550 | ||
561 | return_VALUE(count); | 551 | return count; |
562 | } | 552 | } |
563 | 553 | ||
564 | static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) | 554 | static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) |
@@ -595,13 +585,12 @@ static int acpi_battery_add_fs(struct acpi_device *device) | |||
595 | { | 585 | { |
596 | struct proc_dir_entry *entry = NULL; | 586 | struct proc_dir_entry *entry = NULL; |
597 | 587 | ||
598 | ACPI_FUNCTION_TRACE("acpi_battery_add_fs"); | ||
599 | 588 | ||
600 | if (!acpi_device_dir(device)) { | 589 | if (!acpi_device_dir(device)) { |
601 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), | 590 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), |
602 | acpi_battery_dir); | 591 | acpi_battery_dir); |
603 | if (!acpi_device_dir(device)) | 592 | if (!acpi_device_dir(device)) |
604 | return_VALUE(-ENODEV); | 593 | return -ENODEV; |
605 | acpi_device_dir(device)->owner = THIS_MODULE; | 594 | acpi_device_dir(device)->owner = THIS_MODULE; |
606 | } | 595 | } |
607 | 596 | ||
@@ -609,9 +598,7 @@ static int acpi_battery_add_fs(struct acpi_device *device) | |||
609 | entry = create_proc_entry(ACPI_BATTERY_FILE_INFO, | 598 | entry = create_proc_entry(ACPI_BATTERY_FILE_INFO, |
610 | S_IRUGO, acpi_device_dir(device)); | 599 | S_IRUGO, acpi_device_dir(device)); |
611 | if (!entry) | 600 | if (!entry) |
612 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 601 | return -ENODEV; |
613 | "Unable to create '%s' fs entry\n", | ||
614 | ACPI_BATTERY_FILE_INFO)); | ||
615 | else { | 602 | else { |
616 | entry->proc_fops = &acpi_battery_info_ops; | 603 | entry->proc_fops = &acpi_battery_info_ops; |
617 | entry->data = acpi_driver_data(device); | 604 | entry->data = acpi_driver_data(device); |
@@ -622,9 +609,7 @@ static int acpi_battery_add_fs(struct acpi_device *device) | |||
622 | entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS, | 609 | entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS, |
623 | S_IRUGO, acpi_device_dir(device)); | 610 | S_IRUGO, acpi_device_dir(device)); |
624 | if (!entry) | 611 | if (!entry) |
625 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 612 | return -ENODEV; |
626 | "Unable to create '%s' fs entry\n", | ||
627 | ACPI_BATTERY_FILE_STATUS)); | ||
628 | else { | 613 | else { |
629 | entry->proc_fops = &acpi_battery_state_ops; | 614 | entry->proc_fops = &acpi_battery_state_ops; |
630 | entry->data = acpi_driver_data(device); | 615 | entry->data = acpi_driver_data(device); |
@@ -636,21 +621,18 @@ static int acpi_battery_add_fs(struct acpi_device *device) | |||
636 | S_IFREG | S_IRUGO | S_IWUSR, | 621 | S_IFREG | S_IRUGO | S_IWUSR, |
637 | acpi_device_dir(device)); | 622 | acpi_device_dir(device)); |
638 | if (!entry) | 623 | if (!entry) |
639 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 624 | return -ENODEV; |
640 | "Unable to create '%s' fs entry\n", | ||
641 | ACPI_BATTERY_FILE_ALARM)); | ||
642 | else { | 625 | else { |
643 | entry->proc_fops = &acpi_battery_alarm_ops; | 626 | entry->proc_fops = &acpi_battery_alarm_ops; |
644 | entry->data = acpi_driver_data(device); | 627 | entry->data = acpi_driver_data(device); |
645 | entry->owner = THIS_MODULE; | 628 | entry->owner = THIS_MODULE; |
646 | } | 629 | } |
647 | 630 | ||
648 | return_VALUE(0); | 631 | return 0; |
649 | } | 632 | } |
650 | 633 | ||
651 | static int acpi_battery_remove_fs(struct acpi_device *device) | 634 | static int acpi_battery_remove_fs(struct acpi_device *device) |
652 | { | 635 | { |
653 | ACPI_FUNCTION_TRACE("acpi_battery_remove_fs"); | ||
654 | 636 | ||
655 | if (acpi_device_dir(device)) { | 637 | if (acpi_device_dir(device)) { |
656 | remove_proc_entry(ACPI_BATTERY_FILE_ALARM, | 638 | remove_proc_entry(ACPI_BATTERY_FILE_ALARM, |
@@ -664,7 +646,7 @@ static int acpi_battery_remove_fs(struct acpi_device *device) | |||
664 | acpi_device_dir(device) = NULL; | 646 | acpi_device_dir(device) = NULL; |
665 | } | 647 | } |
666 | 648 | ||
667 | return_VALUE(0); | 649 | return 0; |
668 | } | 650 | } |
669 | 651 | ||
670 | /* -------------------------------------------------------------------------- | 652 | /* -------------------------------------------------------------------------- |
@@ -676,13 +658,12 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) | |||
676 | struct acpi_battery *battery = (struct acpi_battery *)data; | 658 | struct acpi_battery *battery = (struct acpi_battery *)data; |
677 | struct acpi_device *device = NULL; | 659 | struct acpi_device *device = NULL; |
678 | 660 | ||
679 | ACPI_FUNCTION_TRACE("acpi_battery_notify"); | ||
680 | 661 | ||
681 | if (!battery) | 662 | if (!battery) |
682 | return_VOID; | 663 | return; |
683 | 664 | ||
684 | if (acpi_bus_get_device(handle, &device)) | 665 | if (acpi_bus_get_device(handle, &device)) |
685 | return_VOID; | 666 | return; |
686 | 667 | ||
687 | switch (event) { | 668 | switch (event) { |
688 | case ACPI_BATTERY_NOTIFY_STATUS: | 669 | case ACPI_BATTERY_NOTIFY_STATUS: |
@@ -696,7 +677,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) | |||
696 | break; | 677 | break; |
697 | } | 678 | } |
698 | 679 | ||
699 | return_VOID; | 680 | return; |
700 | } | 681 | } |
701 | 682 | ||
702 | static int acpi_battery_add(struct acpi_device *device) | 683 | static int acpi_battery_add(struct acpi_device *device) |
@@ -705,14 +686,13 @@ static int acpi_battery_add(struct acpi_device *device) | |||
705 | acpi_status status = 0; | 686 | acpi_status status = 0; |
706 | struct acpi_battery *battery = NULL; | 687 | struct acpi_battery *battery = NULL; |
707 | 688 | ||
708 | ACPI_FUNCTION_TRACE("acpi_battery_add"); | ||
709 | 689 | ||
710 | if (!device) | 690 | if (!device) |
711 | return_VALUE(-EINVAL); | 691 | return -EINVAL; |
712 | 692 | ||
713 | battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL); | 693 | battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL); |
714 | if (!battery) | 694 | if (!battery) |
715 | return_VALUE(-ENOMEM); | 695 | return -ENOMEM; |
716 | memset(battery, 0, sizeof(struct acpi_battery)); | 696 | memset(battery, 0, sizeof(struct acpi_battery)); |
717 | 697 | ||
718 | battery->handle = device->handle; | 698 | battery->handle = device->handle; |
@@ -732,8 +712,6 @@ static int acpi_battery_add(struct acpi_device *device) | |||
732 | ACPI_DEVICE_NOTIFY, | 712 | ACPI_DEVICE_NOTIFY, |
733 | acpi_battery_notify, battery); | 713 | acpi_battery_notify, battery); |
734 | if (ACPI_FAILURE(status)) { | 714 | if (ACPI_FAILURE(status)) { |
735 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
736 | "Error installing notify handler\n")); | ||
737 | result = -ENODEV; | 715 | result = -ENODEV; |
738 | goto end; | 716 | goto end; |
739 | } | 717 | } |
@@ -748,7 +726,7 @@ static int acpi_battery_add(struct acpi_device *device) | |||
748 | kfree(battery); | 726 | kfree(battery); |
749 | } | 727 | } |
750 | 728 | ||
751 | return_VALUE(result); | 729 | return result; |
752 | } | 730 | } |
753 | 731 | ||
754 | static int acpi_battery_remove(struct acpi_device *device, int type) | 732 | static int acpi_battery_remove(struct acpi_device *device, int type) |
@@ -756,56 +734,50 @@ static int acpi_battery_remove(struct acpi_device *device, int type) | |||
756 | acpi_status status = 0; | 734 | acpi_status status = 0; |
757 | struct acpi_battery *battery = NULL; | 735 | struct acpi_battery *battery = NULL; |
758 | 736 | ||
759 | ACPI_FUNCTION_TRACE("acpi_battery_remove"); | ||
760 | 737 | ||
761 | if (!device || !acpi_driver_data(device)) | 738 | if (!device || !acpi_driver_data(device)) |
762 | return_VALUE(-EINVAL); | 739 | return -EINVAL; |
763 | 740 | ||
764 | battery = (struct acpi_battery *)acpi_driver_data(device); | 741 | battery = (struct acpi_battery *)acpi_driver_data(device); |
765 | 742 | ||
766 | status = acpi_remove_notify_handler(battery->handle, | 743 | status = acpi_remove_notify_handler(battery->handle, |
767 | ACPI_DEVICE_NOTIFY, | 744 | ACPI_DEVICE_NOTIFY, |
768 | acpi_battery_notify); | 745 | acpi_battery_notify); |
769 | if (ACPI_FAILURE(status)) | ||
770 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
771 | "Error removing notify handler\n")); | ||
772 | 746 | ||
773 | acpi_battery_remove_fs(device); | 747 | acpi_battery_remove_fs(device); |
774 | 748 | ||
775 | kfree(battery); | 749 | kfree(battery); |
776 | 750 | ||
777 | return_VALUE(0); | 751 | return 0; |
778 | } | 752 | } |
779 | 753 | ||
780 | static int __init acpi_battery_init(void) | 754 | static int __init acpi_battery_init(void) |
781 | { | 755 | { |
782 | int result = 0; | 756 | int result = 0; |
783 | 757 | ||
784 | ACPI_FUNCTION_TRACE("acpi_battery_init"); | ||
785 | 758 | ||
786 | acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); | 759 | acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); |
787 | if (!acpi_battery_dir) | 760 | if (!acpi_battery_dir) |
788 | return_VALUE(-ENODEV); | 761 | return -ENODEV; |
789 | acpi_battery_dir->owner = THIS_MODULE; | 762 | acpi_battery_dir->owner = THIS_MODULE; |
790 | 763 | ||
791 | result = acpi_bus_register_driver(&acpi_battery_driver); | 764 | result = acpi_bus_register_driver(&acpi_battery_driver); |
792 | if (result < 0) { | 765 | if (result < 0) { |
793 | remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); | 766 | remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); |
794 | return_VALUE(-ENODEV); | 767 | return -ENODEV; |
795 | } | 768 | } |
796 | 769 | ||
797 | return_VALUE(0); | 770 | return 0; |
798 | } | 771 | } |
799 | 772 | ||
800 | static void __exit acpi_battery_exit(void) | 773 | static void __exit acpi_battery_exit(void) |
801 | { | 774 | { |
802 | ACPI_FUNCTION_TRACE("acpi_battery_exit"); | ||
803 | 775 | ||
804 | acpi_bus_unregister_driver(&acpi_battery_driver); | 776 | acpi_bus_unregister_driver(&acpi_battery_driver); |
805 | 777 | ||
806 | remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); | 778 | remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); |
807 | 779 | ||
808 | return_VOID; | 780 | return; |
809 | } | 781 | } |
810 | 782 | ||
811 | module_init(acpi_battery_init); | 783 | module_init(acpi_battery_init); |