2 * acpi_battery.c - ACPI Battery Driver ($Revision: 37 $)
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <linux/init.h>
29 #include <linux/types.h>
30 #include <linux/proc_fs.h>
31 #include <linux/seq_file.h>
32 #include <asm/uaccess.h>
34 #include <acpi/acpi_bus.h>
35 #include <acpi/acpi_drivers.h>
37 #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF
39 #define ACPI_BATTERY_FORMAT_BIF "NNNNNNNNNSSSS"
40 #define ACPI_BATTERY_FORMAT_BST "NNNN"
42 #define ACPI_BATTERY_COMPONENT 0x00040000
43 #define ACPI_BATTERY_CLASS "battery"
44 #define ACPI_BATTERY_DEVICE_NAME "Battery"
45 #define ACPI_BATTERY_NOTIFY_STATUS 0x80
46 #define ACPI_BATTERY_NOTIFY_INFO 0x81
47 #define ACPI_BATTERY_UNITS_WATTS "mW"
48 #define ACPI_BATTERY_UNITS_AMPS "mA"
50 #define _COMPONENT ACPI_BATTERY_COMPONENT
52 #define ACPI_BATTERY_UPDATE_TIME 0
54 #define ACPI_BATTERY_NONE_UPDATE 0
55 #define ACPI_BATTERY_EASY_UPDATE 1
56 #define ACPI_BATTERY_INIT_UPDATE 2
58 ACPI_MODULE_NAME("battery");
60 MODULE_AUTHOR("Paul Diefenbaugh");
61 MODULE_DESCRIPTION("ACPI Battery Driver");
62 MODULE_LICENSE("GPL");
64 static unsigned int update_time = ACPI_BATTERY_UPDATE_TIME;
66 /* 0 - every time, > 0 - by update_time */
67 module_param(update_time, uint, 0644);
69 extern struct proc_dir_entry *acpi_lock_battery_dir(void);
70 extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
72 static int acpi_battery_add(struct acpi_device *device);
73 static int acpi_battery_remove(struct acpi_device *device, int type);
74 static int acpi_battery_resume(struct acpi_device *device);
76 static const struct acpi_device_id battery_device_ids[] = {
80 MODULE_DEVICE_TABLE(acpi, battery_device_ids);
82 static struct acpi_driver acpi_battery_driver = {
84 .class = ACPI_BATTERY_CLASS,
85 .ids = battery_device_ids,
87 .add = acpi_battery_add,
88 .resume = acpi_battery_resume,
89 .remove = acpi_battery_remove,
93 struct acpi_battery_state {
95 acpi_integer present_rate;
96 acpi_integer remaining_capacity;
97 acpi_integer present_voltage;
100 struct acpi_battery_info {
101 acpi_integer power_unit;
102 acpi_integer design_capacity;
103 acpi_integer last_full_capacity;
104 acpi_integer battery_technology;
105 acpi_integer design_voltage;
106 acpi_integer design_capacity_warning;
107 acpi_integer design_capacity_low;
108 acpi_integer battery_capacity_granularity_1;
109 acpi_integer battery_capacity_granularity_2;
110 acpi_string model_number;
111 acpi_string serial_number;
112 acpi_string battery_type;
113 acpi_string oem_info;
116 enum acpi_battery_files{
117 ACPI_BATTERY_INFO = 0,
120 ACPI_BATTERY_NUMFILES,
123 struct acpi_battery_flags {
124 u8 battery_present_prev;
127 u8 update[ACPI_BATTERY_NUMFILES];
131 struct acpi_battery {
133 struct acpi_device *device;
134 struct acpi_battery_flags flags;
135 struct acpi_buffer bif_data;
136 struct acpi_buffer bst_data;
138 unsigned long update_time[ACPI_BATTERY_NUMFILES];
141 inline int acpi_battery_present(struct acpi_battery *battery)
143 return battery->device->status.battery_present;
145 inline char *acpi_battery_power_units(struct acpi_battery *battery)
147 if (battery->flags.power_unit)
148 return ACPI_BATTERY_UNITS_AMPS;
150 return ACPI_BATTERY_UNITS_WATTS;
153 inline acpi_handle acpi_battery_handle(struct acpi_battery *battery)
155 return battery->device->handle;
158 /* --------------------------------------------------------------------------
160 -------------------------------------------------------------------------- */
162 static void acpi_battery_check_result(struct acpi_battery *battery, int result)
168 battery->flags.init_update = 1;
172 static int acpi_battery_extract_package(struct acpi_battery *battery,
173 union acpi_object *package,
174 struct acpi_buffer *format,
175 struct acpi_buffer *data,
178 acpi_status status = AE_OK;
179 struct acpi_buffer data_null = { 0, NULL };
181 status = acpi_extract_package(package, format, &data_null);
182 if (status != AE_BUFFER_OVERFLOW) {
183 ACPI_EXCEPTION((AE_INFO, status, "Extracting size %s",
188 if (data_null.length != data->length) {
189 kfree(data->pointer);
190 data->pointer = kzalloc(data_null.length, GFP_KERNEL);
191 if (!data->pointer) {
192 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, "kzalloc()"));
195 data->length = data_null.length;
198 status = acpi_extract_package(package, format, data);
199 if (ACPI_FAILURE(status)) {
200 ACPI_EXCEPTION((AE_INFO, status, "Extracting %s",
208 static int acpi_battery_get_status(struct acpi_battery *battery)
212 result = acpi_bus_get_status(battery->device);
214 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Evaluating _STA"));
220 static int acpi_battery_get_info(struct acpi_battery *battery)
223 acpi_status status = 0;
224 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
225 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BIF),
226 ACPI_BATTERY_FORMAT_BIF
228 union acpi_object *package = NULL;
229 struct acpi_buffer *data = NULL;
230 struct acpi_battery_info *bif = NULL;
232 battery->update_time[ACPI_BATTERY_INFO] = get_seconds();
234 if (!acpi_battery_present(battery))
240 acpi_evaluate_object(acpi_battery_handle(battery), "_BIF", NULL,
242 if (ACPI_FAILURE(status)) {
243 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
247 package = buffer.pointer;
249 data = &battery->bif_data;
251 /* Extract Package Data */
254 acpi_battery_extract_package(battery, package, &format, data,
261 kfree(buffer.pointer);
265 battery->flags.power_unit = bif->power_unit;
271 static int acpi_battery_get_state(struct acpi_battery *battery)
274 acpi_status status = 0;
275 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
276 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BST),
277 ACPI_BATTERY_FORMAT_BST
279 union acpi_object *package = NULL;
280 struct acpi_buffer *data = NULL;
282 battery->update_time[ACPI_BATTERY_STATE] = get_seconds();
284 if (!acpi_battery_present(battery))
290 acpi_evaluate_object(acpi_battery_handle(battery), "_BST", NULL,
292 if (ACPI_FAILURE(status)) {
293 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
297 package = buffer.pointer;
299 data = &battery->bst_data;
301 /* Extract Package Data */
304 acpi_battery_extract_package(battery, package, &format, data,
310 kfree(buffer.pointer);
315 static int acpi_battery_get_alarm(struct acpi_battery *battery)
317 battery->update_time[ACPI_BATTERY_ALARM] = get_seconds();
322 static int acpi_battery_set_alarm(struct acpi_battery *battery,
325 acpi_status status = 0;
326 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
327 struct acpi_object_list arg_list = { 1, &arg0 };
329 battery->update_time[ACPI_BATTERY_ALARM] = get_seconds();
331 if (!acpi_battery_present(battery))
334 if (!battery->flags.alarm_present)
337 arg0.integer.value = alarm;
340 acpi_evaluate_object(acpi_battery_handle(battery), "_BTP",
342 if (ACPI_FAILURE(status))
345 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm));
347 battery->alarm = alarm;
352 static int acpi_battery_init_alarm(struct acpi_battery *battery)
355 acpi_status status = AE_OK;
356 acpi_handle handle = NULL;
357 struct acpi_battery_info *bif = battery->bif_data.pointer;
358 unsigned long alarm = battery->alarm;
360 /* See if alarms are supported, and if so, set default */
362 status = acpi_get_handle(acpi_battery_handle(battery), "_BTP", &handle);
363 if (ACPI_SUCCESS(status)) {
364 battery->flags.alarm_present = 1;
366 alarm = bif->design_capacity_warning;
368 result = acpi_battery_set_alarm(battery, alarm);
372 battery->flags.alarm_present = 0;
380 static int acpi_battery_init_update(struct acpi_battery *battery)
384 result = acpi_battery_get_status(battery);
388 battery->flags.battery_present_prev = acpi_battery_present(battery);
390 if (acpi_battery_present(battery)) {
391 result = acpi_battery_get_info(battery);
394 result = acpi_battery_get_state(battery);
398 acpi_battery_init_alarm(battery);
404 static int acpi_battery_update(struct acpi_battery *battery,
405 int update, int *update_result_ptr)
408 int update_result = ACPI_BATTERY_NONE_UPDATE;
410 if (!acpi_battery_present(battery)) {
414 if (battery->flags.init_update) {
415 result = acpi_battery_init_update(battery);
418 update_result = ACPI_BATTERY_INIT_UPDATE;
420 result = acpi_battery_get_status(battery);
423 if ((!battery->flags.battery_present_prev & acpi_battery_present(battery))
424 || (battery->flags.battery_present_prev & !acpi_battery_present(battery))) {
425 result = acpi_battery_init_update(battery);
428 update_result = ACPI_BATTERY_INIT_UPDATE;
430 update_result = ACPI_BATTERY_EASY_UPDATE;
436 battery->flags.init_update = (result != 0);
438 *update_result_ptr = update_result;
443 static void acpi_battery_notify_update(struct acpi_battery *battery)
445 acpi_battery_get_status(battery);
447 if (battery->flags.init_update) {
451 if ((!battery->flags.battery_present_prev &
452 acpi_battery_present(battery)) ||
453 (battery->flags.battery_present_prev &
454 !acpi_battery_present(battery))) {
455 battery->flags.init_update = 1;
457 battery->flags.update[ACPI_BATTERY_INFO] = 1;
458 battery->flags.update[ACPI_BATTERY_STATE] = 1;
459 battery->flags.update[ACPI_BATTERY_ALARM] = 1;
463 /* --------------------------------------------------------------------------
465 -------------------------------------------------------------------------- */
467 static struct proc_dir_entry *acpi_battery_dir;
469 static int acpi_battery_print_info(struct seq_file *seq, int result)
471 struct acpi_battery *battery = seq->private;
472 struct acpi_battery_info *bif = NULL;
478 if (acpi_battery_present(battery))
479 seq_printf(seq, "present: yes\n");
481 seq_printf(seq, "present: no\n");
485 bif = battery->bif_data.pointer;
487 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "BIF buffer is NULL"));
494 units = acpi_battery_power_units(battery);
496 if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
497 seq_printf(seq, "design capacity: unknown\n");
499 seq_printf(seq, "design capacity: %d %sh\n",
500 (u32) bif->design_capacity, units);
502 if (bif->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
503 seq_printf(seq, "last full capacity: unknown\n");
505 seq_printf(seq, "last full capacity: %d %sh\n",
506 (u32) bif->last_full_capacity, units);
508 switch ((u32) bif->battery_technology) {
510 seq_printf(seq, "battery technology: non-rechargeable\n");
513 seq_printf(seq, "battery technology: rechargeable\n");
516 seq_printf(seq, "battery technology: unknown\n");
520 if (bif->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
521 seq_printf(seq, "design voltage: unknown\n");
523 seq_printf(seq, "design voltage: %d mV\n",
524 (u32) bif->design_voltage);
525 seq_printf(seq, "design capacity warning: %d %sh\n",
526 (u32) bif->design_capacity_warning, units);
527 seq_printf(seq, "design capacity low: %d %sh\n",
528 (u32) bif->design_capacity_low, units);
529 seq_printf(seq, "capacity granularity 1: %d %sh\n",
530 (u32) bif->battery_capacity_granularity_1, units);
531 seq_printf(seq, "capacity granularity 2: %d %sh\n",
532 (u32) bif->battery_capacity_granularity_2, units);
533 seq_printf(seq, "model number: %s\n", bif->model_number);
534 seq_printf(seq, "serial number: %s\n", bif->serial_number);
535 seq_printf(seq, "battery type: %s\n", bif->battery_type);
536 seq_printf(seq, "OEM info: %s\n", bif->oem_info);
541 seq_printf(seq, "ERROR: Unable to read battery info\n");
546 static int acpi_battery_print_state(struct seq_file *seq, int result)
548 struct acpi_battery *battery = seq->private;
549 struct acpi_battery_state *bst = NULL;
555 if (acpi_battery_present(battery))
556 seq_printf(seq, "present: yes\n");
558 seq_printf(seq, "present: no\n");
562 bst = battery->bst_data.pointer;
564 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "BST buffer is NULL"));
571 units = acpi_battery_power_units(battery);
573 if (!(bst->state & 0x04))
574 seq_printf(seq, "capacity state: ok\n");
576 seq_printf(seq, "capacity state: critical\n");
578 if ((bst->state & 0x01) && (bst->state & 0x02)) {
580 "charging state: charging/discharging\n");
581 } else if (bst->state & 0x01)
582 seq_printf(seq, "charging state: discharging\n");
583 else if (bst->state & 0x02)
584 seq_printf(seq, "charging state: charging\n");
586 seq_printf(seq, "charging state: charged\n");
589 if (bst->present_rate == ACPI_BATTERY_VALUE_UNKNOWN)
590 seq_printf(seq, "present rate: unknown\n");
592 seq_printf(seq, "present rate: %d %s\n",
593 (u32) bst->present_rate, units);
595 if (bst->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
596 seq_printf(seq, "remaining capacity: unknown\n");
598 seq_printf(seq, "remaining capacity: %d %sh\n",
599 (u32) bst->remaining_capacity, units);
601 if (bst->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
602 seq_printf(seq, "present voltage: unknown\n");
604 seq_printf(seq, "present voltage: %d mV\n",
605 (u32) bst->present_voltage);
610 seq_printf(seq, "ERROR: Unable to read battery state\n");
616 static int acpi_battery_print_alarm(struct seq_file *seq, int result)
618 struct acpi_battery *battery = seq->private;
624 if (!acpi_battery_present(battery)) {
625 seq_printf(seq, "present: no\n");
631 units = acpi_battery_power_units(battery);
633 seq_printf(seq, "alarm: ");
635 seq_printf(seq, "unsupported\n");
637 seq_printf(seq, "%lu %sh\n", battery->alarm, units);
642 seq_printf(seq, "ERROR: Unable to read battery alarm\n");
648 acpi_battery_write_alarm(struct file *file,
649 const char __user * buffer,
650 size_t count, loff_t * ppos)
653 char alarm_string[12] = { '\0' };
654 struct seq_file *m = file->private_data;
655 struct acpi_battery *battery = m->private;
656 int update_result = ACPI_BATTERY_NONE_UPDATE;
658 if (!battery || (count > sizeof(alarm_string) - 1))
661 mutex_lock(&battery->mutex);
663 result = acpi_battery_update(battery, 1, &update_result);
669 if (!acpi_battery_present(battery)) {
674 if (copy_from_user(alarm_string, buffer, count)) {
679 alarm_string[count] = '\0';
681 result = acpi_battery_set_alarm(battery,
682 simple_strtoul(alarm_string, NULL, 0));
688 acpi_battery_check_result(battery, result);
693 mutex_unlock(&battery->mutex);
698 typedef int(*print_func)(struct seq_file *seq, int result);
699 typedef int(*get_func)(struct acpi_battery *battery);
701 static struct acpi_read_mux {
704 } acpi_read_funcs[ACPI_BATTERY_NUMFILES] = {
705 {.get = acpi_battery_get_info, .print = acpi_battery_print_info},
706 {.get = acpi_battery_get_state, .print = acpi_battery_print_state},
707 {.get = acpi_battery_get_alarm, .print = acpi_battery_print_alarm},
710 static int acpi_battery_read(int fid, struct seq_file *seq)
712 struct acpi_battery *battery = seq->private;
714 int update_result = ACPI_BATTERY_NONE_UPDATE;
717 mutex_lock(&battery->mutex);
719 update = (get_seconds() - battery->update_time[fid] >= update_time);
720 update = (update | battery->flags.update[fid]);
722 result = acpi_battery_update(battery, update, &update_result);
726 if (update_result == ACPI_BATTERY_EASY_UPDATE) {
727 result = acpi_read_funcs[fid].get(battery);
733 result = acpi_read_funcs[fid].print(seq, result);
734 acpi_battery_check_result(battery, result);
735 battery->flags.update[fid] = result;
736 mutex_unlock(&battery->mutex);
740 static int acpi_battery_read_info(struct seq_file *seq, void *offset)
742 return acpi_battery_read(ACPI_BATTERY_INFO, seq);
745 static int acpi_battery_read_state(struct seq_file *seq, void *offset)
747 return acpi_battery_read(ACPI_BATTERY_STATE, seq);
750 static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
752 return acpi_battery_read(ACPI_BATTERY_ALARM, seq);
755 static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
757 return single_open(file, acpi_battery_read_info, PDE(inode)->data);
760 static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
762 return single_open(file, acpi_battery_read_state, PDE(inode)->data);
765 static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
767 return single_open(file, acpi_battery_read_alarm, PDE(inode)->data);
770 static struct battery_file {
771 struct file_operations ops;
774 } acpi_battery_file[] = {
779 .open = acpi_battery_info_open_fs,
782 .release = single_release,
783 .owner = THIS_MODULE,
790 .open = acpi_battery_state_open_fs,
793 .release = single_release,
794 .owner = THIS_MODULE,
799 .mode = S_IFREG | S_IRUGO | S_IWUSR,
801 .open = acpi_battery_alarm_open_fs,
803 .write = acpi_battery_write_alarm,
805 .release = single_release,
806 .owner = THIS_MODULE,
811 static int acpi_battery_add_fs(struct acpi_device *device)
813 struct proc_dir_entry *entry = NULL;
816 if (!acpi_device_dir(device)) {
817 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
819 if (!acpi_device_dir(device))
821 acpi_device_dir(device)->owner = THIS_MODULE;
824 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
825 entry = create_proc_entry(acpi_battery_file[i].name,
826 acpi_battery_file[i].mode, acpi_device_dir(device));
830 entry->proc_fops = &acpi_battery_file[i].ops;
831 entry->data = acpi_driver_data(device);
832 entry->owner = THIS_MODULE;
839 static int acpi_battery_remove_fs(struct acpi_device *device)
842 if (acpi_device_dir(device)) {
843 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
844 remove_proc_entry(acpi_battery_file[i].name,
845 acpi_device_dir(device));
847 remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
848 acpi_device_dir(device) = NULL;
854 /* --------------------------------------------------------------------------
856 -------------------------------------------------------------------------- */
858 static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
860 struct acpi_battery *battery = data;
861 struct acpi_device *device = NULL;
866 device = battery->device;
869 case ACPI_BATTERY_NOTIFY_STATUS:
870 case ACPI_BATTERY_NOTIFY_INFO:
871 case ACPI_NOTIFY_BUS_CHECK:
872 case ACPI_NOTIFY_DEVICE_CHECK:
873 device = battery->device;
874 acpi_battery_notify_update(battery);
875 acpi_bus_generate_event(device, event,
876 acpi_battery_present(battery));
879 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
880 "Unsupported event [0x%x]\n", event));
887 static int acpi_battery_add(struct acpi_device *device)
890 acpi_status status = 0;
891 struct acpi_battery *battery = NULL;
896 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
900 mutex_init(&battery->mutex);
902 mutex_lock(&battery->mutex);
904 battery->device = device;
905 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
906 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
907 acpi_driver_data(device) = battery;
909 result = acpi_battery_get_status(battery);
913 battery->flags.init_update = 1;
915 result = acpi_battery_add_fs(device);
919 status = acpi_install_notify_handler(device->handle,
921 acpi_battery_notify, battery);
922 if (ACPI_FAILURE(status)) {
923 ACPI_EXCEPTION((AE_INFO, status, "Installing notify handler"));
928 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
929 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
930 device->status.battery_present ? "present" : "absent");
935 acpi_battery_remove_fs(device);
939 mutex_unlock(&battery->mutex);
944 static int acpi_battery_remove(struct acpi_device *device, int type)
946 acpi_status status = 0;
947 struct acpi_battery *battery = NULL;
949 if (!device || !acpi_driver_data(device))
952 battery = acpi_driver_data(device);
954 mutex_lock(&battery->mutex);
956 status = acpi_remove_notify_handler(device->handle,
958 acpi_battery_notify);
960 acpi_battery_remove_fs(device);
962 kfree(battery->bif_data.pointer);
964 kfree(battery->bst_data.pointer);
966 mutex_unlock(&battery->mutex);
968 mutex_destroy(&battery->mutex);
975 /* this is needed to learn about changes made in suspended state */
976 static int acpi_battery_resume(struct acpi_device *device)
978 struct acpi_battery *battery;
983 battery = device->driver_data;
985 battery->flags.init_update = 1;
990 static int __init acpi_battery_init(void)
997 acpi_battery_dir = acpi_lock_battery_dir();
998 if (!acpi_battery_dir)
1001 result = acpi_bus_register_driver(&acpi_battery_driver);
1003 acpi_unlock_battery_dir(acpi_battery_dir);
1010 static void __exit acpi_battery_exit(void)
1012 acpi_bus_unregister_driver(&acpi_battery_driver);
1014 acpi_unlock_battery_dir(acpi_battery_dir);
1019 module_init(acpi_battery_init);
1020 module_exit(acpi_battery_exit);