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_HID "PNP0C0A"
45 #define ACPI_BATTERY_DEVICE_NAME "Battery"
46 #define ACPI_BATTERY_NOTIFY_STATUS 0x80
47 #define ACPI_BATTERY_NOTIFY_INFO 0x81
48 #define ACPI_BATTERY_UNITS_WATTS "mW"
49 #define ACPI_BATTERY_UNITS_AMPS "mA"
51 #define _COMPONENT ACPI_BATTERY_COMPONENT
53 #define ACPI_BATTERY_UPDATE_TIME 0
55 #define ACPI_BATTERY_NONE_UPDATE 0
56 #define ACPI_BATTERY_EASY_UPDATE 1
57 #define ACPI_BATTERY_INIT_UPDATE 2
59 ACPI_MODULE_NAME("battery");
61 MODULE_AUTHOR("Paul Diefenbaugh");
62 MODULE_DESCRIPTION("ACPI Battery Driver");
63 MODULE_LICENSE("GPL");
65 static unsigned int update_time = ACPI_BATTERY_UPDATE_TIME;
67 /* 0 - every time, > 0 - by update_time */
68 module_param(update_time, uint, 0644);
70 extern struct proc_dir_entry *acpi_lock_battery_dir(void);
71 extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
73 static int acpi_battery_add(struct acpi_device *device);
74 static int acpi_battery_remove(struct acpi_device *device, int type);
75 static int acpi_battery_resume(struct acpi_device *device);
77 static struct acpi_driver acpi_battery_driver = {
79 .class = ACPI_BATTERY_CLASS,
80 .ids = ACPI_BATTERY_HID,
82 .add = acpi_battery_add,
83 .resume = acpi_battery_resume,
84 .remove = acpi_battery_remove,
88 struct acpi_battery_state {
90 acpi_integer present_rate;
91 acpi_integer remaining_capacity;
92 acpi_integer present_voltage;
95 struct acpi_battery_info {
96 acpi_integer power_unit;
97 acpi_integer design_capacity;
98 acpi_integer last_full_capacity;
99 acpi_integer battery_technology;
100 acpi_integer design_voltage;
101 acpi_integer design_capacity_warning;
102 acpi_integer design_capacity_low;
103 acpi_integer battery_capacity_granularity_1;
104 acpi_integer battery_capacity_granularity_2;
105 acpi_string model_number;
106 acpi_string serial_number;
107 acpi_string battery_type;
108 acpi_string oem_info;
111 enum acpi_battery_files{
112 ACPI_BATTERY_INFO = 0,
115 ACPI_BATTERY_NUMFILES,
118 struct acpi_battery_flags {
119 u8 battery_present_prev;
122 u8 update[ACPI_BATTERY_NUMFILES];
126 struct acpi_battery {
128 struct acpi_device *device;
129 struct acpi_battery_flags flags;
130 struct acpi_buffer bif_data;
131 struct acpi_buffer bst_data;
133 unsigned long update_time[ACPI_BATTERY_NUMFILES];
136 inline int acpi_battery_present(struct acpi_battery *battery)
138 return battery->device->status.battery_present;
140 inline char *acpi_battery_power_units(struct acpi_battery *battery)
142 if (battery->flags.power_unit)
143 return ACPI_BATTERY_UNITS_AMPS;
145 return ACPI_BATTERY_UNITS_WATTS;
148 inline acpi_handle acpi_battery_handle(struct acpi_battery *battery)
150 return battery->device->handle;
153 /* --------------------------------------------------------------------------
155 -------------------------------------------------------------------------- */
157 static void acpi_battery_check_result(struct acpi_battery *battery, int result)
163 battery->flags.init_update = 1;
167 static int acpi_battery_extract_package(struct acpi_battery *battery,
168 union acpi_object *package,
169 struct acpi_buffer *format,
170 struct acpi_buffer *data,
173 acpi_status status = AE_OK;
174 struct acpi_buffer data_null = { 0, NULL };
176 status = acpi_extract_package(package, format, &data_null);
177 if (status != AE_BUFFER_OVERFLOW) {
178 ACPI_EXCEPTION((AE_INFO, status, "Extracting size %s",
183 if (data_null.length != data->length) {
184 kfree(data->pointer);
185 data->pointer = kzalloc(data_null.length, GFP_KERNEL);
186 if (!data->pointer) {
187 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, "kzalloc()"));
190 data->length = data_null.length;
193 status = acpi_extract_package(package, format, data);
194 if (ACPI_FAILURE(status)) {
195 ACPI_EXCEPTION((AE_INFO, status, "Extracting %s",
203 static int acpi_battery_get_status(struct acpi_battery *battery)
207 result = acpi_bus_get_status(battery->device);
209 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Evaluating _STA"));
215 static int acpi_battery_get_info(struct acpi_battery *battery)
218 acpi_status status = 0;
219 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
220 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BIF),
221 ACPI_BATTERY_FORMAT_BIF
223 union acpi_object *package = NULL;
224 struct acpi_buffer *data = NULL;
225 struct acpi_battery_info *bif = NULL;
227 battery->update_time[ACPI_BATTERY_INFO] = get_seconds();
229 if (!acpi_battery_present(battery))
235 acpi_evaluate_object(acpi_battery_handle(battery), "_BIF", NULL,
237 if (ACPI_FAILURE(status)) {
238 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
242 package = buffer.pointer;
244 data = &battery->bif_data;
246 /* Extract Package Data */
249 acpi_battery_extract_package(battery, package, &format, data,
256 kfree(buffer.pointer);
260 battery->flags.power_unit = bif->power_unit;
266 static int acpi_battery_get_state(struct acpi_battery *battery)
269 acpi_status status = 0;
270 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
271 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BST),
272 ACPI_BATTERY_FORMAT_BST
274 union acpi_object *package = NULL;
275 struct acpi_buffer *data = NULL;
277 battery->update_time[ACPI_BATTERY_STATE] = get_seconds();
279 if (!acpi_battery_present(battery))
285 acpi_evaluate_object(acpi_battery_handle(battery), "_BST", NULL,
287 if (ACPI_FAILURE(status)) {
288 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
292 package = buffer.pointer;
294 data = &battery->bst_data;
296 /* Extract Package Data */
299 acpi_battery_extract_package(battery, package, &format, data,
305 kfree(buffer.pointer);
310 static int acpi_battery_get_alarm(struct acpi_battery *battery)
312 battery->update_time[ACPI_BATTERY_ALARM] = get_seconds();
317 static int acpi_battery_set_alarm(struct acpi_battery *battery,
320 acpi_status status = 0;
321 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
322 struct acpi_object_list arg_list = { 1, &arg0 };
324 battery->update_time[ACPI_BATTERY_ALARM] = get_seconds();
326 if (!acpi_battery_present(battery))
329 if (!battery->flags.alarm_present)
332 arg0.integer.value = alarm;
335 acpi_evaluate_object(acpi_battery_handle(battery), "_BTP",
337 if (ACPI_FAILURE(status))
340 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm));
342 battery->alarm = alarm;
347 static int acpi_battery_init_alarm(struct acpi_battery *battery)
350 acpi_status status = AE_OK;
351 acpi_handle handle = NULL;
352 struct acpi_battery_info *bif = battery->bif_data.pointer;
353 unsigned long alarm = battery->alarm;
355 /* See if alarms are supported, and if so, set default */
357 status = acpi_get_handle(acpi_battery_handle(battery), "_BTP", &handle);
358 if (ACPI_SUCCESS(status)) {
359 battery->flags.alarm_present = 1;
361 alarm = bif->design_capacity_warning;
363 result = acpi_battery_set_alarm(battery, alarm);
367 battery->flags.alarm_present = 0;
375 static int acpi_battery_init_update(struct acpi_battery *battery)
379 result = acpi_battery_get_status(battery);
383 battery->flags.battery_present_prev = acpi_battery_present(battery);
385 if (acpi_battery_present(battery)) {
386 result = acpi_battery_get_info(battery);
389 result = acpi_battery_get_state(battery);
393 acpi_battery_init_alarm(battery);
399 static int acpi_battery_update(struct acpi_battery *battery,
400 int update, int *update_result_ptr)
403 int update_result = ACPI_BATTERY_NONE_UPDATE;
405 if (!acpi_battery_present(battery)) {
409 if (battery->flags.init_update) {
410 result = acpi_battery_init_update(battery);
413 update_result = ACPI_BATTERY_INIT_UPDATE;
415 result = acpi_battery_get_status(battery);
418 if ((!battery->flags.battery_present_prev & acpi_battery_present(battery))
419 || (battery->flags.battery_present_prev & !acpi_battery_present(battery))) {
420 result = acpi_battery_init_update(battery);
423 update_result = ACPI_BATTERY_INIT_UPDATE;
425 update_result = ACPI_BATTERY_EASY_UPDATE;
431 battery->flags.init_update = (result != 0);
433 *update_result_ptr = update_result;
438 static void acpi_battery_notify_update(struct acpi_battery *battery)
440 acpi_battery_get_status(battery);
442 if (battery->flags.init_update) {
446 if ((!battery->flags.battery_present_prev &
447 acpi_battery_present(battery)) ||
448 (battery->flags.battery_present_prev &
449 !acpi_battery_present(battery))) {
450 battery->flags.init_update = 1;
452 battery->flags.update[ACPI_BATTERY_INFO] = 1;
453 battery->flags.update[ACPI_BATTERY_STATE] = 1;
454 battery->flags.update[ACPI_BATTERY_ALARM] = 1;
458 /* --------------------------------------------------------------------------
460 -------------------------------------------------------------------------- */
462 static struct proc_dir_entry *acpi_battery_dir;
464 static int acpi_battery_print_info(struct seq_file *seq, int result)
466 struct acpi_battery *battery = seq->private;
467 struct acpi_battery_info *bif = NULL;
473 if (acpi_battery_present(battery))
474 seq_printf(seq, "present: yes\n");
476 seq_printf(seq, "present: no\n");
480 bif = battery->bif_data.pointer;
482 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "BIF buffer is NULL"));
489 units = acpi_battery_power_units(battery);
491 if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
492 seq_printf(seq, "design capacity: unknown\n");
494 seq_printf(seq, "design capacity: %d %sh\n",
495 (u32) bif->design_capacity, units);
497 if (bif->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
498 seq_printf(seq, "last full capacity: unknown\n");
500 seq_printf(seq, "last full capacity: %d %sh\n",
501 (u32) bif->last_full_capacity, units);
503 switch ((u32) bif->battery_technology) {
505 seq_printf(seq, "battery technology: non-rechargeable\n");
508 seq_printf(seq, "battery technology: rechargeable\n");
511 seq_printf(seq, "battery technology: unknown\n");
515 if (bif->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
516 seq_printf(seq, "design voltage: unknown\n");
518 seq_printf(seq, "design voltage: %d mV\n",
519 (u32) bif->design_voltage);
520 seq_printf(seq, "design capacity warning: %d %sh\n",
521 (u32) bif->design_capacity_warning, units);
522 seq_printf(seq, "design capacity low: %d %sh\n",
523 (u32) bif->design_capacity_low, units);
524 seq_printf(seq, "capacity granularity 1: %d %sh\n",
525 (u32) bif->battery_capacity_granularity_1, units);
526 seq_printf(seq, "capacity granularity 2: %d %sh\n",
527 (u32) bif->battery_capacity_granularity_2, units);
528 seq_printf(seq, "model number: %s\n", bif->model_number);
529 seq_printf(seq, "serial number: %s\n", bif->serial_number);
530 seq_printf(seq, "battery type: %s\n", bif->battery_type);
531 seq_printf(seq, "OEM info: %s\n", bif->oem_info);
536 seq_printf(seq, "ERROR: Unable to read battery info\n");
541 static int acpi_battery_print_state(struct seq_file *seq, int result)
543 struct acpi_battery *battery = seq->private;
544 struct acpi_battery_state *bst = NULL;
550 if (acpi_battery_present(battery))
551 seq_printf(seq, "present: yes\n");
553 seq_printf(seq, "present: no\n");
557 bst = battery->bst_data.pointer;
559 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "BST buffer is NULL"));
566 units = acpi_battery_power_units(battery);
568 if (!(bst->state & 0x04))
569 seq_printf(seq, "capacity state: ok\n");
571 seq_printf(seq, "capacity state: critical\n");
573 if ((bst->state & 0x01) && (bst->state & 0x02)) {
575 "charging state: charging/discharging\n");
576 } else if (bst->state & 0x01)
577 seq_printf(seq, "charging state: discharging\n");
578 else if (bst->state & 0x02)
579 seq_printf(seq, "charging state: charging\n");
581 seq_printf(seq, "charging state: charged\n");
584 if (bst->present_rate == ACPI_BATTERY_VALUE_UNKNOWN)
585 seq_printf(seq, "present rate: unknown\n");
587 seq_printf(seq, "present rate: %d %s\n",
588 (u32) bst->present_rate, units);
590 if (bst->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
591 seq_printf(seq, "remaining capacity: unknown\n");
593 seq_printf(seq, "remaining capacity: %d %sh\n",
594 (u32) bst->remaining_capacity, units);
596 if (bst->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
597 seq_printf(seq, "present voltage: unknown\n");
599 seq_printf(seq, "present voltage: %d mV\n",
600 (u32) bst->present_voltage);
605 seq_printf(seq, "ERROR: Unable to read battery state\n");
611 static int acpi_battery_print_alarm(struct seq_file *seq, int result)
613 struct acpi_battery *battery = seq->private;
619 if (!acpi_battery_present(battery)) {
620 seq_printf(seq, "present: no\n");
626 units = acpi_battery_power_units(battery);
628 seq_printf(seq, "alarm: ");
630 seq_printf(seq, "unsupported\n");
632 seq_printf(seq, "%lu %sh\n", battery->alarm, units);
637 seq_printf(seq, "ERROR: Unable to read battery alarm\n");
643 acpi_battery_write_alarm(struct file *file,
644 const char __user * buffer,
645 size_t count, loff_t * ppos)
648 char alarm_string[12] = { '\0' };
649 struct seq_file *m = file->private_data;
650 struct acpi_battery *battery = m->private;
651 int update_result = ACPI_BATTERY_NONE_UPDATE;
653 if (!battery || (count > sizeof(alarm_string) - 1))
656 mutex_lock(&battery->mutex);
658 result = acpi_battery_update(battery, 1, &update_result);
664 if (!acpi_battery_present(battery)) {
669 if (copy_from_user(alarm_string, buffer, count)) {
674 alarm_string[count] = '\0';
676 result = acpi_battery_set_alarm(battery,
677 simple_strtoul(alarm_string, NULL, 0));
683 acpi_battery_check_result(battery, result);
688 mutex_unlock(&battery->mutex);
693 typedef int(*print_func)(struct seq_file *seq, int result);
694 typedef int(*get_func)(struct acpi_battery *battery);
696 static struct acpi_read_mux {
699 } acpi_read_funcs[ACPI_BATTERY_NUMFILES] = {
700 {.get = acpi_battery_get_info, .print = acpi_battery_print_info},
701 {.get = acpi_battery_get_state, .print = acpi_battery_print_state},
702 {.get = acpi_battery_get_alarm, .print = acpi_battery_print_alarm},
705 static int acpi_battery_read(int fid, struct seq_file *seq)
707 struct acpi_battery *battery = seq->private;
709 int update_result = ACPI_BATTERY_NONE_UPDATE;
712 mutex_lock(&battery->mutex);
714 update = (get_seconds() - battery->update_time[fid] >= update_time);
715 update = (update | battery->flags.update[fid]);
717 result = acpi_battery_update(battery, update, &update_result);
721 if (update_result == ACPI_BATTERY_EASY_UPDATE) {
722 result = acpi_read_funcs[fid].get(battery);
728 result = acpi_read_funcs[fid].print(seq, result);
729 acpi_battery_check_result(battery, result);
730 battery->flags.update[fid] = result;
731 mutex_unlock(&battery->mutex);
735 static int acpi_battery_read_info(struct seq_file *seq, void *offset)
737 return acpi_battery_read(ACPI_BATTERY_INFO, seq);
740 static int acpi_battery_read_state(struct seq_file *seq, void *offset)
742 return acpi_battery_read(ACPI_BATTERY_STATE, seq);
745 static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
747 return acpi_battery_read(ACPI_BATTERY_ALARM, seq);
750 static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
752 return single_open(file, acpi_battery_read_info, PDE(inode)->data);
755 static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
757 return single_open(file, acpi_battery_read_state, PDE(inode)->data);
760 static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
762 return single_open(file, acpi_battery_read_alarm, PDE(inode)->data);
765 static struct battery_file {
766 struct file_operations ops;
769 } acpi_battery_file[] = {
774 .open = acpi_battery_info_open_fs,
777 .release = single_release,
778 .owner = THIS_MODULE,
785 .open = acpi_battery_state_open_fs,
788 .release = single_release,
789 .owner = THIS_MODULE,
794 .mode = S_IFREG | S_IRUGO | S_IWUSR,
796 .open = acpi_battery_alarm_open_fs,
798 .write = acpi_battery_write_alarm,
800 .release = single_release,
801 .owner = THIS_MODULE,
806 static int acpi_battery_add_fs(struct acpi_device *device)
808 struct proc_dir_entry *entry = NULL;
811 if (!acpi_device_dir(device)) {
812 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
814 if (!acpi_device_dir(device))
816 acpi_device_dir(device)->owner = THIS_MODULE;
819 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
820 entry = create_proc_entry(acpi_battery_file[i].name,
821 acpi_battery_file[i].mode, acpi_device_dir(device));
825 entry->proc_fops = &acpi_battery_file[i].ops;
826 entry->data = acpi_driver_data(device);
827 entry->owner = THIS_MODULE;
834 static int acpi_battery_remove_fs(struct acpi_device *device)
837 if (acpi_device_dir(device)) {
838 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
839 remove_proc_entry(acpi_battery_file[i].name,
840 acpi_device_dir(device));
842 remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
843 acpi_device_dir(device) = NULL;
849 /* --------------------------------------------------------------------------
851 -------------------------------------------------------------------------- */
853 static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
855 struct acpi_battery *battery = data;
856 struct acpi_device *device = NULL;
861 device = battery->device;
864 case ACPI_BATTERY_NOTIFY_STATUS:
865 case ACPI_BATTERY_NOTIFY_INFO:
866 case ACPI_NOTIFY_BUS_CHECK:
867 case ACPI_NOTIFY_DEVICE_CHECK:
868 device = battery->device;
869 acpi_battery_notify_update(battery);
870 acpi_bus_generate_event(device, event,
871 acpi_battery_present(battery));
874 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
875 "Unsupported event [0x%x]\n", event));
882 static int acpi_battery_add(struct acpi_device *device)
885 acpi_status status = 0;
886 struct acpi_battery *battery = NULL;
891 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
895 mutex_init(&battery->mutex);
897 mutex_lock(&battery->mutex);
899 battery->device = device;
900 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
901 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
902 acpi_driver_data(device) = battery;
904 result = acpi_battery_get_status(battery);
908 battery->flags.init_update = 1;
910 result = acpi_battery_add_fs(device);
914 status = acpi_install_notify_handler(device->handle,
916 acpi_battery_notify, battery);
917 if (ACPI_FAILURE(status)) {
918 ACPI_EXCEPTION((AE_INFO, status, "Installing notify handler"));
923 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
924 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
925 device->status.battery_present ? "present" : "absent");
930 acpi_battery_remove_fs(device);
934 mutex_unlock(&battery->mutex);
939 static int acpi_battery_remove(struct acpi_device *device, int type)
941 acpi_status status = 0;
942 struct acpi_battery *battery = NULL;
944 if (!device || !acpi_driver_data(device))
947 battery = acpi_driver_data(device);
949 mutex_lock(&battery->mutex);
951 status = acpi_remove_notify_handler(device->handle,
953 acpi_battery_notify);
955 acpi_battery_remove_fs(device);
957 kfree(battery->bif_data.pointer);
959 kfree(battery->bst_data.pointer);
961 mutex_unlock(&battery->mutex);
963 mutex_destroy(&battery->mutex);
970 /* this is needed to learn about changes made in suspended state */
971 static int acpi_battery_resume(struct acpi_device *device)
973 struct acpi_battery *battery;
978 battery = device->driver_data;
980 battery->flags.init_update = 1;
985 static int __init acpi_battery_init(void)
992 acpi_battery_dir = acpi_lock_battery_dir();
993 if (!acpi_battery_dir)
996 result = acpi_bus_register_driver(&acpi_battery_driver);
998 acpi_unlock_battery_dir(acpi_battery_dir);
1005 static void __exit acpi_battery_exit(void)
1007 acpi_bus_unregister_driver(&acpi_battery_driver);
1009 acpi_unlock_battery_dir(acpi_battery_dir);
1014 module_init(acpi_battery_init);
1015 module_exit(acpi_battery_exit);