Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 | * |
| 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. |
| 22 | * |
| 23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 24 | */ |
| 25 | |
| 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 <acpi/acpi_bus.h> |
| 33 | #include <acpi/acpi_drivers.h> |
| 34 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #define ACPI_AC_COMPONENT 0x00020000 |
| 36 | #define ACPI_AC_CLASS "ac_adapter" |
| 37 | #define ACPI_AC_HID "ACPI0003" |
| 38 | #define ACPI_AC_DRIVER_NAME "ACPI AC Adapter Driver" |
| 39 | #define ACPI_AC_DEVICE_NAME "AC Adapter" |
| 40 | #define ACPI_AC_FILE_STATE "state" |
| 41 | #define ACPI_AC_NOTIFY_STATUS 0x80 |
| 42 | #define ACPI_AC_STATUS_OFFLINE 0x00 |
| 43 | #define ACPI_AC_STATUS_ONLINE 0x01 |
| 44 | #define ACPI_AC_STATUS_UNKNOWN 0xFF |
| 45 | |
| 46 | #define _COMPONENT ACPI_AC_COMPONENT |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 47 | ACPI_MODULE_NAME("acpi_ac") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | MODULE_AUTHOR("Paul Diefenbaugh"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | MODULE_DESCRIPTION(ACPI_AC_DRIVER_NAME); |
| 51 | MODULE_LICENSE("GPL"); |
| 52 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 53 | static int acpi_ac_add(struct acpi_device *device); |
| 54 | static int acpi_ac_remove(struct acpi_device *device, int type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | static int acpi_ac_open_fs(struct inode *inode, struct file *file); |
| 56 | |
| 57 | static struct acpi_driver acpi_ac_driver = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 58 | .name = ACPI_AC_DRIVER_NAME, |
| 59 | .class = ACPI_AC_CLASS, |
| 60 | .ids = ACPI_AC_HID, |
| 61 | .ops = { |
| 62 | .add = acpi_ac_add, |
| 63 | .remove = acpi_ac_remove, |
| 64 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | struct acpi_ac { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 68 | acpi_handle handle; |
Patrick Mochel | af96179 | 2006-05-19 16:54:32 -0400 | [diff] [blame] | 69 | struct acpi_device * device; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 70 | unsigned long state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | static struct file_operations acpi_ac_fops = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 74 | .open = acpi_ac_open_fs, |
| 75 | .read = seq_read, |
| 76 | .llseek = seq_lseek, |
| 77 | .release = single_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | /* -------------------------------------------------------------------------- |
| 81 | AC Adapter Management |
| 82 | -------------------------------------------------------------------------- */ |
| 83 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 84 | static int acpi_ac_get_state(struct acpi_ac *ac) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 86 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
| 89 | if (!ac) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 90 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
| 92 | status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state); |
| 93 | if (ACPI_FAILURE(status)) { |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 94 | ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | ac->state = ACPI_AC_STATUS_UNKNOWN; |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 96 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 98 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 99 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | /* -------------------------------------------------------------------------- |
| 103 | FS Interface (/proc) |
| 104 | -------------------------------------------------------------------------- */ |
| 105 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 106 | static struct proc_dir_entry *acpi_ac_dir; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
| 108 | static int acpi_ac_seq_show(struct seq_file *seq, void *offset) |
| 109 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 110 | struct acpi_ac *ac = (struct acpi_ac *)seq->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
| 113 | if (!ac) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 114 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | if (acpi_ac_get_state(ac)) { |
| 117 | seq_puts(seq, "ERROR: Unable to read AC Adapter state\n"); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 118 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | seq_puts(seq, "state: "); |
| 122 | switch (ac->state) { |
| 123 | case ACPI_AC_STATUS_OFFLINE: |
| 124 | seq_puts(seq, "off-line\n"); |
| 125 | break; |
| 126 | case ACPI_AC_STATUS_ONLINE: |
| 127 | seq_puts(seq, "on-line\n"); |
| 128 | break; |
| 129 | default: |
| 130 | seq_puts(seq, "unknown\n"); |
| 131 | break; |
| 132 | } |
| 133 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 134 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 136 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | static int acpi_ac_open_fs(struct inode *inode, struct file *file) |
| 138 | { |
| 139 | return single_open(file, acpi_ac_seq_show, PDE(inode)->data); |
| 140 | } |
| 141 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 142 | static int acpi_ac_add_fs(struct acpi_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 144 | struct proc_dir_entry *entry = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
| 147 | if (!acpi_device_dir(device)) { |
| 148 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 149 | acpi_ac_dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | if (!acpi_device_dir(device)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 151 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | acpi_device_dir(device)->owner = THIS_MODULE; |
| 153 | } |
| 154 | |
| 155 | /* 'state' [R] */ |
| 156 | entry = create_proc_entry(ACPI_AC_FILE_STATE, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 157 | S_IRUGO, acpi_device_dir(device)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | if (!entry) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 159 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | else { |
| 161 | entry->proc_fops = &acpi_ac_fops; |
| 162 | entry->data = acpi_driver_data(device); |
| 163 | entry->owner = THIS_MODULE; |
| 164 | } |
| 165 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 166 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 169 | static int acpi_ac_remove_fs(struct acpi_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
| 172 | if (acpi_device_dir(device)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 173 | remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | remove_proc_entry(acpi_device_bid(device), acpi_ac_dir); |
| 176 | acpi_device_dir(device) = NULL; |
| 177 | } |
| 178 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 179 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | /* -------------------------------------------------------------------------- |
| 183 | Driver Model |
| 184 | -------------------------------------------------------------------------- */ |
| 185 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 186 | static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 188 | struct acpi_ac *ac = (struct acpi_ac *)data; |
| 189 | struct acpi_device *device = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
| 192 | if (!ac) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 193 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
Patrick Mochel | af96179 | 2006-05-19 16:54:32 -0400 | [diff] [blame] | 195 | device = ac->device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | switch (event) { |
| 197 | case ACPI_AC_NOTIFY_STATUS: |
| 198 | acpi_ac_get_state(ac); |
| 199 | acpi_bus_generate_event(device, event, (u32) ac->state); |
| 200 | break; |
| 201 | default: |
| 202 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 203 | "Unsupported event [0x%x]\n", event)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | break; |
| 205 | } |
| 206 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 207 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | } |
| 209 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 210 | static int acpi_ac_add(struct acpi_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 212 | int result = 0; |
| 213 | acpi_status status = AE_OK; |
| 214 | struct acpi_ac *ac = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | |
| 217 | if (!device) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 218 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
| 220 | ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL); |
| 221 | if (!ac) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 222 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | memset(ac, 0, sizeof(struct acpi_ac)); |
| 224 | |
| 225 | ac->handle = device->handle; |
Patrick Mochel | af96179 | 2006-05-19 16:54:32 -0400 | [diff] [blame] | 226 | ac->device = device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME); |
| 228 | strcpy(acpi_device_class(device), ACPI_AC_CLASS); |
| 229 | acpi_driver_data(device) = ac; |
| 230 | |
| 231 | result = acpi_ac_get_state(ac); |
| 232 | if (result) |
| 233 | goto end; |
| 234 | |
| 235 | result = acpi_ac_add_fs(device); |
| 236 | if (result) |
| 237 | goto end; |
| 238 | |
| 239 | status = acpi_install_notify_handler(ac->handle, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 240 | ACPI_DEVICE_NOTIFY, acpi_ac_notify, |
| 241 | ac); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | result = -ENODEV; |
| 244 | goto end; |
| 245 | } |
| 246 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 247 | printk(KERN_INFO PREFIX "%s [%s] (%s)\n", |
| 248 | acpi_device_name(device), acpi_device_bid(device), |
| 249 | ac->state ? "on-line" : "off-line"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 251 | end: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | if (result) { |
| 253 | acpi_ac_remove_fs(device); |
| 254 | kfree(ac); |
| 255 | } |
| 256 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 257 | return result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | } |
| 259 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 260 | static int acpi_ac_remove(struct acpi_device *device, int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 262 | acpi_status status = AE_OK; |
| 263 | struct acpi_ac *ac = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | |
| 266 | if (!device || !acpi_driver_data(device)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 267 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 269 | ac = (struct acpi_ac *)acpi_driver_data(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | |
| 271 | status = acpi_remove_notify_handler(ac->handle, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 272 | ACPI_DEVICE_NOTIFY, acpi_ac_notify); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | |
| 274 | acpi_ac_remove_fs(device); |
| 275 | |
| 276 | kfree(ac); |
| 277 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 278 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 281 | static int __init acpi_ac_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 283 | int result = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | |
| 286 | acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir); |
| 287 | if (!acpi_ac_dir) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 288 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | acpi_ac_dir->owner = THIS_MODULE; |
| 290 | |
| 291 | result = acpi_bus_register_driver(&acpi_ac_driver); |
| 292 | if (result < 0) { |
| 293 | remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 294 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | } |
| 296 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 297 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 300 | static void __exit acpi_ac_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
| 303 | acpi_bus_unregister_driver(&acpi_ac_driver); |
| 304 | |
| 305 | remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); |
| 306 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 307 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | module_init(acpi_ac_init); |
| 311 | module_exit(acpi_ac_exit); |