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