]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/acpi/battery.c
ACPI: Battery: Misc clean-ups, no functional changes
[mirror_ubuntu-bionic-kernel.git] / drivers / acpi / battery.c
1 /*
2 * battery.c - ACPI Battery Driver (Revision: 2.0)
3 *
4 * Copyright (C) 2007 Alexey Starikovskiy <astarikovskiy@suse.de>
5 * Copyright (C) 2004-2007 Vladimir Lebedev <vladimir.p.lebedev@intel.com>
6 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
7 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
8 *
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 *
25 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 */
27
28 #include <linux/kernel.h>
29 #include <linux/module.h>
30 #include <linux/init.h>
31 #include <linux/types.h>
32 #include <linux/jiffies.h>
33 #include <linux/proc_fs.h>
34 #include <linux/seq_file.h>
35 #include <asm/uaccess.h>
36
37 #include <acpi/acpi_bus.h>
38 #include <acpi/acpi_drivers.h>
39
40 #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF
41
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
48 #define _COMPONENT ACPI_BATTERY_COMPONENT
49
50 ACPI_MODULE_NAME("battery");
51
52 MODULE_AUTHOR("Paul Diefenbaugh");
53 MODULE_AUTHOR("Alexey Starikovskiy <astarikovskiy@suse.de>");
54 MODULE_DESCRIPTION("ACPI Battery Driver");
55 MODULE_LICENSE("GPL");
56
57 static unsigned int cache_time = 1000;
58 module_param(cache_time, uint, 0644);
59 MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
60
61 extern struct proc_dir_entry *acpi_lock_battery_dir(void);
62 extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
63
64 static const struct acpi_device_id battery_device_ids[] = {
65 {"PNP0C0A", 0},
66 {"", 0},
67 };
68
69 MODULE_DEVICE_TABLE(acpi, battery_device_ids);
70
71 enum acpi_battery_files {
72 info_tag = 0,
73 state_tag,
74 alarm_tag,
75 ACPI_BATTERY_NUMFILES,
76 };
77
78 struct acpi_battery {
79 struct mutex lock;
80 struct acpi_device *device;
81 unsigned long update_time;
82 int present_rate;
83 int remaining_capacity;
84 int present_voltage;
85 int design_capacity;
86 int last_full_capacity;
87 int technology;
88 int design_voltage;
89 int design_capacity_warning;
90 int design_capacity_low;
91 int capacity_granularity_1;
92 int capacity_granularity_2;
93 int alarm;
94 char model_number[32];
95 char serial_number[32];
96 char type[32];
97 char oem_info[32];
98 int state;
99 int power_unit;
100 u8 alarm_present;
101 };
102
103 inline int acpi_battery_present(struct acpi_battery *battery)
104 {
105 return battery->device->status.battery_present;
106 }
107
108 inline char *acpi_battery_units(struct acpi_battery *battery)
109 {
110 return (battery->power_unit)?"mA":"mW";
111 }
112
113 /* --------------------------------------------------------------------------
114 Battery Management
115 -------------------------------------------------------------------------- */
116 struct acpi_offsets {
117 size_t offset; /* offset inside struct acpi_sbs_battery */
118 u8 mode; /* int or string? */
119 };
120
121 static struct acpi_offsets state_offsets[] = {
122 {offsetof(struct acpi_battery, state), 0},
123 {offsetof(struct acpi_battery, present_rate), 0},
124 {offsetof(struct acpi_battery, remaining_capacity), 0},
125 {offsetof(struct acpi_battery, present_voltage), 0},
126 };
127
128 static struct acpi_offsets info_offsets[] = {
129 {offsetof(struct acpi_battery, power_unit), 0},
130 {offsetof(struct acpi_battery, design_capacity), 0},
131 {offsetof(struct acpi_battery, last_full_capacity), 0},
132 {offsetof(struct acpi_battery, technology), 0},
133 {offsetof(struct acpi_battery, design_voltage), 0},
134 {offsetof(struct acpi_battery, design_capacity_warning), 0},
135 {offsetof(struct acpi_battery, design_capacity_low), 0},
136 {offsetof(struct acpi_battery, capacity_granularity_1), 0},
137 {offsetof(struct acpi_battery, capacity_granularity_2), 0},
138 {offsetof(struct acpi_battery, model_number), 1},
139 {offsetof(struct acpi_battery, serial_number), 1},
140 {offsetof(struct acpi_battery, type), 1},
141 {offsetof(struct acpi_battery, oem_info), 1},
142 };
143
144 static int extract_package(struct acpi_battery *battery,
145 union acpi_object *package,
146 struct acpi_offsets *offsets, int num)
147 {
148 int i, *x;
149 union acpi_object *element;
150 if (package->type != ACPI_TYPE_PACKAGE)
151 return -EFAULT;
152 for (i = 0; i < num; ++i) {
153 if (package->package.count <= i)
154 return -EFAULT;
155 element = &package->package.elements[i];
156 if (offsets[i].mode) {
157 if (element->type != ACPI_TYPE_STRING &&
158 element->type != ACPI_TYPE_BUFFER)
159 return -EFAULT;
160 strncpy((u8 *)battery + offsets[i].offset,
161 element->string.pointer, 32);
162 } else {
163 if (element->type != ACPI_TYPE_INTEGER)
164 return -EFAULT;
165 x = (int *)((u8 *)battery + offsets[i].offset);
166 *x = element->integer.value;
167 }
168 }
169 return 0;
170 }
171
172 static int acpi_battery_get_status(struct acpi_battery *battery)
173 {
174 if (acpi_bus_get_status(battery->device)) {
175 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Evaluating _STA"));
176 return -ENODEV;
177 }
178 return 0;
179 }
180
181 static int acpi_battery_get_info(struct acpi_battery *battery)
182 {
183 int result = -EFAULT;
184 acpi_status status = 0;
185 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
186
187 if (!acpi_battery_present(battery))
188 return 0;
189 mutex_lock(&battery->lock);
190 status = acpi_evaluate_object(battery->device->handle, "_BIF",
191 NULL, &buffer);
192 mutex_unlock(&battery->lock);
193
194 if (ACPI_FAILURE(status)) {
195 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
196 return -ENODEV;
197 }
198
199 result = extract_package(battery, buffer.pointer,
200 info_offsets, ARRAY_SIZE(info_offsets));
201 kfree(buffer.pointer);
202 return result;
203 }
204
205 static int acpi_battery_get_state(struct acpi_battery *battery)
206 {
207 int result = 0;
208 acpi_status status = 0;
209 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
210
211 if (!acpi_battery_present(battery))
212 return 0;
213
214 if (battery->update_time &&
215 time_before(jiffies, battery->update_time +
216 msecs_to_jiffies(cache_time)))
217 return 0;
218
219 mutex_lock(&battery->lock);
220 status = acpi_evaluate_object(battery->device->handle, "_BST",
221 NULL, &buffer);
222 mutex_unlock(&battery->lock);
223
224 if (ACPI_FAILURE(status)) {
225 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
226 return -ENODEV;
227 }
228
229 result = extract_package(battery, buffer.pointer,
230 state_offsets, ARRAY_SIZE(state_offsets));
231 battery->update_time = jiffies;
232 kfree(buffer.pointer);
233 return result;
234 }
235
236 static int acpi_battery_set_alarm(struct acpi_battery *battery)
237 {
238 acpi_status status = 0;
239 union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER };
240 struct acpi_object_list arg_list = { 1, &arg0 };
241
242 if (!acpi_battery_present(battery)|| !battery->alarm_present)
243 return -ENODEV;
244
245 arg0.integer.value = battery->alarm;
246
247 mutex_lock(&battery->lock);
248 status = acpi_evaluate_object(battery->device->handle, "_BTP",
249 &arg_list, NULL);
250 mutex_unlock(&battery->lock);
251
252 if (ACPI_FAILURE(status))
253 return -ENODEV;
254
255 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", battery->alarm));
256 return 0;
257 }
258
259 static int acpi_battery_init_alarm(struct acpi_battery *battery)
260 {
261 acpi_status status = AE_OK;
262 acpi_handle handle = NULL;
263
264 /* See if alarms are supported, and if so, set default */
265 status = acpi_get_handle(battery->device->handle, "_BTP", &handle);
266 if (ACPI_FAILURE(status)) {
267 battery->alarm_present = 0;
268 return 0;
269 }
270 battery->alarm_present = 1;
271 if (!battery->alarm)
272 battery->alarm = battery->design_capacity_warning;
273 return acpi_battery_set_alarm(battery);
274 }
275
276 static int acpi_battery_update(struct acpi_battery *battery)
277 {
278 int saved_present = acpi_battery_present(battery);
279 int result = acpi_battery_get_status(battery);
280 if (result || !acpi_battery_present(battery))
281 return result;
282 if (saved_present != acpi_battery_present(battery) ||
283 !battery->update_time) {
284 battery->update_time = 0;
285 result = acpi_battery_get_info(battery);
286 if (result)
287 return result;
288 acpi_battery_init_alarm(battery);
289 }
290 return acpi_battery_get_state(battery);
291 }
292
293 /* --------------------------------------------------------------------------
294 FS Interface (/proc)
295 -------------------------------------------------------------------------- */
296
297 static struct proc_dir_entry *acpi_battery_dir;
298
299 static int acpi_battery_print_info(struct seq_file *seq, int result)
300 {
301 struct acpi_battery *battery = seq->private;
302
303 if (result)
304 goto end;
305
306 seq_printf(seq, "present: %s\n",
307 acpi_battery_present(battery)?"yes":"no");
308 if (!acpi_battery_present(battery))
309 goto end;
310 if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
311 seq_printf(seq, "design capacity: unknown\n");
312 else
313 seq_printf(seq, "design capacity: %d %sh\n",
314 battery->design_capacity,
315 acpi_battery_units(battery));
316
317 if (battery->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
318 seq_printf(seq, "last full capacity: unknown\n");
319 else
320 seq_printf(seq, "last full capacity: %d %sh\n",
321 battery->last_full_capacity,
322 acpi_battery_units(battery));
323
324 seq_printf(seq, "battery technology: %srechargeable\n",
325 (!battery->technology)?"non-":"");
326
327 if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
328 seq_printf(seq, "design voltage: unknown\n");
329 else
330 seq_printf(seq, "design voltage: %d mV\n",
331 battery->design_voltage);
332 seq_printf(seq, "design capacity warning: %d %sh\n",
333 battery->design_capacity_warning,
334 acpi_battery_units(battery));
335 seq_printf(seq, "design capacity low: %d %sh\n",
336 battery->design_capacity_low,
337 acpi_battery_units(battery));
338 seq_printf(seq, "capacity granularity 1: %d %sh\n",
339 battery->capacity_granularity_1,
340 acpi_battery_units(battery));
341 seq_printf(seq, "capacity granularity 2: %d %sh\n",
342 battery->capacity_granularity_2,
343 acpi_battery_units(battery));
344 seq_printf(seq, "model number: %s\n", battery->model_number);
345 seq_printf(seq, "serial number: %s\n", battery->serial_number);
346 seq_printf(seq, "battery type: %s\n", battery->type);
347 seq_printf(seq, "OEM info: %s\n", battery->oem_info);
348 end:
349 if (result)
350 seq_printf(seq, "ERROR: Unable to read battery info\n");
351 return result;
352 }
353
354 static int acpi_battery_print_state(struct seq_file *seq, int result)
355 {
356 struct acpi_battery *battery = seq->private;
357
358 if (result)
359 goto end;
360
361 seq_printf(seq, "present: %s\n",
362 acpi_battery_present(battery)?"yes":"no");
363 if (!acpi_battery_present(battery))
364 goto end;
365
366 seq_printf(seq, "capacity state: %s\n",
367 (battery->state & 0x04)?"critical":"ok");
368 if ((battery->state & 0x01) && (battery->state & 0x02))
369 seq_printf(seq,
370 "charging state: charging/discharging\n");
371 else if (battery->state & 0x01)
372 seq_printf(seq, "charging state: discharging\n");
373 else if (battery->state & 0x02)
374 seq_printf(seq, "charging state: charging\n");
375 else
376 seq_printf(seq, "charging state: charged\n");
377
378 if (battery->present_rate == ACPI_BATTERY_VALUE_UNKNOWN)
379 seq_printf(seq, "present rate: unknown\n");
380 else
381 seq_printf(seq, "present rate: %d %s\n",
382 battery->present_rate, acpi_battery_units(battery));
383
384 if (battery->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
385 seq_printf(seq, "remaining capacity: unknown\n");
386 else
387 seq_printf(seq, "remaining capacity: %d %sh\n",
388 battery->remaining_capacity, acpi_battery_units(battery));
389 if (battery->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
390 seq_printf(seq, "present voltage: unknown\n");
391 else
392 seq_printf(seq, "present voltage: %d mV\n",
393 battery->present_voltage);
394 end:
395 if (result)
396 seq_printf(seq, "ERROR: Unable to read battery state\n");
397
398 return result;
399 }
400
401 static int acpi_battery_print_alarm(struct seq_file *seq, int result)
402 {
403 struct acpi_battery *battery = seq->private;
404
405 if (result)
406 goto end;
407
408 if (!acpi_battery_present(battery)) {
409 seq_printf(seq, "present: no\n");
410 goto end;
411 }
412 seq_printf(seq, "alarm: ");
413 if (!battery->alarm)
414 seq_printf(seq, "unsupported\n");
415 else
416 seq_printf(seq, "%u %sh\n", battery->alarm,
417 acpi_battery_units(battery));
418 end:
419 if (result)
420 seq_printf(seq, "ERROR: Unable to read battery alarm\n");
421 return result;
422 }
423
424 static ssize_t acpi_battery_write_alarm(struct file *file,
425 const char __user * buffer,
426 size_t count, loff_t * ppos)
427 {
428 int result = 0;
429 char alarm_string[12] = { '\0' };
430 struct seq_file *m = file->private_data;
431 struct acpi_battery *battery = m->private;
432
433 if (!battery || (count > sizeof(alarm_string) - 1))
434 return -EINVAL;
435 if (result) {
436 result = -ENODEV;
437 goto end;
438 }
439 if (!acpi_battery_present(battery)) {
440 result = -ENODEV;
441 goto end;
442 }
443 if (copy_from_user(alarm_string, buffer, count)) {
444 result = -EFAULT;
445 goto end;
446 }
447 alarm_string[count] = '\0';
448 battery->alarm = simple_strtol(alarm_string, NULL, 0);
449 result = acpi_battery_set_alarm(battery);
450 end:
451 if (!result)
452 return count;
453 return result;
454 }
455
456 typedef int(*print_func)(struct seq_file *seq, int result);
457
458 static print_func acpi_print_funcs[ACPI_BATTERY_NUMFILES] = {
459 acpi_battery_print_info,
460 acpi_battery_print_state,
461 acpi_battery_print_alarm,
462 };
463
464 static int acpi_battery_read(int fid, struct seq_file *seq)
465 {
466 struct acpi_battery *battery = seq->private;
467 int result = acpi_battery_update(battery);
468 return acpi_print_funcs[fid](seq, result);
469 }
470
471 #define DECLARE_FILE_FUNCTIONS(_name) \
472 static int acpi_battery_read_##_name(struct seq_file *seq, void *offset) \
473 { \
474 return acpi_battery_read(_name##_tag, seq); \
475 } \
476 static int acpi_battery_##_name##_open_fs(struct inode *inode, struct file *file) \
477 { \
478 return single_open(file, acpi_battery_read_##_name, PDE(inode)->data); \
479 }
480
481 DECLARE_FILE_FUNCTIONS(info);
482 DECLARE_FILE_FUNCTIONS(state);
483 DECLARE_FILE_FUNCTIONS(alarm);
484
485 #undef DECLARE_FILE_FUNCTIONS
486
487 #define FILE_DESCRIPTION_RO(_name) \
488 { \
489 .name = __stringify(_name), \
490 .mode = S_IRUGO, \
491 .ops = { \
492 .open = acpi_battery_##_name##_open_fs, \
493 .read = seq_read, \
494 .llseek = seq_lseek, \
495 .release = single_release, \
496 .owner = THIS_MODULE, \
497 }, \
498 }
499
500 #define FILE_DESCRIPTION_RW(_name) \
501 { \
502 .name = __stringify(_name), \
503 .mode = S_IFREG | S_IRUGO | S_IWUSR, \
504 .ops = { \
505 .open = acpi_battery_##_name##_open_fs, \
506 .read = seq_read, \
507 .llseek = seq_lseek, \
508 .write = acpi_battery_write_##_name, \
509 .release = single_release, \
510 .owner = THIS_MODULE, \
511 }, \
512 }
513
514 static struct battery_file {
515 struct file_operations ops;
516 mode_t mode;
517 char *name;
518 } acpi_battery_file[] = {
519 FILE_DESCRIPTION_RO(info),
520 FILE_DESCRIPTION_RO(state),
521 FILE_DESCRIPTION_RW(alarm),
522 };
523
524 #undef FILE_DESCRIPTION_RO
525 #undef FILE_DESCRIPTION_RW
526
527 static int acpi_battery_add_fs(struct acpi_device *device)
528 {
529 struct proc_dir_entry *entry = NULL;
530 int i;
531
532 if (!acpi_device_dir(device)) {
533 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
534 acpi_battery_dir);
535 if (!acpi_device_dir(device))
536 return -ENODEV;
537 acpi_device_dir(device)->owner = THIS_MODULE;
538 }
539
540 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
541 entry = create_proc_entry(acpi_battery_file[i].name,
542 acpi_battery_file[i].mode, acpi_device_dir(device));
543 if (!entry)
544 return -ENODEV;
545 else {
546 entry->proc_fops = &acpi_battery_file[i].ops;
547 entry->data = acpi_driver_data(device);
548 entry->owner = THIS_MODULE;
549 }
550 }
551 return 0;
552 }
553
554 static void acpi_battery_remove_fs(struct acpi_device *device)
555 {
556 int i;
557 if (!acpi_device_dir(device))
558 return;
559 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i)
560 remove_proc_entry(acpi_battery_file[i].name,
561 acpi_device_dir(device));
562
563 remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
564 acpi_device_dir(device) = NULL;
565 }
566
567 /* --------------------------------------------------------------------------
568 Driver Interface
569 -------------------------------------------------------------------------- */
570
571 static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
572 {
573 struct acpi_battery *battery = data;
574 struct acpi_device *device;
575 if (!battery)
576 return;
577 device = battery->device;
578 acpi_battery_update(battery);
579 acpi_bus_generate_proc_event(device, event,
580 acpi_battery_present(battery));
581 acpi_bus_generate_netlink_event(device->pnp.device_class,
582 device->dev.bus_id, event,
583 acpi_battery_present(battery));
584 }
585
586 static int acpi_battery_add(struct acpi_device *device)
587 {
588 int result = 0;
589 acpi_status status = 0;
590 struct acpi_battery *battery = NULL;
591 if (!device)
592 return -EINVAL;
593 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
594 if (!battery)
595 return -ENOMEM;
596 battery->device = device;
597 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
598 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
599 acpi_driver_data(device) = battery;
600 mutex_init(&battery->lock);
601 acpi_battery_update(battery);
602 result = acpi_battery_add_fs(device);
603 if (result)
604 goto end;
605 status = acpi_install_notify_handler(device->handle,
606 ACPI_ALL_NOTIFY,
607 acpi_battery_notify, battery);
608 if (ACPI_FAILURE(status)) {
609 ACPI_EXCEPTION((AE_INFO, status, "Installing notify handler"));
610 result = -ENODEV;
611 goto end;
612 }
613 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
614 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
615 device->status.battery_present ? "present" : "absent");
616 end:
617 if (result) {
618 acpi_battery_remove_fs(device);
619 kfree(battery);
620 }
621 return result;
622 }
623
624 static int acpi_battery_remove(struct acpi_device *device, int type)
625 {
626 acpi_status status = 0;
627 struct acpi_battery *battery = NULL;
628
629 if (!device || !acpi_driver_data(device))
630 return -EINVAL;
631 battery = acpi_driver_data(device);
632 status = acpi_remove_notify_handler(device->handle,
633 ACPI_ALL_NOTIFY,
634 acpi_battery_notify);
635 acpi_battery_remove_fs(device);
636 mutex_destroy(&battery->lock);
637 kfree(battery);
638 return 0;
639 }
640
641 /* this is needed to learn about changes made in suspended state */
642 static int acpi_battery_resume(struct acpi_device *device)
643 {
644 struct acpi_battery *battery;
645 if (!device)
646 return -EINVAL;
647 battery = acpi_driver_data(device);
648 battery->update_time = 0;
649 return 0;
650 }
651
652 static struct acpi_driver acpi_battery_driver = {
653 .name = "battery",
654 .class = ACPI_BATTERY_CLASS,
655 .ids = battery_device_ids,
656 .ops = {
657 .add = acpi_battery_add,
658 .resume = acpi_battery_resume,
659 .remove = acpi_battery_remove,
660 },
661 };
662
663 static int __init acpi_battery_init(void)
664 {
665 if (acpi_disabled)
666 return -ENODEV;
667 acpi_battery_dir = acpi_lock_battery_dir();
668 if (!acpi_battery_dir)
669 return -ENODEV;
670 if (acpi_bus_register_driver(&acpi_battery_driver) < 0) {
671 acpi_unlock_battery_dir(acpi_battery_dir);
672 return -ENODEV;
673 }
674 return 0;
675 }
676
677 static void __exit acpi_battery_exit(void)
678 {
679 acpi_bus_unregister_driver(&acpi_battery_driver);
680 acpi_unlock_battery_dir(acpi_battery_dir);
681 }
682
683 module_init(acpi_battery_init);
684 module_exit(acpi_battery_exit);