blob: f71b756b05c40981cdd6e9e10320c7edca06842c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * acpi_ac.c - ACPI AC Adapter Driver ($Revision: 27 $)
3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
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.
13 *
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.
18 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 */
21
22#include <linux/kernel.h>
23#include <linux/module.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090024#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <linux/init.h>
26#include <linux/types.h>
Lan Tianyu0ab5bb62013-05-08 07:28:46 +000027#include <linux/dmi.h>
28#include <linux/delay.h>
Lan Tianyue63f6e22014-07-07 01:13:46 +020029#ifdef CONFIG_ACPI_PROCFS_POWER
30#include <linux/proc_fs.h>
31#include <linux/seq_file.h>
32#endif
Zhang Ruicc8ef522013-09-25 20:39:45 +080033#include <linux/platform_device.h>
Alexey Starikovskiyd5b4a3d2007-09-26 19:44:06 +040034#include <linux/power_supply.h>
Lv Zheng8b484632013-12-03 08:49:16 +080035#include <linux/acpi.h>
Alexander Mezin4eee4f02014-03-12 00:58:48 +070036#include "battery.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Len Browna192a952009-07-28 16:45:54 -040038#define PREFIX "ACPI: "
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#define ACPI_AC_CLASS "ac_adapter"
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#define ACPI_AC_DEVICE_NAME "AC Adapter"
42#define ACPI_AC_FILE_STATE "state"
43#define ACPI_AC_NOTIFY_STATUS 0x80
44#define ACPI_AC_STATUS_OFFLINE 0x00
45#define ACPI_AC_STATUS_ONLINE 0x01
46#define ACPI_AC_STATUS_UNKNOWN 0xFF
47
48#define _COMPONENT ACPI_AC_COMPONENT
Len Brownf52fd662007-02-12 22:42:12 -050049ACPI_MODULE_NAME("ac");
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Len Brownf52fd662007-02-12 22:42:12 -050051MODULE_AUTHOR("Paul Diefenbaugh");
Len Brown7cda93e2007-02-12 23:50:02 -050052MODULE_DESCRIPTION("ACPI AC Adapter Driver");
Linus Torvalds1da177e2005-04-16 15:20:36 -070053MODULE_LICENSE("GPL");
54
Lan Tianyue63f6e22014-07-07 01:13:46 +020055
Guenter Roeck98012842014-05-06 19:18:28 -070056static int acpi_ac_add(struct acpi_device *device);
57static int acpi_ac_remove(struct acpi_device *device);
58static void acpi_ac_notify(struct acpi_device *device, u32 event);
59
60static const struct acpi_device_id ac_device_ids[] = {
61 {"ACPI0003", 0},
62 {"", 0},
63};
64MODULE_DEVICE_TABLE(acpi, ac_device_ids);
65
66#ifdef CONFIG_PM_SLEEP
67static int acpi_ac_resume(struct device *dev);
68#endif
69static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
70
Lan Tianyue63f6e22014-07-07 01:13:46 +020071#ifdef CONFIG_ACPI_PROCFS_POWER
72extern struct proc_dir_entry *acpi_lock_ac_dir(void);
73extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir);
74static int acpi_ac_open_fs(struct inode *inode, struct file *file);
75#endif
76
77
Lan Tianyu0ab5bb62013-05-08 07:28:46 +000078static int ac_sleep_before_get_state_ms;
79
Guenter Roeck98012842014-05-06 19:18:28 -070080static struct acpi_driver acpi_ac_driver = {
81 .name = "ac",
82 .class = ACPI_AC_CLASS,
83 .ids = ac_device_ids,
84 .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
85 .ops = {
86 .add = acpi_ac_add,
87 .remove = acpi_ac_remove,
88 .notify = acpi_ac_notify,
89 },
90 .drv.pm = &acpi_ac_pm,
91};
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093struct acpi_ac {
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +010094 struct power_supply *charger;
95 struct power_supply_desc charger_desc;
Guenter Roeck98012842014-05-06 19:18:28 -070096 struct acpi_device * device;
Matthew Wilcox27663c52008-10-10 02:22:59 -040097 unsigned long long state;
Alexander Mezin4eee4f02014-03-12 00:58:48 +070098 struct notifier_block battery_nb;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099};
100
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100101#define to_acpi_ac(x) power_supply_get_drvdata(x)
Alexey Starikovskiyd5b4a3d2007-09-26 19:44:06 +0400102
Lan Tianyue63f6e22014-07-07 01:13:46 +0200103#ifdef CONFIG_ACPI_PROCFS_POWER
104static const struct file_operations acpi_ac_fops = {
105 .owner = THIS_MODULE,
106 .open = acpi_ac_open_fs,
107 .read = seq_read,
108 .llseek = seq_lseek,
109 .release = single_release,
110};
111#endif
112
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113/* --------------------------------------------------------------------------
114 AC Adapter Management
115 -------------------------------------------------------------------------- */
116
Len Brown4be44fc2005-08-05 00:44:28 -0400117static int acpi_ac_get_state(struct acpi_ac *ac)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118{
Guenter Roeck98012842014-05-06 19:18:28 -0700119 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Guenter Roeck98012842014-05-06 19:18:28 -0700121 if (!ac)
122 return -EINVAL;
123
124 status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL,
Zhang Ruicc8ef522013-09-25 20:39:45 +0800125 &ac->state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 if (ACPI_FAILURE(status)) {
Zhang Ruicc8ef522013-09-25 20:39:45 +0800127 ACPI_EXCEPTION((AE_INFO, status,
128 "Error reading AC Adapter state"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 ac->state = ACPI_AC_STATUS_UNKNOWN;
Patrick Mocheld550d982006-06-27 00:41:40 -0400130 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 }
Len Brown4be44fc2005-08-05 00:44:28 -0400132
Patrick Mocheld550d982006-06-27 00:41:40 -0400133 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134}
135
Zhang Rui3151dbb2010-12-08 10:40:45 +0800136/* --------------------------------------------------------------------------
137 sysfs I/F
138 -------------------------------------------------------------------------- */
139static int get_ac_property(struct power_supply *psy,
140 enum power_supply_property psp,
141 union power_supply_propval *val)
142{
143 struct acpi_ac *ac = to_acpi_ac(psy);
144
145 if (!ac)
146 return -ENODEV;
147
148 if (acpi_ac_get_state(ac))
149 return -ENODEV;
150
151 switch (psp) {
152 case POWER_SUPPLY_PROP_ONLINE:
153 val->intval = ac->state;
154 break;
155 default:
156 return -EINVAL;
157 }
158 return 0;
159}
160
161static enum power_supply_property ac_props[] = {
162 POWER_SUPPLY_PROP_ONLINE,
163};
164
Lan Tianyue63f6e22014-07-07 01:13:46 +0200165#ifdef CONFIG_ACPI_PROCFS_POWER
166/* --------------------------------------------------------------------------
167 FS Interface (/proc)
168 -------------------------------------------------------------------------- */
169
170static struct proc_dir_entry *acpi_ac_dir;
171
172static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
173{
174 struct acpi_ac *ac = seq->private;
175
176
177 if (!ac)
178 return 0;
179
180 if (acpi_ac_get_state(ac)) {
181 seq_puts(seq, "ERROR: Unable to read AC Adapter state\n");
182 return 0;
183 }
184
185 seq_puts(seq, "state: ");
186 switch (ac->state) {
187 case ACPI_AC_STATUS_OFFLINE:
188 seq_puts(seq, "off-line\n");
189 break;
190 case ACPI_AC_STATUS_ONLINE:
191 seq_puts(seq, "on-line\n");
192 break;
193 default:
194 seq_puts(seq, "unknown\n");
195 break;
196 }
197
198 return 0;
199}
200
201static int acpi_ac_open_fs(struct inode *inode, struct file *file)
202{
203 return single_open(file, acpi_ac_seq_show, PDE_DATA(inode));
204}
205
206static int acpi_ac_add_fs(struct acpi_ac *ac)
207{
208 struct proc_dir_entry *entry = NULL;
209
210 printk(KERN_WARNING PREFIX "Deprecated procfs I/F for AC is loaded,"
211 " please retry with CONFIG_ACPI_PROCFS_POWER cleared\n");
212 if (!acpi_device_dir(ac->device)) {
213 acpi_device_dir(ac->device) =
214 proc_mkdir(acpi_device_bid(ac->device), acpi_ac_dir);
215 if (!acpi_device_dir(ac->device))
216 return -ENODEV;
217 }
218
219 /* 'state' [R] */
220 entry = proc_create_data(ACPI_AC_FILE_STATE,
221 S_IRUGO, acpi_device_dir(ac->device),
222 &acpi_ac_fops, ac);
223 if (!entry)
224 return -ENODEV;
225 return 0;
226}
227
228static int acpi_ac_remove_fs(struct acpi_ac *ac)
229{
230
231 if (acpi_device_dir(ac->device)) {
232 remove_proc_entry(ACPI_AC_FILE_STATE,
233 acpi_device_dir(ac->device));
234 remove_proc_entry(acpi_device_bid(ac->device), acpi_ac_dir);
235 acpi_device_dir(ac->device) = NULL;
236 }
237
238 return 0;
239}
240#endif
241
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242/* --------------------------------------------------------------------------
243 Driver Model
244 -------------------------------------------------------------------------- */
245
Guenter Roeck98012842014-05-06 19:18:28 -0700246static void acpi_ac_notify(struct acpi_device *device, u32 event)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247{
Guenter Roeck98012842014-05-06 19:18:28 -0700248 struct acpi_ac *ac = acpi_driver_data(device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
250 if (!ac)
Patrick Mocheld550d982006-06-27 00:41:40 -0400251 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 switch (event) {
Len Brownf163ff52008-06-14 01:26:37 -0400254 default:
255 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
256 "Unsupported event [0x%x]\n", event));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 case ACPI_AC_NOTIFY_STATUS:
Christian Lupien03d78252004-08-19 01:26:00 -0400258 case ACPI_NOTIFY_BUS_CHECK:
259 case ACPI_NOTIFY_DEVICE_CHECK:
Lan Tianyu0ab5bb62013-05-08 07:28:46 +0000260 /*
261 * A buggy BIOS may notify AC first and then sleep for
262 * a specific time before doing actual operations in the
263 * EC event handler (_Qxx). This will cause the AC state
264 * reported by the ACPI event to be incorrect, so wait for a
265 * specific time for the EC event handler to make progress.
266 */
267 if (ac_sleep_before_get_state_ms > 0)
268 msleep(ac_sleep_before_get_state_ms);
269
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 acpi_ac_get_state(ac);
Guenter Roeck98012842014-05-06 19:18:28 -0700271 acpi_bus_generate_netlink_event(device->pnp.device_class,
272 dev_name(&device->dev), event,
273 (u32) ac->state);
274 acpi_notifier_call_chain(device, event, (u32) ac->state);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100275 kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 }
277
Patrick Mocheld550d982006-06-27 00:41:40 -0400278 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279}
280
Alexander Mezin4eee4f02014-03-12 00:58:48 +0700281static int acpi_ac_battery_notify(struct notifier_block *nb,
282 unsigned long action, void *data)
283{
284 struct acpi_ac *ac = container_of(nb, struct acpi_ac, battery_nb);
285 struct acpi_bus_event *event = (struct acpi_bus_event *)data;
286
287 /*
288 * On HP Pavilion dv6-6179er AC status notifications aren't triggered
289 * when adapter is plugged/unplugged. However, battery status
290 * notifcations are triggered when battery starts charging or
291 * discharging. Re-reading AC status triggers lost AC notifications,
292 * if AC status has changed.
293 */
294 if (strcmp(event->device_class, ACPI_BATTERY_CLASS) == 0 &&
295 event->type == ACPI_BATTERY_NOTIFY_STATUS)
296 acpi_ac_get_state(ac);
297
298 return NOTIFY_OK;
299}
300
Lan Tianyu0ab5bb62013-05-08 07:28:46 +0000301static int thinkpad_e530_quirk(const struct dmi_system_id *d)
302{
303 ac_sleep_before_get_state_ms = 1000;
304 return 0;
305}
306
Mathias Krause44f610c2015-06-13 14:26:49 +0200307static const struct dmi_system_id ac_dmi_table[] = {
Lan Tianyu0ab5bb62013-05-08 07:28:46 +0000308 {
309 .callback = thinkpad_e530_quirk,
310 .ident = "thinkpad e530",
311 .matches = {
312 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
313 DMI_MATCH(DMI_PRODUCT_NAME, "32597CG"),
314 },
315 },
316 {},
317};
318
Guenter Roeck98012842014-05-06 19:18:28 -0700319static int acpi_ac_add(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320{
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100321 struct power_supply_config psy_cfg = {};
Len Brown4be44fc2005-08-05 00:44:28 -0400322 int result = 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400323 struct acpi_ac *ac = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
Guenter Roeck98012842014-05-06 19:18:28 -0700325
326 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400327 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
Burman Yan36bcbec2006-12-19 12:56:11 -0800329 ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 if (!ac)
Patrick Mocheld550d982006-06-27 00:41:40 -0400331 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
Guenter Roeck98012842014-05-06 19:18:28 -0700333 ac->device = device;
334 strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME);
335 strcpy(acpi_device_class(device), ACPI_AC_CLASS);
336 device->driver_data = ac;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
338 result = acpi_ac_get_state(ac);
339 if (result)
340 goto end;
341
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100342 psy_cfg.drv_data = ac;
343
344 ac->charger_desc.name = acpi_device_bid(device);
Lan Tianyue63f6e22014-07-07 01:13:46 +0200345#ifdef CONFIG_ACPI_PROCFS_POWER
346 result = acpi_ac_add_fs(ac);
347 if (result)
348 goto end;
349#endif
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100350 ac->charger_desc.type = POWER_SUPPLY_TYPE_MAINS;
351 ac->charger_desc.properties = ac_props;
352 ac->charger_desc.num_properties = ARRAY_SIZE(ac_props);
353 ac->charger_desc.get_property = get_ac_property;
354 ac->charger = power_supply_register(&ac->device->dev,
355 &ac->charger_desc, &psy_cfg);
356 if (IS_ERR(ac->charger)) {
357 result = PTR_ERR(ac->charger);
Lan Tianyuf197ac12012-07-20 13:29:16 +0800358 goto end;
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100359 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360
Len Brown4be44fc2005-08-05 00:44:28 -0400361 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
Guenter Roeck98012842014-05-06 19:18:28 -0700362 acpi_device_name(device), acpi_device_bid(device),
Len Brown4be44fc2005-08-05 00:44:28 -0400363 ac->state ? "on-line" : "off-line");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364
Alexander Mezin4eee4f02014-03-12 00:58:48 +0700365 ac->battery_nb.notifier_call = acpi_ac_battery_notify;
366 register_acpi_notifier(&ac->battery_nb);
Lan Tianyuab0fd672013-10-12 21:04:48 +0800367end:
Lan Tianyue63f6e22014-07-07 01:13:46 +0200368 if (result) {
369#ifdef CONFIG_ACPI_PROCFS_POWER
370 acpi_ac_remove_fs(ac);
371#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 kfree(ac);
Lan Tianyue63f6e22014-07-07 01:13:46 +0200373 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374
Lan Tianyu0ab5bb62013-05-08 07:28:46 +0000375 dmi_check_system(ac_dmi_table);
Patrick Mocheld550d982006-06-27 00:41:40 -0400376 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377}
378
Rafael J. Wysocki90692402012-08-09 23:00:02 +0200379#ifdef CONFIG_PM_SLEEP
Rafael J. Wysockiccda7062012-06-27 23:26:35 +0200380static int acpi_ac_resume(struct device *dev)
Alexey Starikovskiy5bfeca32007-11-14 17:00:39 -0800381{
382 struct acpi_ac *ac;
383 unsigned old_state;
Rafael J. Wysockiccda7062012-06-27 23:26:35 +0200384
385 if (!dev)
Alexey Starikovskiy5bfeca32007-11-14 17:00:39 -0800386 return -EINVAL;
Rafael J. Wysockiccda7062012-06-27 23:26:35 +0200387
Guenter Roeck98012842014-05-06 19:18:28 -0700388 ac = acpi_driver_data(to_acpi_device(dev));
Rafael J. Wysockiccda7062012-06-27 23:26:35 +0200389 if (!ac)
390 return -EINVAL;
391
Alexey Starikovskiy5bfeca32007-11-14 17:00:39 -0800392 old_state = ac->state;
393 if (acpi_ac_get_state(ac))
394 return 0;
395 if (old_state != ac->state)
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100396 kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE);
Alexey Starikovskiy5bfeca32007-11-14 17:00:39 -0800397 return 0;
398}
Shuah Khan06521c22014-02-12 20:19:05 -0700399#else
400#define acpi_ac_resume NULL
Rafael J. Wysocki90692402012-08-09 23:00:02 +0200401#endif
Alexey Starikovskiy5bfeca32007-11-14 17:00:39 -0800402
Guenter Roeck98012842014-05-06 19:18:28 -0700403static int acpi_ac_remove(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404{
Guenter Roeck98012842014-05-06 19:18:28 -0700405 struct acpi_ac *ac = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
Guenter Roeck98012842014-05-06 19:18:28 -0700407
408 if (!device || !acpi_driver_data(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400409 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410
Guenter Roeck98012842014-05-06 19:18:28 -0700411 ac = acpi_driver_data(device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100413 power_supply_unregister(ac->charger);
Alexander Mezin4eee4f02014-03-12 00:58:48 +0700414 unregister_acpi_notifier(&ac->battery_nb);
Zhang Ruicc8ef522013-09-25 20:39:45 +0800415
Lan Tianyue63f6e22014-07-07 01:13:46 +0200416#ifdef CONFIG_ACPI_PROCFS_POWER
417 acpi_ac_remove_fs(ac);
418#endif
419
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 kfree(ac);
421
Patrick Mocheld550d982006-06-27 00:41:40 -0400422 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423}
424
Len Brown4be44fc2005-08-05 00:44:28 -0400425static int __init acpi_ac_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426{
Rich Townsend3f86b832006-07-01 11:36:54 -0400427 int result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428
Pavel Machek4d8316d2006-08-14 22:37:22 -0700429 if (acpi_disabled)
430 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
Lan Tianyue63f6e22014-07-07 01:13:46 +0200432#ifdef CONFIG_ACPI_PROCFS_POWER
433 acpi_ac_dir = acpi_lock_ac_dir();
434 if (!acpi_ac_dir)
Patrick Mocheld550d982006-06-27 00:41:40 -0400435 return -ENODEV;
Lan Tianyue63f6e22014-07-07 01:13:46 +0200436#endif
437
438
439 result = acpi_bus_register_driver(&acpi_ac_driver);
440 if (result < 0) {
441#ifdef CONFIG_ACPI_PROCFS_POWER
442 acpi_unlock_ac_dir(acpi_ac_dir);
443#endif
444 return -ENODEV;
445 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446
Patrick Mocheld550d982006-06-27 00:41:40 -0400447 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448}
449
Len Brown4be44fc2005-08-05 00:44:28 -0400450static void __exit acpi_ac_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451{
Guenter Roeck98012842014-05-06 19:18:28 -0700452 acpi_bus_unregister_driver(&acpi_ac_driver);
Lan Tianyue63f6e22014-07-07 01:13:46 +0200453#ifdef CONFIG_ACPI_PROCFS_POWER
454 acpi_unlock_ac_dir(acpi_ac_dir);
455#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457module_init(acpi_ac_init);
458module_exit(acpi_ac_exit);