]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
50a4da89 | 2 | * button.c - ACPI Button Driver |
1da177e4 LT |
3 | * |
4 | * Copyright (C) 2001, 2002 Andy Grover <[email protected]> | |
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <[email protected]> | |
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> | |
b34a8030 AS |
29 | #include <linux/types.h> |
30 | #include <linux/proc_fs.h> | |
31 | #include <linux/seq_file.h> | |
c0968f0e | 32 | #include <linux/input.h> |
5a0e3ad6 | 33 | #include <linux/slab.h> |
1da177e4 LT |
34 | #include <acpi/acpi_bus.h> |
35 | #include <acpi/acpi_drivers.h> | |
36 | ||
a192a958 LB |
37 | #define PREFIX "ACPI: " |
38 | ||
1da177e4 | 39 | #define ACPI_BUTTON_CLASS "button" |
b34a8030 AS |
40 | #define ACPI_BUTTON_FILE_INFO "info" |
41 | #define ACPI_BUTTON_FILE_STATE "state" | |
42 | #define ACPI_BUTTON_TYPE_UNKNOWN 0x00 | |
1da177e4 LT |
43 | #define ACPI_BUTTON_NOTIFY_STATUS 0x80 |
44 | ||
45 | #define ACPI_BUTTON_SUBCLASS_POWER "power" | |
4be44fcd | 46 | #define ACPI_BUTTON_HID_POWER "PNP0C0C" |
d68b597c | 47 | #define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button" |
1da177e4 | 48 | #define ACPI_BUTTON_TYPE_POWER 0x01 |
1da177e4 LT |
49 | |
50 | #define ACPI_BUTTON_SUBCLASS_SLEEP "sleep" | |
51 | #define ACPI_BUTTON_HID_SLEEP "PNP0C0E" | |
d68b597c | 52 | #define ACPI_BUTTON_DEVICE_NAME_SLEEP "Sleep Button" |
1da177e4 | 53 | #define ACPI_BUTTON_TYPE_SLEEP 0x03 |
1da177e4 LT |
54 | |
55 | #define ACPI_BUTTON_SUBCLASS_LID "lid" | |
56 | #define ACPI_BUTTON_HID_LID "PNP0C0D" | |
57 | #define ACPI_BUTTON_DEVICE_NAME_LID "Lid Switch" | |
58 | #define ACPI_BUTTON_TYPE_LID 0x05 | |
59 | ||
60 | #define _COMPONENT ACPI_BUTTON_COMPONENT | |
f52fd66d | 61 | ACPI_MODULE_NAME("button"); |
1da177e4 | 62 | |
c0968f0e | 63 | MODULE_AUTHOR("Paul Diefenbaugh"); |
7cda93e0 | 64 | MODULE_DESCRIPTION("ACPI Button Driver"); |
1da177e4 LT |
65 | MODULE_LICENSE("GPL"); |
66 | ||
1ba90e3a TR |
67 | static const struct acpi_device_id button_device_ids[] = { |
68 | {ACPI_BUTTON_HID_LID, 0}, | |
69 | {ACPI_BUTTON_HID_SLEEP, 0}, | |
70 | {ACPI_BUTTON_HID_SLEEPF, 0}, | |
71 | {ACPI_BUTTON_HID_POWER, 0}, | |
72 | {ACPI_BUTTON_HID_POWERF, 0}, | |
73 | {"", 0}, | |
74 | }; | |
75 | MODULE_DEVICE_TABLE(acpi, button_device_ids); | |
76 | ||
4be44fcd LB |
77 | static int acpi_button_add(struct acpi_device *device); |
78 | static int acpi_button_remove(struct acpi_device *device, int type); | |
23de5d9e | 79 | static int acpi_button_resume(struct acpi_device *device); |
373cfc36 | 80 | static void acpi_button_notify(struct acpi_device *device, u32 event); |
b34a8030 AS |
81 | static int acpi_button_info_open_fs(struct inode *inode, struct file *file); |
82 | static int acpi_button_state_open_fs(struct inode *inode, struct file *file); | |
1da177e4 LT |
83 | |
84 | static struct acpi_driver acpi_button_driver = { | |
c2b6705b | 85 | .name = "button", |
4be44fcd | 86 | .class = ACPI_BUTTON_CLASS, |
1ba90e3a | 87 | .ids = button_device_ids, |
4be44fcd LB |
88 | .ops = { |
89 | .add = acpi_button_add, | |
23de5d9e | 90 | .resume = acpi_button_resume, |
4be44fcd | 91 | .remove = acpi_button_remove, |
373cfc36 | 92 | .notify = acpi_button_notify, |
c0968f0e | 93 | }, |
1da177e4 LT |
94 | }; |
95 | ||
96 | struct acpi_button { | |
c0968f0e DT |
97 | unsigned int type; |
98 | struct input_dev *input; | |
99 | char phys[32]; /* for input device */ | |
4be44fcd | 100 | unsigned long pushed; |
1da177e4 LT |
101 | }; |
102 | ||
d7508032 | 103 | static const struct file_operations acpi_button_info_fops = { |
cf7acfab | 104 | .owner = THIS_MODULE, |
4be44fcd LB |
105 | .open = acpi_button_info_open_fs, |
106 | .read = seq_read, | |
107 | .llseek = seq_lseek, | |
108 | .release = single_release, | |
b34a8030 AS |
109 | }; |
110 | ||
d7508032 | 111 | static const struct file_operations acpi_button_state_fops = { |
cf7acfab | 112 | .owner = THIS_MODULE, |
4be44fcd LB |
113 | .open = acpi_button_state_open_fs, |
114 | .read = seq_read, | |
115 | .llseek = seq_lseek, | |
116 | .release = single_release, | |
b34a8030 | 117 | }; |
4be44fcd | 118 | |
7e12715e JB |
119 | static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier); |
120 | static struct acpi_device *lid_device; | |
121 | ||
b34a8030 AS |
122 | /* -------------------------------------------------------------------------- |
123 | FS Interface (/proc) | |
124 | -------------------------------------------------------------------------- */ | |
125 | ||
4be44fcd | 126 | static struct proc_dir_entry *acpi_button_dir; |
b34a8030 AS |
127 | |
128 | static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) | |
129 | { | |
106c19e7 | 130 | struct acpi_device *device = seq->private; |
b34a8030 | 131 | |
4be44fcd | 132 | seq_printf(seq, "type: %s\n", |
106c19e7 | 133 | acpi_device_name(device)); |
d550d98d | 134 | return 0; |
b34a8030 AS |
135 | } |
136 | ||
137 | static int acpi_button_info_open_fs(struct inode *inode, struct file *file) | |
138 | { | |
139 | return single_open(file, acpi_button_info_seq_show, PDE(inode)->data); | |
140 | } | |
4be44fcd | 141 | |
b34a8030 AS |
142 | static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) |
143 | { | |
106c19e7 | 144 | struct acpi_device *device = seq->private; |
4be44fcd | 145 | acpi_status status; |
27663c58 | 146 | unsigned long long state; |
b34a8030 | 147 | |
106c19e7 | 148 | status = acpi_evaluate_integer(device->handle, "_LID", NULL, &state); |
c0968f0e DT |
149 | seq_printf(seq, "state: %s\n", |
150 | ACPI_FAILURE(status) ? "unsupported" : | |
151 | (state ? "open" : "closed")); | |
d550d98d | 152 | return 0; |
b34a8030 AS |
153 | } |
154 | ||
155 | static int acpi_button_state_open_fs(struct inode *inode, struct file *file) | |
156 | { | |
157 | return single_open(file, acpi_button_state_seq_show, PDE(inode)->data); | |
158 | } | |
159 | ||
160 | static struct proc_dir_entry *acpi_power_dir; | |
161 | static struct proc_dir_entry *acpi_sleep_dir; | |
162 | static struct proc_dir_entry *acpi_lid_dir; | |
163 | ||
4be44fcd | 164 | static int acpi_button_add_fs(struct acpi_device *device) |
b34a8030 | 165 | { |
1bce8113 | 166 | struct acpi_button *button = acpi_driver_data(device); |
4be44fcd | 167 | struct proc_dir_entry *entry = NULL; |
b34a8030 AS |
168 | |
169 | switch (button->type) { | |
170 | case ACPI_BUTTON_TYPE_POWER: | |
b34a8030 | 171 | if (!acpi_power_dir) |
4be44fcd LB |
172 | acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, |
173 | acpi_button_dir); | |
b34a8030 AS |
174 | entry = acpi_power_dir; |
175 | break; | |
176 | case ACPI_BUTTON_TYPE_SLEEP: | |
b34a8030 | 177 | if (!acpi_sleep_dir) |
4be44fcd LB |
178 | acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP, |
179 | acpi_button_dir); | |
b34a8030 AS |
180 | entry = acpi_sleep_dir; |
181 | break; | |
182 | case ACPI_BUTTON_TYPE_LID: | |
183 | if (!acpi_lid_dir) | |
4be44fcd LB |
184 | acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, |
185 | acpi_button_dir); | |
b34a8030 AS |
186 | entry = acpi_lid_dir; |
187 | break; | |
188 | } | |
189 | ||
190 | if (!entry) | |
d550d98d | 191 | return -ENODEV; |
b34a8030 AS |
192 | |
193 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); | |
194 | if (!acpi_device_dir(device)) | |
d550d98d | 195 | return -ENODEV; |
b34a8030 AS |
196 | |
197 | /* 'info' [R] */ | |
cf7acfab DL |
198 | entry = proc_create_data(ACPI_BUTTON_FILE_INFO, |
199 | S_IRUGO, acpi_device_dir(device), | |
106c19e7 | 200 | &acpi_button_info_fops, device); |
b34a8030 | 201 | if (!entry) |
d550d98d | 202 | return -ENODEV; |
b34a8030 AS |
203 | |
204 | /* show lid state [R] */ | |
205 | if (button->type == ACPI_BUTTON_TYPE_LID) { | |
cf7acfab DL |
206 | entry = proc_create_data(ACPI_BUTTON_FILE_STATE, |
207 | S_IRUGO, acpi_device_dir(device), | |
106c19e7 | 208 | &acpi_button_state_fops, device); |
b34a8030 | 209 | if (!entry) |
a6fc6720 | 210 | return -ENODEV; |
b34a8030 AS |
211 | } |
212 | ||
d550d98d | 213 | return 0; |
b34a8030 AS |
214 | } |
215 | ||
4be44fcd | 216 | static int acpi_button_remove_fs(struct acpi_device *device) |
b34a8030 | 217 | { |
c0968f0e | 218 | struct acpi_button *button = acpi_driver_data(device); |
b34a8030 | 219 | |
b34a8030 AS |
220 | if (acpi_device_dir(device)) { |
221 | if (button->type == ACPI_BUTTON_TYPE_LID) | |
222 | remove_proc_entry(ACPI_BUTTON_FILE_STATE, | |
4be44fcd | 223 | acpi_device_dir(device)); |
b34a8030 | 224 | remove_proc_entry(ACPI_BUTTON_FILE_INFO, |
4be44fcd | 225 | acpi_device_dir(device)); |
b34a8030 AS |
226 | |
227 | remove_proc_entry(acpi_device_bid(device), | |
4be44fcd | 228 | acpi_device_dir(device)->parent); |
b34a8030 AS |
229 | acpi_device_dir(device) = NULL; |
230 | } | |
231 | ||
d550d98d | 232 | return 0; |
b34a8030 AS |
233 | } |
234 | ||
1da177e4 LT |
235 | /* -------------------------------------------------------------------------- |
236 | Driver Interface | |
237 | -------------------------------------------------------------------------- */ | |
7e12715e JB |
238 | int acpi_lid_notifier_register(struct notifier_block *nb) |
239 | { | |
240 | return blocking_notifier_chain_register(&acpi_lid_notifier, nb); | |
241 | } | |
242 | EXPORT_SYMBOL(acpi_lid_notifier_register); | |
243 | ||
244 | int acpi_lid_notifier_unregister(struct notifier_block *nb) | |
245 | { | |
246 | return blocking_notifier_chain_unregister(&acpi_lid_notifier, nb); | |
247 | } | |
248 | EXPORT_SYMBOL(acpi_lid_notifier_unregister); | |
249 | ||
250 | int acpi_lid_open(void) | |
251 | { | |
252 | acpi_status status; | |
253 | unsigned long long state; | |
254 | ||
2c907b72 JB |
255 | if (!lid_device) |
256 | return -ENODEV; | |
257 | ||
7e12715e JB |
258 | status = acpi_evaluate_integer(lid_device->handle, "_LID", NULL, |
259 | &state); | |
260 | if (ACPI_FAILURE(status)) | |
261 | return -ENODEV; | |
262 | ||
263 | return !!state; | |
264 | } | |
265 | EXPORT_SYMBOL(acpi_lid_open); | |
266 | ||
106c19e7 | 267 | static int acpi_lid_send_state(struct acpi_device *device) |
23de5d9e | 268 | { |
106c19e7 | 269 | struct acpi_button *button = acpi_driver_data(device); |
27663c58 | 270 | unsigned long long state; |
23de5d9e | 271 | acpi_status status; |
7e12715e | 272 | int ret; |
23de5d9e | 273 | |
106c19e7 | 274 | status = acpi_evaluate_integer(device->handle, "_LID", NULL, &state); |
23de5d9e AS |
275 | if (ACPI_FAILURE(status)) |
276 | return -ENODEV; | |
50a4da89 | 277 | |
23de5d9e AS |
278 | /* input layer checks if event is redundant */ |
279 | input_report_switch(button->input, SW_LID, !state); | |
df316e93 | 280 | input_sync(button->input); |
7e12715e JB |
281 | |
282 | ret = blocking_notifier_call_chain(&acpi_lid_notifier, state, device); | |
283 | if (ret == NOTIFY_DONE) | |
284 | ret = blocking_notifier_call_chain(&acpi_lid_notifier, state, | |
285 | device); | |
13c199c0 ZY |
286 | if (ret == NOTIFY_DONE || ret == NOTIFY_OK) { |
287 | /* | |
288 | * It is also regarded as success if the notifier_chain | |
289 | * returns NOTIFY_OK or NOTIFY_DONE. | |
290 | */ | |
291 | ret = 0; | |
292 | } | |
7e12715e | 293 | return ret; |
23de5d9e | 294 | } |
1da177e4 | 295 | |
373cfc36 | 296 | static void acpi_button_notify(struct acpi_device *device, u32 event) |
1da177e4 | 297 | { |
373cfc36 | 298 | struct acpi_button *button = acpi_driver_data(device); |
c0968f0e | 299 | struct input_dev *input; |
1da177e4 | 300 | |
1da177e4 | 301 | switch (event) { |
373cfc36 BH |
302 | case ACPI_FIXED_HARDWARE_EVENT: |
303 | event = ACPI_BUTTON_NOTIFY_STATUS; | |
304 | /* fall through */ | |
1da177e4 | 305 | case ACPI_BUTTON_NOTIFY_STATUS: |
c0968f0e | 306 | input = button->input; |
c0968f0e | 307 | if (button->type == ACPI_BUTTON_TYPE_LID) { |
106c19e7 | 308 | acpi_lid_send_state(device); |
c0968f0e DT |
309 | } else { |
310 | int keycode = test_bit(KEY_SLEEP, input->keybit) ? | |
311 | KEY_SLEEP : KEY_POWER; | |
312 | ||
313 | input_report_key(input, keycode, 1); | |
314 | input_sync(input); | |
315 | input_report_key(input, keycode, 0); | |
df316e93 | 316 | input_sync(input); |
c0968f0e | 317 | } |
c0968f0e | 318 | |
106c19e7 | 319 | acpi_bus_generate_proc_event(device, event, ++button->pushed); |
1da177e4 LT |
320 | break; |
321 | default: | |
322 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | |
4be44fcd | 323 | "Unsupported event [0x%x]\n", event)); |
1da177e4 LT |
324 | break; |
325 | } | |
1da177e4 LT |
326 | } |
327 | ||
23de5d9e AS |
328 | static int acpi_button_resume(struct acpi_device *device) |
329 | { | |
1bce8113 | 330 | struct acpi_button *button = acpi_driver_data(device); |
50a4da89 | 331 | |
e2fb9754 | 332 | if (button->type == ACPI_BUTTON_TYPE_LID) |
106c19e7 | 333 | return acpi_lid_send_state(device); |
23de5d9e AS |
334 | return 0; |
335 | } | |
336 | ||
c0968f0e DT |
337 | static int acpi_button_add(struct acpi_device *device) |
338 | { | |
c0968f0e DT |
339 | struct acpi_button *button; |
340 | struct input_dev *input; | |
bf04a772 | 341 | char *hid, *name, *class; |
1bce8113 | 342 | int error; |
1da177e4 | 343 | |
c0968f0e | 344 | button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL); |
1da177e4 | 345 | if (!button) |
d550d98d | 346 | return -ENOMEM; |
1da177e4 | 347 | |
db89b4f0 | 348 | device->driver_data = button; |
1da177e4 | 349 | |
c0968f0e DT |
350 | button->input = input = input_allocate_device(); |
351 | if (!input) { | |
352 | error = -ENOMEM; | |
353 | goto err_free_button; | |
354 | } | |
355 | ||
bf04a772 BH |
356 | hid = acpi_device_hid(device); |
357 | name = acpi_device_name(device); | |
358 | class = acpi_device_class(device); | |
359 | ||
d68b597c BH |
360 | if (!strcmp(hid, ACPI_BUTTON_HID_POWER) || |
361 | !strcmp(hid, ACPI_BUTTON_HID_POWERF)) { | |
1da177e4 | 362 | button->type = ACPI_BUTTON_TYPE_POWER; |
bf04a772 BH |
363 | strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWER); |
364 | sprintf(class, "%s/%s", | |
1da177e4 | 365 | ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); |
d68b597c BH |
366 | } else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP) || |
367 | !strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) { | |
1da177e4 | 368 | button->type = ACPI_BUTTON_TYPE_SLEEP; |
bf04a772 BH |
369 | strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP); |
370 | sprintf(class, "%s/%s", | |
1da177e4 | 371 | ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); |
bf04a772 | 372 | } else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) { |
1da177e4 | 373 | button->type = ACPI_BUTTON_TYPE_LID; |
bf04a772 BH |
374 | strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID); |
375 | sprintf(class, "%s/%s", | |
1da177e4 | 376 | ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); |
4be44fcd | 377 | } else { |
bf04a772 | 378 | printk(KERN_ERR PREFIX "Unsupported hid [%s]\n", hid); |
c0968f0e DT |
379 | error = -ENODEV; |
380 | goto err_free_input; | |
1da177e4 LT |
381 | } |
382 | ||
c0968f0e DT |
383 | error = acpi_button_add_fs(device); |
384 | if (error) | |
385 | goto err_free_input; | |
386 | ||
bf04a772 | 387 | snprintf(button->phys, sizeof(button->phys), "%s/button/input0", hid); |
c0968f0e | 388 | |
bf04a772 | 389 | input->name = name; |
c0968f0e DT |
390 | input->phys = button->phys; |
391 | input->id.bustype = BUS_HOST; | |
392 | input->id.product = button->type; | |
3b34e523 | 393 | input->dev.parent = &device->dev; |
b34a8030 | 394 | |
1da177e4 | 395 | switch (button->type) { |
c0968f0e | 396 | case ACPI_BUTTON_TYPE_POWER: |
7b19ada2 | 397 | input->evbit[0] = BIT_MASK(EV_KEY); |
c0968f0e | 398 | set_bit(KEY_POWER, input->keybit); |
1da177e4 | 399 | break; |
c0968f0e DT |
400 | |
401 | case ACPI_BUTTON_TYPE_SLEEP: | |
7b19ada2 | 402 | input->evbit[0] = BIT_MASK(EV_KEY); |
c0968f0e | 403 | set_bit(KEY_SLEEP, input->keybit); |
1da177e4 | 404 | break; |
c0968f0e DT |
405 | |
406 | case ACPI_BUTTON_TYPE_LID: | |
7b19ada2 | 407 | input->evbit[0] = BIT_MASK(EV_SW); |
c0968f0e | 408 | set_bit(SW_LID, input->swbit); |
1da177e4 LT |
409 | break; |
410 | } | |
411 | ||
c0968f0e DT |
412 | error = input_register_device(input); |
413 | if (error) | |
373cfc36 | 414 | goto err_remove_fs; |
7e12715e | 415 | if (button->type == ACPI_BUTTON_TYPE_LID) { |
106c19e7 | 416 | acpi_lid_send_state(device); |
7e12715e JB |
417 | /* |
418 | * This assumes there's only one lid device, or if there are | |
419 | * more we only care about the last one... | |
420 | */ | |
421 | lid_device = device; | |
422 | } | |
1da177e4 LT |
423 | |
424 | if (device->wakeup.flags.valid) { | |
425 | /* Button's GPE is run-wake GPE */ | |
4be44fcd | 426 | acpi_enable_gpe(device->wakeup.gpe_device, |
a44061aa | 427 | device->wakeup.gpe_number); |
f517709d | 428 | device->wakeup.run_wake_count++; |
1da177e4 LT |
429 | device->wakeup.state.enabled = 1; |
430 | } | |
431 | ||
bf04a772 | 432 | printk(KERN_INFO PREFIX "%s [%s]\n", name, acpi_device_bid(device)); |
c0968f0e | 433 | return 0; |
1da177e4 | 434 | |
c0968f0e DT |
435 | err_remove_fs: |
436 | acpi_button_remove_fs(device); | |
437 | err_free_input: | |
438 | input_free_device(input); | |
439 | err_free_button: | |
440 | kfree(button); | |
441 | return error; | |
1da177e4 LT |
442 | } |
443 | ||
4be44fcd | 444 | static int acpi_button_remove(struct acpi_device *device, int type) |
1da177e4 | 445 | { |
1bce8113 | 446 | struct acpi_button *button = acpi_driver_data(device); |
1da177e4 | 447 | |
9630bdd9 RW |
448 | if (device->wakeup.flags.valid) { |
449 | acpi_disable_gpe(device->wakeup.gpe_device, | |
a44061aa | 450 | device->wakeup.gpe_number); |
f517709d | 451 | device->wakeup.run_wake_count--; |
9630bdd9 RW |
452 | device->wakeup.state.enabled = 0; |
453 | } | |
454 | ||
4be44fcd | 455 | acpi_button_remove_fs(device); |
c0968f0e | 456 | input_unregister_device(button->input); |
1da177e4 | 457 | kfree(button); |
d550d98d | 458 | return 0; |
1da177e4 LT |
459 | } |
460 | ||
4be44fcd | 461 | static int __init acpi_button_init(void) |
1da177e4 | 462 | { |
c0968f0e | 463 | int result; |
1da177e4 | 464 | |
b34a8030 AS |
465 | acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); |
466 | if (!acpi_button_dir) | |
d550d98d | 467 | return -ENODEV; |
50a4da89 | 468 | |
1da177e4 LT |
469 | result = acpi_bus_register_driver(&acpi_button_driver); |
470 | if (result < 0) { | |
b34a8030 | 471 | remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); |
d550d98d | 472 | return -ENODEV; |
1da177e4 LT |
473 | } |
474 | ||
d550d98d | 475 | return 0; |
1da177e4 LT |
476 | } |
477 | ||
4be44fcd | 478 | static void __exit acpi_button_exit(void) |
1da177e4 | 479 | { |
1da177e4 LT |
480 | acpi_bus_unregister_driver(&acpi_button_driver); |
481 | ||
4be44fcd | 482 | if (acpi_power_dir) |
b34a8030 AS |
483 | remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir); |
484 | if (acpi_sleep_dir) | |
485 | remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir); | |
486 | if (acpi_lid_dir) | |
487 | remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); | |
488 | remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); | |
1da177e4 LT |
489 | } |
490 | ||
1da177e4 LT |
491 | module_init(acpi_button_init); |
492 | module_exit(acpi_button_exit); |