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