blob: db725bfe584009350842a05ead83cbf3a515b5e4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +04002 * battery.c - ACPI Battery Driver (Revision: 2.0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +04004 * Copyright (C) 2007 Alexey Starikovskiy <astarikovskiy@suse.de>
5 * Copyright (C) 2004-2007 Vladimir Lebedev <vladimir.p.lebedev@intel.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * 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>
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +040032#include <linux/jiffies.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#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
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#define ACPI_BATTERY_COMPONENT 0x00040000
43#define ACPI_BATTERY_CLASS "battery"
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#define ACPI_BATTERY_DEVICE_NAME "Battery"
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#define ACPI_BATTERY_NOTIFY_STATUS 0x80
46#define ACPI_BATTERY_NOTIFY_INFO 0x81
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#define _COMPONENT ACPI_BATTERY_COMPONENT
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +030049
Len Brownf52fd662007-02-12 22:42:12 -050050ACPI_MODULE_NAME("battery");
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Len Brownf52fd662007-02-12 22:42:12 -050052MODULE_AUTHOR("Paul Diefenbaugh");
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +040053MODULE_AUTHOR("Alexey Starikovskiy <astarikovskiy@suse.de>");
Len Brown7cda93e2007-02-12 23:50:02 -050054MODULE_DESCRIPTION("ACPI Battery Driver");
Linus Torvalds1da177e2005-04-16 15:20:36 -070055MODULE_LICENSE("GPL");
56
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +040057static unsigned int cache_time = 1000;
58module_param(cache_time, uint, 0644);
59MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +030060
Rich Townsend3f86b832006-07-01 11:36:54 -040061extern struct proc_dir_entry *acpi_lock_battery_dir(void);
62extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
63
Thomas Renninger1ba90e32007-07-23 14:44:41 +020064static const struct acpi_device_id battery_device_ids[] = {
65 {"PNP0C0A", 0},
66 {"", 0},
67};
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +040068
Thomas Renninger1ba90e32007-07-23 14:44:41 +020069MODULE_DEVICE_TABLE(acpi, battery_device_ids);
70
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +040071enum acpi_battery_files {
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +040072 info_tag = 0,
73 state_tag,
74 alarm_tag,
Alexey Starikovskiy78490d82007-05-11 13:18:55 -040075 ACPI_BATTERY_NUMFILES,
76};
77
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +040078struct acpi_battery {
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +040079 struct mutex lock;
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +040080 struct acpi_device *device;
81 unsigned long update_time;
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +040082 int present_rate;
83 int remaining_capacity;
84 int present_voltage;
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +040085 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;
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +040093 int alarm;
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +040094 char model_number[32];
95 char serial_number[32];
96 char type[32];
97 char oem_info[32];
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +040098 int state;
99 int power_unit;
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300100 u8 alarm_present;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101};
102
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400103inline int acpi_battery_present(struct acpi_battery *battery)
104{
105 return battery->device->status.battery_present;
106}
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400107
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400108inline char *acpi_battery_units(struct acpi_battery *battery)
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400109{
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400110 return (battery->power_unit)?"mA":"mW";
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400111}
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300112
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113/* --------------------------------------------------------------------------
114 Battery Management
115 -------------------------------------------------------------------------- */
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400116struct acpi_offsets {
117 size_t offset; /* offset inside struct acpi_sbs_battery */
118 u8 mode; /* int or string? */
119};
120
121static 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
128static 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
144static int extract_package(struct acpi_battery *battery,
145 union acpi_object *package,
146 struct acpi_offsets *offsets, int num)
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300147{
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400148 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;
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300167 }
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300168 }
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300169 return 0;
170}
171
172static int acpi_battery_get_status(struct acpi_battery *battery)
173{
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400174 if (acpi_bus_get_status(battery->device)) {
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300175 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Evaluating _STA"));
176 return -ENODEV;
177 }
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400178 return 0;
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300179}
180
181static int acpi_battery_get_info(struct acpi_battery *battery)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182{
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400183 int result = -EFAULT;
Len Brown4be44fc2005-08-05 00:44:28 -0400184 acpi_status status = 0;
185 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300187 if (!acpi_battery_present(battery))
188 return 0;
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400189 mutex_lock(&battery->lock);
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400190 status = acpi_evaluate_object(battery->device->handle, "_BIF",
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400191 NULL, &buffer);
192 mutex_unlock(&battery->lock);
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 if (ACPI_FAILURE(status)) {
Thomas Renningera6fc6722006-06-26 23:58:43 -0400195 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400196 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 }
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400198
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400199 result = extract_package(battery, buffer.pointer,
200 info_offsets, ARRAY_SIZE(info_offsets));
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400201 kfree(buffer.pointer);
Patrick Mocheld550d982006-06-27 00:41:40 -0400202 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203}
204
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300205static int acpi_battery_get_state(struct acpi_battery *battery)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206{
Len Brown4be44fc2005-08-05 00:44:28 -0400207 int result = 0;
208 acpi_status status = 0;
209 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300211 if (!acpi_battery_present(battery))
212 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400214 if (battery->update_time &&
215 time_before(jiffies, battery->update_time +
216 msecs_to_jiffies(cache_time)))
217 return 0;
218
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400219 mutex_lock(&battery->lock);
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400220 status = acpi_evaluate_object(battery->device->handle, "_BST",
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400221 NULL, &buffer);
222 mutex_unlock(&battery->lock);
Len Brown5b31d892007-08-15 00:19:26 -0400223
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 if (ACPI_FAILURE(status)) {
Thomas Renningera6fc6722006-06-26 23:58:43 -0400225 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400226 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 }
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400228
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400229 result = extract_package(battery, buffer.pointer,
230 state_offsets, ARRAY_SIZE(state_offsets));
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400231 battery->update_time = jiffies;
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400232 kfree(buffer.pointer);
Patrick Mocheld550d982006-06-27 00:41:40 -0400233 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234}
235
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400236static int acpi_battery_set_alarm(struct acpi_battery *battery)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237{
Len Brown4be44fc2005-08-05 00:44:28 -0400238 acpi_status status = 0;
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400239 union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER };
Len Brown4be44fc2005-08-05 00:44:28 -0400240 struct acpi_object_list arg_list = { 1, &arg0 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400242 if (!acpi_battery_present(battery)|| !battery->alarm_present)
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300243 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400245 arg0.integer.value = battery->alarm;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400247 mutex_lock(&battery->lock);
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400248 status = acpi_evaluate_object(battery->device->handle, "_BTP",
249 &arg_list, NULL);
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400250 mutex_unlock(&battery->lock);
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400251
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 if (ACPI_FAILURE(status))
Patrick Mocheld550d982006-06-27 00:41:40 -0400253 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400255 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", battery->alarm));
Patrick Mocheld550d982006-06-27 00:41:40 -0400256 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257}
258
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300259static int acpi_battery_init_alarm(struct acpi_battery *battery)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260{
Len Brown4be44fc2005-08-05 00:44:28 -0400261 acpi_status status = AE_OK;
262 acpi_handle handle = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300264 /* See if alarms are supported, and if so, set default */
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400265 status = acpi_get_handle(battery->device->handle, "_BTP", &handle);
266 if (ACPI_FAILURE(status)) {
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400267 battery->alarm_present = 0;
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400268 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 }
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400270 battery->alarm_present = 1;
271 if (!battery->alarm)
272 battery->alarm = battery->design_capacity_warning;
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400273 return acpi_battery_set_alarm(battery);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274}
275
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400276static int acpi_battery_update(struct acpi_battery *battery)
Vladimir Lebedev4bd35cd2007-02-10 01:43:48 -0500277{
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400278 int saved_present = acpi_battery_present(battery);
279 int result = acpi_battery_get_status(battery);
280 if (result || !acpi_battery_present(battery))
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300281 return result;
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400282 if (saved_present != acpi_battery_present(battery) ||
283 !battery->update_time) {
284 battery->update_time = 0;
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300285 result = acpi_battery_get_info(battery);
286 if (result)
287 return result;
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300288 acpi_battery_init_alarm(battery);
289 }
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400290 return acpi_battery_get_state(battery);
Vladimir Lebedev4bd35cd2007-02-10 01:43:48 -0500291}
292
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293/* --------------------------------------------------------------------------
294 FS Interface (/proc)
295 -------------------------------------------------------------------------- */
296
Len Brown4be44fc2005-08-05 00:44:28 -0400297static struct proc_dir_entry *acpi_battery_dir;
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300298
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400299static int acpi_battery_print_info(struct seq_file *seq, int result)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300{
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200301 struct acpi_battery *battery = seq->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300303 if (result)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 goto end;
305
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400306 seq_printf(seq, "present: %s\n",
307 acpi_battery_present(battery)?"yes":"no");
308 if (!acpi_battery_present(battery))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 goto end;
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400310 if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 seq_printf(seq, "design capacity: unknown\n");
312 else
313 seq_printf(seq, "design capacity: %d %sh\n",
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400314 battery->design_capacity,
315 acpi_battery_units(battery));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400317 if (battery->last_full_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 seq_printf(seq, "last full capacity: unknown\n");
319 else
320 seq_printf(seq, "last full capacity: %d %sh\n",
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400321 battery->last_full_capacity,
322 acpi_battery_units(battery));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400324 seq_printf(seq, "battery technology: %srechargeable\n",
325 (!battery->technology)?"non-":"");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400327 if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 seq_printf(seq, "design voltage: unknown\n");
329 else
330 seq_printf(seq, "design voltage: %d mV\n",
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400331 battery->design_voltage);
Len Brown4be44fc2005-08-05 00:44:28 -0400332 seq_printf(seq, "design capacity warning: %d %sh\n",
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400333 battery->design_capacity_warning,
334 acpi_battery_units(battery));
Len Brown4be44fc2005-08-05 00:44:28 -0400335 seq_printf(seq, "design capacity low: %d %sh\n",
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400336 battery->design_capacity_low,
337 acpi_battery_units(battery));
Len Brown4be44fc2005-08-05 00:44:28 -0400338 seq_printf(seq, "capacity granularity 1: %d %sh\n",
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400339 battery->capacity_granularity_1,
340 acpi_battery_units(battery));
Len Brown4be44fc2005-08-05 00:44:28 -0400341 seq_printf(seq, "capacity granularity 2: %d %sh\n",
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400342 battery->capacity_granularity_2,
343 acpi_battery_units(battery));
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400344 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);
Len Brown4be44fc2005-08-05 00:44:28 -0400348 end:
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300349 if (result)
350 seq_printf(seq, "ERROR: Unable to read battery info\n");
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300351 return result;
352}
353
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400354static int acpi_battery_print_state(struct seq_file *seq, int result)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355{
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200356 struct acpi_battery *battery = seq->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300358 if (result)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 goto end;
360
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400361 seq_printf(seq, "present: %s\n",
362 acpi_battery_present(battery)?"yes":"no");
363 if (!acpi_battery_present(battery))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 goto end;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400366 seq_printf(seq, "capacity state: %s\n",
367 (battery->state & 0x04)?"critical":"ok");
368 if ((battery->state & 0x01) && (battery->state & 0x02))
Len Brown4be44fc2005-08-05 00:44:28 -0400369 seq_printf(seq,
370 "charging state: charging/discharging\n");
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400371 else if (battery->state & 0x01)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 seq_printf(seq, "charging state: discharging\n");
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400373 else if (battery->state & 0x02)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 seq_printf(seq, "charging state: charging\n");
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400375 else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 seq_printf(seq, "charging state: charged\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400378 if (battery->present_rate == ACPI_BATTERY_VALUE_UNKNOWN)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 seq_printf(seq, "present rate: unknown\n");
380 else
381 seq_printf(seq, "present rate: %d %s\n",
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400382 battery->present_rate, acpi_battery_units(battery));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400384 if (battery->remaining_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 seq_printf(seq, "remaining capacity: unknown\n");
386 else
387 seq_printf(seq, "remaining capacity: %d %sh\n",
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400388 battery->remaining_capacity, acpi_battery_units(battery));
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400389 if (battery->present_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 seq_printf(seq, "present voltage: unknown\n");
391 else
392 seq_printf(seq, "present voltage: %d mV\n",
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400393 battery->present_voltage);
Len Brown4be44fc2005-08-05 00:44:28 -0400394 end:
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400395 if (result)
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300396 seq_printf(seq, "ERROR: Unable to read battery state\n");
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300397
398 return result;
399}
400
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400401static int acpi_battery_print_alarm(struct seq_file *seq, int result)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402{
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200403 struct acpi_battery *battery = seq->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300405 if (result)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 goto end;
407
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300408 if (!acpi_battery_present(battery)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 seq_printf(seq, "present: no\n");
410 goto end;
411 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 seq_printf(seq, "alarm: ");
413 if (!battery->alarm)
414 seq_printf(seq, "unsupported\n");
415 else
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400416 seq_printf(seq, "%u %sh\n", battery->alarm,
417 acpi_battery_units(battery));
Len Brown4be44fc2005-08-05 00:44:28 -0400418 end:
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300419 if (result)
420 seq_printf(seq, "ERROR: Unable to read battery alarm\n");
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300421 return result;
422}
423
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400424static ssize_t acpi_battery_write_alarm(struct file *file,
425 const char __user * buffer,
426 size_t count, loff_t * ppos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427{
Len Brown4be44fc2005-08-05 00:44:28 -0400428 int result = 0;
429 char alarm_string[12] = { '\0' };
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200430 struct seq_file *m = file->private_data;
431 struct acpi_battery *battery = m->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 if (!battery || (count > sizeof(alarm_string) - 1))
Patrick Mocheld550d982006-06-27 00:41:40 -0400434 return -EINVAL;
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300435 if (result) {
436 result = -ENODEV;
437 goto end;
438 }
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300439 if (!acpi_battery_present(battery)) {
440 result = -ENODEV;
441 goto end;
442 }
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300443 if (copy_from_user(alarm_string, buffer, count)) {
444 result = -EFAULT;
445 goto end;
446 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 alarm_string[count] = '\0';
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400448 battery->alarm = simple_strtol(alarm_string, NULL, 0);
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400449 result = acpi_battery_set_alarm(battery);
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300450 end:
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300451 if (!result)
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400452 return count;
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300453 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454}
455
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400456typedef int(*print_func)(struct seq_file *seq, int result);
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400457
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400458static print_func acpi_print_funcs[ACPI_BATTERY_NUMFILES] = {
459 acpi_battery_print_info,
460 acpi_battery_print_state,
461 acpi_battery_print_alarm,
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400462};
463
464static int acpi_battery_read(int fid, struct seq_file *seq)
465{
466 struct acpi_battery *battery = seq->private;
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400467 int result = acpi_battery_update(battery);
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400468 return acpi_print_funcs[fid](seq, result);
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400469}
470
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400471#define DECLARE_FILE_FUNCTIONS(_name) \
472static int acpi_battery_read_##_name(struct seq_file *seq, void *offset) \
473{ \
474 return acpi_battery_read(_name##_tag, seq); \
475} \
476static 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); \
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400479}
480
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400481DECLARE_FILE_FUNCTIONS(info);
482DECLARE_FILE_FUNCTIONS(state);
483DECLARE_FILE_FUNCTIONS(alarm);
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400484
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400485#undef DECLARE_FILE_FUNCTIONS
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400486
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400487#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 }
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400499
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400500#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 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400514static struct battery_file {
515 struct file_operations ops;
516 mode_t mode;
517 char *name;
518} acpi_battery_file[] = {
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400519 FILE_DESCRIPTION_RO(info),
520 FILE_DESCRIPTION_RO(state),
521 FILE_DESCRIPTION_RW(alarm),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522};
523
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400524#undef FILE_DESCRIPTION_RO
525#undef FILE_DESCRIPTION_RW
526
Len Brown4be44fc2005-08-05 00:44:28 -0400527static int acpi_battery_add_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528{
Len Brown4be44fc2005-08-05 00:44:28 -0400529 struct proc_dir_entry *entry = NULL;
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400530 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 if (!acpi_device_dir(device)) {
533 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
Len Brown4be44fc2005-08-05 00:44:28 -0400534 acpi_battery_dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 if (!acpi_device_dir(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400536 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 acpi_device_dir(device)->owner = THIS_MODULE;
538 }
539
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400540 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 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 }
Patrick Mocheld550d982006-06-27 00:41:40 -0400551 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552}
553
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400554static void acpi_battery_remove_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555{
Alexey Starikovskiy78490d82007-05-11 13:18:55 -0400556 int i;
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400557 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,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 acpi_device_dir(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400563 remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
564 acpi_device_dir(device) = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565}
566
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567/* --------------------------------------------------------------------------
568 Driver Interface
569 -------------------------------------------------------------------------- */
570
Len Brown4be44fc2005-08-05 00:44:28 -0400571static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572{
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200573 struct acpi_battery *battery = data;
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400574 struct acpi_device *device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 if (!battery)
Patrick Mocheld550d982006-06-27 00:41:40 -0400576 return;
Patrick Mochel145def82006-05-19 16:54:39 -0400577 device = battery->device;
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400578 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,
Vladimir Lebedev9ea7d572007-02-20 15:48:06 +0300583 acpi_battery_present(battery));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584}
585
Len Brown4be44fc2005-08-05 00:44:28 -0400586static int acpi_battery_add(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587{
Len Brown4be44fc2005-08-05 00:44:28 -0400588 int result = 0;
589 acpi_status status = 0;
590 struct acpi_battery *battery = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400592 return -EINVAL;
Burman Yan36bcbec2006-12-19 12:56:11 -0800593 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 if (!battery)
Patrick Mocheld550d982006-06-27 00:41:40 -0400595 return -ENOMEM;
Patrick Mochel145def82006-05-19 16:54:39 -0400596 battery->device = device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
598 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
599 acpi_driver_data(device) = battery;
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400600 mutex_init(&battery->lock);
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400601 acpi_battery_update(battery);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 result = acpi_battery_add_fs(device);
603 if (result)
604 goto end;
Patrick Mochel3b073ec2006-05-19 16:54:41 -0400605 status = acpi_install_notify_handler(device->handle,
Vladimir Lebedev9fdae722006-06-27 04:49:00 -0400606 ACPI_ALL_NOTIFY,
Len Brown4be44fc2005-08-05 00:44:28 -0400607 acpi_battery_notify, battery);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 if (ACPI_FAILURE(status)) {
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300609 ACPI_EXCEPTION((AE_INFO, status, "Installing notify handler"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 result = -ENODEV;
611 goto end;
612 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400614 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
615 device->status.battery_present ? "present" : "absent");
Len Brown4be44fc2005-08-05 00:44:28 -0400616 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 if (result) {
618 acpi_battery_remove_fs(device);
619 kfree(battery);
620 }
Patrick Mocheld550d982006-06-27 00:41:40 -0400621 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622}
623
Len Brown4be44fc2005-08-05 00:44:28 -0400624static int acpi_battery_remove(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625{
Len Brown4be44fc2005-08-05 00:44:28 -0400626 acpi_status status = 0;
627 struct acpi_battery *battery = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 if (!device || !acpi_driver_data(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400630 return -EINVAL;
Jan Engelhardt50dd0962006-10-01 00:28:50 +0200631 battery = acpi_driver_data(device);
Patrick Mochel3b073ec2006-05-19 16:54:41 -0400632 status = acpi_remove_notify_handler(device->handle,
Vladimir Lebedev9fdae722006-06-27 04:49:00 -0400633 ACPI_ALL_NOTIFY,
Len Brown4be44fc2005-08-05 00:44:28 -0400634 acpi_battery_notify);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 acpi_battery_remove_fs(device);
Alexey Starikovskiy038fdea2007-09-26 19:42:46 +0400636 mutex_destroy(&battery->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 kfree(battery);
Patrick Mocheld550d982006-06-27 00:41:40 -0400638 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639}
640
Jiri Kosina34c44152006-10-10 14:20:41 -0700641/* this is needed to learn about changes made in suspended state */
Patrick Mochel5d9464a2006-12-07 20:56:27 +0800642static int acpi_battery_resume(struct acpi_device *device)
Jiri Kosina34c44152006-10-10 14:20:41 -0700643{
644 struct acpi_battery *battery;
Jiri Kosina34c44152006-10-10 14:20:41 -0700645 if (!device)
646 return -EINVAL;
Alexey Starikovskiyf1d46612007-09-26 19:42:52 +0400647 battery = acpi_driver_data(device);
648 battery->update_time = 0;
Vladimir Lebedevb6ce4082007-02-20 15:48:06 +0300649 return 0;
Jiri Kosina34c44152006-10-10 14:20:41 -0700650}
651
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400652static 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
Len Brown4be44fc2005-08-05 00:44:28 -0400663static int __init acpi_battery_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664{
Pavel Machek4d8316d2006-08-14 22:37:22 -0700665 if (acpi_disabled)
666 return -ENODEV;
Rich Townsend3f86b832006-07-01 11:36:54 -0400667 acpi_battery_dir = acpi_lock_battery_dir();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 if (!acpi_battery_dir)
Patrick Mocheld550d982006-06-27 00:41:40 -0400669 return -ENODEV;
Alexey Starikovskiyaa650bb2007-09-26 19:42:58 +0400670 if (acpi_bus_register_driver(&acpi_battery_driver) < 0) {
Rich Townsend3f86b832006-07-01 11:36:54 -0400671 acpi_unlock_battery_dir(acpi_battery_dir);
Patrick Mocheld550d982006-06-27 00:41:40 -0400672 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 }
Patrick Mocheld550d982006-06-27 00:41:40 -0400674 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675}
676
Len Brown4be44fc2005-08-05 00:44:28 -0400677static void __exit acpi_battery_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 acpi_bus_unregister_driver(&acpi_battery_driver);
Rich Townsend3f86b832006-07-01 11:36:54 -0400680 acpi_unlock_battery_dir(acpi_battery_dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681}
682
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683module_init(acpi_battery_init);
684module_exit(acpi_battery_exit);