Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * acpi_button.c - ACPI Button Driver ($Revision: 30 $) |
| 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> |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 29 | #include <linux/types.h> |
| 30 | #include <linux/proc_fs.h> |
| 31 | #include <linux/seq_file.h> |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 32 | #include <linux/input.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <acpi/acpi_bus.h> |
| 34 | #include <acpi/acpi_drivers.h> |
| 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #define ACPI_BUTTON_COMPONENT 0x00080000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #define ACPI_BUTTON_CLASS "button" |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 38 | #define ACPI_BUTTON_FILE_INFO "info" |
| 39 | #define ACPI_BUTTON_FILE_STATE "state" |
| 40 | #define ACPI_BUTTON_TYPE_UNKNOWN 0x00 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #define ACPI_BUTTON_NOTIFY_STATUS 0x80 |
| 42 | |
| 43 | #define ACPI_BUTTON_SUBCLASS_POWER "power" |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 44 | #define ACPI_BUTTON_HID_POWER "PNP0C0C" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button (CM)" |
| 46 | #define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button (FF)" |
| 47 | #define ACPI_BUTTON_TYPE_POWER 0x01 |
| 48 | #define ACPI_BUTTON_TYPE_POWERF 0x02 |
| 49 | |
| 50 | #define ACPI_BUTTON_SUBCLASS_SLEEP "sleep" |
| 51 | #define ACPI_BUTTON_HID_SLEEP "PNP0C0E" |
| 52 | #define ACPI_BUTTON_DEVICE_NAME_SLEEP "Sleep Button (CM)" |
| 53 | #define ACPI_BUTTON_DEVICE_NAME_SLEEPF "Sleep Button (FF)" |
| 54 | #define ACPI_BUTTON_TYPE_SLEEP 0x03 |
| 55 | #define ACPI_BUTTON_TYPE_SLEEPF 0x04 |
| 56 | |
| 57 | #define ACPI_BUTTON_SUBCLASS_LID "lid" |
| 58 | #define ACPI_BUTTON_HID_LID "PNP0C0D" |
| 59 | #define ACPI_BUTTON_DEVICE_NAME_LID "Lid Switch" |
| 60 | #define ACPI_BUTTON_TYPE_LID 0x05 |
| 61 | |
| 62 | #define _COMPONENT ACPI_BUTTON_COMPONENT |
Len Brown | f52fd66 | 2007-02-12 22:42:12 -0500 | [diff] [blame] | 63 | ACPI_MODULE_NAME("button"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 65 | MODULE_AUTHOR("Paul Diefenbaugh"); |
Len Brown | 7cda93e | 2007-02-12 23:50:02 -0500 | [diff] [blame] | 66 | MODULE_DESCRIPTION("ACPI Button Driver"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | MODULE_LICENSE("GPL"); |
| 68 | |
Thomas Renninger | 1ba90e3 | 2007-07-23 14:44:41 +0200 | [diff] [blame] | 69 | static const struct acpi_device_id button_device_ids[] = { |
| 70 | {ACPI_BUTTON_HID_LID, 0}, |
| 71 | {ACPI_BUTTON_HID_SLEEP, 0}, |
| 72 | {ACPI_BUTTON_HID_SLEEPF, 0}, |
| 73 | {ACPI_BUTTON_HID_POWER, 0}, |
| 74 | {ACPI_BUTTON_HID_POWERF, 0}, |
| 75 | {"", 0}, |
| 76 | }; |
| 77 | MODULE_DEVICE_TABLE(acpi, button_device_ids); |
| 78 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 79 | static int acpi_button_add(struct acpi_device *device); |
| 80 | static int acpi_button_remove(struct acpi_device *device, int type); |
Alexey Starikovskiy | 23de5d9 | 2007-10-22 14:18:18 +0400 | [diff] [blame] | 81 | static int acpi_button_resume(struct acpi_device *device); |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 82 | static int acpi_button_info_open_fs(struct inode *inode, struct file *file); |
| 83 | static int acpi_button_state_open_fs(struct inode *inode, struct file *file); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
| 85 | static struct acpi_driver acpi_button_driver = { |
Len Brown | c2b6705 | 2007-02-12 23:33:40 -0500 | [diff] [blame] | 86 | .name = "button", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 87 | .class = ACPI_BUTTON_CLASS, |
Thomas Renninger | 1ba90e3 | 2007-07-23 14:44:41 +0200 | [diff] [blame] | 88 | .ids = button_device_ids, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 89 | .ops = { |
| 90 | .add = acpi_button_add, |
Alexey Starikovskiy | 23de5d9 | 2007-10-22 14:18:18 +0400 | [diff] [blame] | 91 | .resume = acpi_button_resume, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 92 | .remove = acpi_button_remove, |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 93 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | struct acpi_button { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 97 | struct acpi_device *device; /* Fixed button kludge */ |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 98 | unsigned int type; |
| 99 | struct input_dev *input; |
| 100 | char phys[32]; /* for input device */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 101 | unsigned long pushed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
Arjan van de Ven | d750803 | 2006-07-04 13:06:00 -0400 | [diff] [blame] | 104 | static const struct file_operations acpi_button_info_fops = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 105 | .open = acpi_button_info_open_fs, |
| 106 | .read = seq_read, |
| 107 | .llseek = seq_lseek, |
| 108 | .release = single_release, |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 109 | }; |
| 110 | |
Arjan van de Ven | d750803 | 2006-07-04 13:06:00 -0400 | [diff] [blame] | 111 | static const struct file_operations acpi_button_state_fops = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 112 | .open = acpi_button_state_open_fs, |
| 113 | .read = seq_read, |
| 114 | .llseek = seq_lseek, |
| 115 | .release = single_release, |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 116 | }; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 117 | |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 118 | /* -------------------------------------------------------------------------- |
| 119 | FS Interface (/proc) |
| 120 | -------------------------------------------------------------------------- */ |
| 121 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 122 | static struct proc_dir_entry *acpi_button_dir; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 123 | |
| 124 | static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) |
| 125 | { |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 126 | struct acpi_button *button = seq->private; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 127 | |
| 128 | if (!button || !button->device) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 129 | return 0; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 130 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 131 | seq_printf(seq, "type: %s\n", |
| 132 | acpi_device_name(button->device)); |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 133 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 134 | return 0; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 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 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 141 | |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 142 | static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) |
| 143 | { |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 144 | struct acpi_button *button = seq->private; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 145 | acpi_status status; |
| 146 | unsigned long state; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 147 | |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 148 | if (!button || !button->device) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 149 | return 0; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 150 | |
Patrick Mochel | 27b1d3e | 2006-05-19 16:54:42 -0400 | [diff] [blame] | 151 | status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, &state); |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 152 | seq_printf(seq, "state: %s\n", |
| 153 | ACPI_FAILURE(status) ? "unsupported" : |
| 154 | (state ? "open" : "closed")); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 155 | return 0; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | static int acpi_button_state_open_fs(struct inode *inode, struct file *file) |
| 159 | { |
| 160 | return single_open(file, acpi_button_state_seq_show, PDE(inode)->data); |
| 161 | } |
| 162 | |
| 163 | static struct proc_dir_entry *acpi_power_dir; |
| 164 | static struct proc_dir_entry *acpi_sleep_dir; |
| 165 | static struct proc_dir_entry *acpi_lid_dir; |
| 166 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 167 | static int acpi_button_add_fs(struct acpi_device *device) |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 168 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 169 | struct proc_dir_entry *entry = NULL; |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 170 | struct acpi_button *button; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 171 | |
| 172 | if (!device || !acpi_driver_data(device)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 173 | return -EINVAL; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 174 | |
| 175 | button = acpi_driver_data(device); |
| 176 | |
| 177 | switch (button->type) { |
| 178 | case ACPI_BUTTON_TYPE_POWER: |
| 179 | case ACPI_BUTTON_TYPE_POWERF: |
| 180 | if (!acpi_power_dir) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 181 | acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, |
| 182 | acpi_button_dir); |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 183 | entry = acpi_power_dir; |
| 184 | break; |
| 185 | case ACPI_BUTTON_TYPE_SLEEP: |
| 186 | case ACPI_BUTTON_TYPE_SLEEPF: |
| 187 | if (!acpi_sleep_dir) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 188 | acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP, |
| 189 | acpi_button_dir); |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 190 | entry = acpi_sleep_dir; |
| 191 | break; |
| 192 | case ACPI_BUTTON_TYPE_LID: |
| 193 | if (!acpi_lid_dir) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 194 | acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, |
| 195 | acpi_button_dir); |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 196 | entry = acpi_lid_dir; |
| 197 | break; |
| 198 | } |
| 199 | |
| 200 | if (!entry) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 201 | return -ENODEV; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 202 | entry->owner = THIS_MODULE; |
| 203 | |
| 204 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); |
| 205 | if (!acpi_device_dir(device)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 206 | return -ENODEV; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 207 | acpi_device_dir(device)->owner = THIS_MODULE; |
| 208 | |
| 209 | /* 'info' [R] */ |
| 210 | entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 211 | S_IRUGO, acpi_device_dir(device)); |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 212 | if (!entry) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 213 | return -ENODEV; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 214 | else { |
| 215 | entry->proc_fops = &acpi_button_info_fops; |
| 216 | entry->data = acpi_driver_data(device); |
| 217 | entry->owner = THIS_MODULE; |
| 218 | } |
| 219 | |
| 220 | /* show lid state [R] */ |
| 221 | if (button->type == ACPI_BUTTON_TYPE_LID) { |
| 222 | entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 223 | S_IRUGO, acpi_device_dir(device)); |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 224 | if (!entry) |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 225 | return -ENODEV; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 226 | else { |
| 227 | entry->proc_fops = &acpi_button_state_fops; |
| 228 | entry->data = acpi_driver_data(device); |
| 229 | entry->owner = THIS_MODULE; |
| 230 | } |
| 231 | } |
| 232 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 233 | return 0; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 234 | } |
| 235 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 236 | static int acpi_button_remove_fs(struct acpi_device *device) |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 237 | { |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 238 | struct acpi_button *button = acpi_driver_data(device); |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 239 | |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 240 | if (acpi_device_dir(device)) { |
| 241 | if (button->type == ACPI_BUTTON_TYPE_LID) |
| 242 | remove_proc_entry(ACPI_BUTTON_FILE_STATE, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 243 | acpi_device_dir(device)); |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 244 | remove_proc_entry(ACPI_BUTTON_FILE_INFO, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 245 | acpi_device_dir(device)); |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 246 | |
| 247 | remove_proc_entry(acpi_device_bid(device), |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 248 | acpi_device_dir(device)->parent); |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 249 | acpi_device_dir(device) = NULL; |
| 250 | } |
| 251 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 252 | return 0; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 253 | } |
| 254 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | /* -------------------------------------------------------------------------- |
| 256 | Driver Interface |
| 257 | -------------------------------------------------------------------------- */ |
Alexey Starikovskiy | 23de5d9 | 2007-10-22 14:18:18 +0400 | [diff] [blame] | 258 | static int acpi_lid_send_state(struct acpi_button *button) |
| 259 | { |
| 260 | unsigned long state; |
| 261 | acpi_status status; |
| 262 | |
| 263 | status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, |
| 264 | &state); |
| 265 | if (ACPI_FAILURE(status)) |
| 266 | return -ENODEV; |
| 267 | /* input layer checks if event is redundant */ |
| 268 | input_report_switch(button->input, SW_LID, !state); |
| 269 | return 0; |
| 270 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 272 | static void acpi_button_notify(acpi_handle handle, u32 event, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | { |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 274 | struct acpi_button *button = data; |
| 275 | struct input_dev *input; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
| 277 | if (!button || !button->device) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 278 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
| 280 | switch (event) { |
| 281 | case ACPI_BUTTON_NOTIFY_STATUS: |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 282 | input = button->input; |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 283 | if (button->type == ACPI_BUTTON_TYPE_LID) { |
Alexey Starikovskiy | 23de5d9 | 2007-10-22 14:18:18 +0400 | [diff] [blame] | 284 | acpi_lid_send_state(button); |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 285 | } else { |
| 286 | int keycode = test_bit(KEY_SLEEP, input->keybit) ? |
| 287 | KEY_SLEEP : KEY_POWER; |
| 288 | |
| 289 | input_report_key(input, keycode, 1); |
| 290 | input_sync(input); |
| 291 | input_report_key(input, keycode, 0); |
| 292 | } |
| 293 | input_sync(input); |
| 294 | |
Len Brown | 14e04fb | 2007-08-23 15:20:26 -0400 | [diff] [blame] | 295 | acpi_bus_generate_proc_event(button->device, event, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 296 | ++button->pushed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | break; |
| 298 | default: |
| 299 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 300 | "Unsupported event [0x%x]\n", event)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | break; |
| 302 | } |
| 303 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 304 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | } |
| 306 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 307 | static acpi_status acpi_button_notify_fixed(void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | { |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 309 | struct acpi_button *button = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 311 | if (!button) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 312 | return AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
Patrick Mochel | 27b1d3e | 2006-05-19 16:54:42 -0400 | [diff] [blame] | 314 | acpi_button_notify(button->device->handle, ACPI_BUTTON_NOTIFY_STATUS, button); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 316 | return AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | } |
| 318 | |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 319 | static int acpi_button_install_notify_handlers(struct acpi_button *button) |
| 320 | { |
| 321 | acpi_status status; |
| 322 | |
| 323 | switch (button->type) { |
| 324 | case ACPI_BUTTON_TYPE_POWERF: |
| 325 | status = |
| 326 | acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, |
| 327 | acpi_button_notify_fixed, |
| 328 | button); |
| 329 | break; |
| 330 | case ACPI_BUTTON_TYPE_SLEEPF: |
| 331 | status = |
| 332 | acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, |
| 333 | acpi_button_notify_fixed, |
| 334 | button); |
| 335 | break; |
| 336 | default: |
| 337 | status = acpi_install_notify_handler(button->device->handle, |
| 338 | ACPI_DEVICE_NOTIFY, |
| 339 | acpi_button_notify, |
| 340 | button); |
| 341 | break; |
| 342 | } |
| 343 | |
| 344 | return ACPI_FAILURE(status) ? -ENODEV : 0; |
| 345 | } |
| 346 | |
Alexey Starikovskiy | 23de5d9 | 2007-10-22 14:18:18 +0400 | [diff] [blame] | 347 | static int acpi_button_resume(struct acpi_device *device) |
| 348 | { |
| 349 | struct acpi_button *button; |
| 350 | if (!device) |
| 351 | return -EINVAL; |
| 352 | button = acpi_driver_data(device); |
| 353 | if (button && button->type == ACPI_BUTTON_TYPE_LID) |
| 354 | return acpi_lid_send_state(button); |
| 355 | return 0; |
| 356 | } |
| 357 | |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 358 | static void acpi_button_remove_notify_handlers(struct acpi_button *button) |
| 359 | { |
| 360 | switch (button->type) { |
| 361 | case ACPI_BUTTON_TYPE_POWERF: |
| 362 | acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, |
| 363 | acpi_button_notify_fixed); |
| 364 | break; |
| 365 | case ACPI_BUTTON_TYPE_SLEEPF: |
| 366 | acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, |
| 367 | acpi_button_notify_fixed); |
| 368 | break; |
| 369 | default: |
| 370 | acpi_remove_notify_handler(button->device->handle, |
| 371 | ACPI_DEVICE_NOTIFY, |
| 372 | acpi_button_notify); |
| 373 | break; |
| 374 | } |
| 375 | } |
| 376 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 377 | static int acpi_button_add(struct acpi_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | { |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 379 | int error; |
| 380 | struct acpi_button *button; |
| 381 | struct input_dev *input; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | |
| 383 | if (!device) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 384 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 386 | button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | if (!button) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 388 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
| 390 | button->device = device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | acpi_driver_data(device) = button; |
| 392 | |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 393 | button->input = input = input_allocate_device(); |
| 394 | if (!input) { |
| 395 | error = -ENOMEM; |
| 396 | goto err_free_button; |
| 397 | } |
| 398 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | /* |
| 400 | * Determine the button type (via hid), as fixed-feature buttons |
| 401 | * need to be handled a bit differently than generic-space. |
| 402 | */ |
| 403 | if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) { |
| 404 | button->type = ACPI_BUTTON_TYPE_POWER; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 405 | strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_POWER); |
| 406 | sprintf(acpi_device_class(device), "%s/%s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 408 | } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | button->type = ACPI_BUTTON_TYPE_POWERF; |
| 410 | strcpy(acpi_device_name(device), |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 411 | ACPI_BUTTON_DEVICE_NAME_POWERF); |
| 412 | sprintf(acpi_device_class(device), "%s/%s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 414 | } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | button->type = ACPI_BUTTON_TYPE_SLEEP; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 416 | strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_SLEEP); |
| 417 | sprintf(acpi_device_class(device), "%s/%s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 419 | } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | button->type = ACPI_BUTTON_TYPE_SLEEPF; |
| 421 | strcpy(acpi_device_name(device), |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 422 | ACPI_BUTTON_DEVICE_NAME_SLEEPF); |
| 423 | sprintf(acpi_device_class(device), "%s/%s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 425 | } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | button->type = ACPI_BUTTON_TYPE_LID; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 427 | strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_LID); |
| 428 | sprintf(acpi_device_class(device), "%s/%s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 430 | } else { |
Len Brown | 6468463 | 2006-06-26 23:41:38 -0400 | [diff] [blame] | 431 | printk(KERN_ERR PREFIX "Unsupported hid [%s]\n", |
| 432 | acpi_device_hid(device)); |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 433 | error = -ENODEV; |
| 434 | goto err_free_input; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | } |
| 436 | |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 437 | error = acpi_button_add_fs(device); |
| 438 | if (error) |
| 439 | goto err_free_input; |
| 440 | |
| 441 | error = acpi_button_install_notify_handlers(button); |
| 442 | if (error) |
| 443 | goto err_remove_fs; |
| 444 | |
| 445 | snprintf(button->phys, sizeof(button->phys), |
| 446 | "%s/button/input0", acpi_device_hid(device)); |
| 447 | |
| 448 | input->name = acpi_device_name(device); |
| 449 | input->phys = button->phys; |
| 450 | input->id.bustype = BUS_HOST; |
| 451 | input->id.product = button->type; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 452 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | switch (button->type) { |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 454 | case ACPI_BUTTON_TYPE_POWER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | case ACPI_BUTTON_TYPE_POWERF: |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 456 | input->evbit[0] = BIT_MASK(EV_KEY); |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 457 | set_bit(KEY_POWER, input->keybit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | break; |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 459 | |
| 460 | case ACPI_BUTTON_TYPE_SLEEP: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | case ACPI_BUTTON_TYPE_SLEEPF: |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 462 | input->evbit[0] = BIT_MASK(EV_KEY); |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 463 | set_bit(KEY_SLEEP, input->keybit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | break; |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 465 | |
| 466 | case ACPI_BUTTON_TYPE_LID: |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 467 | input->evbit[0] = BIT_MASK(EV_SW); |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 468 | set_bit(SW_LID, input->swbit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | break; |
| 470 | } |
| 471 | |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 472 | error = input_register_device(input); |
| 473 | if (error) |
| 474 | goto err_remove_handlers; |
Alexey Starikovskiy | 23de5d9 | 2007-10-22 14:18:18 +0400 | [diff] [blame] | 475 | if (button->type == ACPI_BUTTON_TYPE_LID) |
| 476 | acpi_lid_send_state(button); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
| 478 | if (device->wakeup.flags.valid) { |
| 479 | /* Button's GPE is run-wake GPE */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 480 | acpi_set_gpe_type(device->wakeup.gpe_device, |
| 481 | device->wakeup.gpe_number, |
| 482 | ACPI_GPE_TYPE_WAKE_RUN); |
| 483 | acpi_enable_gpe(device->wakeup.gpe_device, |
| 484 | device->wakeup.gpe_number, ACPI_NOT_ISR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | device->wakeup.state.enabled = 1; |
| 486 | } |
| 487 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 488 | printk(KERN_INFO PREFIX "%s [%s]\n", |
| 489 | acpi_device_name(device), acpi_device_bid(device)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 491 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 493 | err_remove_handlers: |
| 494 | acpi_button_remove_notify_handlers(button); |
| 495 | err_remove_fs: |
| 496 | acpi_button_remove_fs(device); |
| 497 | err_free_input: |
| 498 | input_free_device(input); |
| 499 | err_free_button: |
| 500 | kfree(button); |
| 501 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | } |
| 503 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 504 | static int acpi_button_remove(struct acpi_device *device, int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | { |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 506 | struct acpi_button *button; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | |
| 508 | if (!device || !acpi_driver_data(device)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 509 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | |
| 511 | button = acpi_driver_data(device); |
| 512 | |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 513 | acpi_button_remove_notify_handlers(button); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 514 | acpi_button_remove_fs(device); |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 515 | input_unregister_device(button->input); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | kfree(button); |
| 517 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 518 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | } |
| 520 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 521 | static int __init acpi_button_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | { |
Dmitry Torokhov | c0968f0 | 2006-11-09 00:40:13 -0500 | [diff] [blame] | 523 | int result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 525 | acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); |
| 526 | if (!acpi_button_dir) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 527 | return -ENODEV; |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 528 | acpi_button_dir->owner = THIS_MODULE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | result = acpi_bus_register_driver(&acpi_button_driver); |
| 530 | if (result < 0) { |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 531 | remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 532 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | } |
| 534 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 535 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | } |
| 537 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 538 | static void __exit acpi_button_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | acpi_bus_unregister_driver(&acpi_button_driver); |
| 541 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 542 | if (acpi_power_dir) |
Alexey Starikovskiy | b34a803 | 2005-08-03 17:55:21 -0400 | [diff] [blame] | 543 | remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir); |
| 544 | if (acpi_sleep_dir) |
| 545 | remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir); |
| 546 | if (acpi_lid_dir) |
| 547 | remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); |
| 548 | remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | } |
| 550 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | module_init(acpi_button_init); |
| 552 | module_exit(acpi_button_exit); |