aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/button.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/button.c')
-rw-r--r--drivers/acpi/button.c274
1 files changed, 123 insertions, 151 deletions
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 8162fd0c21a7..4b6d9f0096a1 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -32,7 +32,6 @@
32#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
33#include <acpi/acpi_drivers.h> 33#include <acpi/acpi_drivers.h>
34 34
35
36#define ACPI_BUTTON_COMPONENT 0x00080000 35#define ACPI_BUTTON_COMPONENT 0x00080000
37#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver" 36#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver"
38#define ACPI_BUTTON_CLASS "button" 37#define ACPI_BUTTON_CLASS "button"
@@ -42,7 +41,7 @@
42#define ACPI_BUTTON_NOTIFY_STATUS 0x80 41#define ACPI_BUTTON_NOTIFY_STATUS 0x80
43 42
44#define ACPI_BUTTON_SUBCLASS_POWER "power" 43#define ACPI_BUTTON_SUBCLASS_POWER "power"
45#define ACPI_BUTTON_HID_POWER "PNP0C0C" 44#define ACPI_BUTTON_HID_POWER "PNP0C0C"
46#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button (CM)" 45#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button (CM)"
47#define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button (FF)" 46#define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button (FF)"
48#define ACPI_BUTTON_TYPE_POWER 0x01 47#define ACPI_BUTTON_TYPE_POWER 0x01
@@ -61,65 +60,65 @@
61#define ACPI_BUTTON_TYPE_LID 0x05 60#define ACPI_BUTTON_TYPE_LID 0x05
62 61
63#define _COMPONENT ACPI_BUTTON_COMPONENT 62#define _COMPONENT ACPI_BUTTON_COMPONENT
64ACPI_MODULE_NAME ("acpi_button") 63ACPI_MODULE_NAME("acpi_button")
65 64
66MODULE_AUTHOR("Paul Diefenbaugh"); 65 MODULE_AUTHOR("Paul Diefenbaugh");
67MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME); 66MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME);
68MODULE_LICENSE("GPL"); 67MODULE_LICENSE("GPL");
69 68
70 69static int acpi_button_add(struct acpi_device *device);
71static int acpi_button_add (struct acpi_device *device); 70static int acpi_button_remove(struct acpi_device *device, int type);
72static int acpi_button_remove (struct acpi_device *device, int type);
73static int acpi_button_info_open_fs(struct inode *inode, struct file *file); 71static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
74static int acpi_button_state_open_fs(struct inode *inode, struct file *file); 72static int acpi_button_state_open_fs(struct inode *inode, struct file *file);
75 73
76static struct acpi_driver acpi_button_driver = { 74static struct acpi_driver acpi_button_driver = {
77 .name = ACPI_BUTTON_DRIVER_NAME, 75 .name = ACPI_BUTTON_DRIVER_NAME,
78 .class = ACPI_BUTTON_CLASS, 76 .class = ACPI_BUTTON_CLASS,
79 .ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E", 77 .ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E",
80 .ops = { 78 .ops = {
81 .add = acpi_button_add, 79 .add = acpi_button_add,
82 .remove = acpi_button_remove, 80 .remove = acpi_button_remove,
83 }, 81 },
84}; 82};
85 83
86struct acpi_button { 84struct acpi_button {
87 acpi_handle handle; 85 acpi_handle handle;
88 struct acpi_device *device; /* Fixed button kludge */ 86 struct acpi_device *device; /* Fixed button kludge */
89 u8 type; 87 u8 type;
90 unsigned long pushed; 88 unsigned long pushed;
91}; 89};
92 90
93static struct file_operations acpi_button_info_fops = { 91static struct file_operations acpi_button_info_fops = {
94 .open = acpi_button_info_open_fs, 92 .open = acpi_button_info_open_fs,
95 .read = seq_read, 93 .read = seq_read,
96 .llseek = seq_lseek, 94 .llseek = seq_lseek,
97 .release = single_release, 95 .release = single_release,
98}; 96};
99 97
100static struct file_operations acpi_button_state_fops = { 98static struct file_operations acpi_button_state_fops = {
101 .open = acpi_button_state_open_fs, 99 .open = acpi_button_state_open_fs,
102 .read = seq_read, 100 .read = seq_read,
103 .llseek = seq_lseek, 101 .llseek = seq_lseek,
104 .release = single_release, 102 .release = single_release,
105}; 103};
104
106/* -------------------------------------------------------------------------- 105/* --------------------------------------------------------------------------
107 FS Interface (/proc) 106 FS Interface (/proc)
108 -------------------------------------------------------------------------- */ 107 -------------------------------------------------------------------------- */
109 108
110static struct proc_dir_entry *acpi_button_dir; 109static struct proc_dir_entry *acpi_button_dir;
111 110
112static int acpi_button_info_seq_show(struct seq_file *seq, void *offset) 111static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
113{ 112{
114 struct acpi_button *button = (struct acpi_button *) seq->private; 113 struct acpi_button *button = (struct acpi_button *)seq->private;
115 114
116 ACPI_FUNCTION_TRACE("acpi_button_info_seq_show"); 115 ACPI_FUNCTION_TRACE("acpi_button_info_seq_show");
117 116
118 if (!button || !button->device) 117 if (!button || !button->device)
119 return_VALUE(0); 118 return_VALUE(0);
120 119
121 seq_printf(seq, "type: %s\n", 120 seq_printf(seq, "type: %s\n",
122 acpi_device_name(button->device)); 121 acpi_device_name(button->device));
123 122
124 return_VALUE(0); 123 return_VALUE(0);
125} 124}
@@ -128,24 +127,24 @@ static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
128{ 127{
129 return single_open(file, acpi_button_info_seq_show, PDE(inode)->data); 128 return single_open(file, acpi_button_info_seq_show, PDE(inode)->data);
130} 129}
131 130
132static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) 131static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
133{ 132{
134 struct acpi_button *button = (struct acpi_button *) seq->private; 133 struct acpi_button *button = (struct acpi_button *)seq->private;
135 acpi_status status; 134 acpi_status status;
136 unsigned long state; 135 unsigned long state;
137 136
138 ACPI_FUNCTION_TRACE("acpi_button_state_seq_show"); 137 ACPI_FUNCTION_TRACE("acpi_button_state_seq_show");
139 138
140 if (!button || !button->device) 139 if (!button || !button->device)
141 return_VALUE(0); 140 return_VALUE(0);
142 141
143 status = acpi_evaluate_integer(button->handle,"_LID",NULL,&state); 142 status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state);
144 if (ACPI_FAILURE(status)) { 143 if (ACPI_FAILURE(status)) {
145 seq_printf(seq, "state: unsupported\n"); 144 seq_printf(seq, "state: unsupported\n");
146 } 145 } else {
147 else{ 146 seq_printf(seq, "state: %s\n",
148 seq_printf(seq, "state: %s\n", (state ? "open" : "closed")); 147 (state ? "open" : "closed"));
149 } 148 }
150 149
151 return_VALUE(0); 150 return_VALUE(0);
@@ -160,12 +159,10 @@ static struct proc_dir_entry *acpi_power_dir;
160static struct proc_dir_entry *acpi_sleep_dir; 159static struct proc_dir_entry *acpi_sleep_dir;
161static struct proc_dir_entry *acpi_lid_dir; 160static struct proc_dir_entry *acpi_lid_dir;
162 161
163static int 162static int acpi_button_add_fs(struct acpi_device *device)
164acpi_button_add_fs (
165 struct acpi_device *device)
166{ 163{
167 struct proc_dir_entry *entry = NULL; 164 struct proc_dir_entry *entry = NULL;
168 struct acpi_button *button = NULL; 165 struct acpi_button *button = NULL;
169 166
170 ACPI_FUNCTION_TRACE("acpi_button_add_fs"); 167 ACPI_FUNCTION_TRACE("acpi_button_add_fs");
171 168
@@ -178,21 +175,21 @@ acpi_button_add_fs (
178 case ACPI_BUTTON_TYPE_POWER: 175 case ACPI_BUTTON_TYPE_POWER:
179 case ACPI_BUTTON_TYPE_POWERF: 176 case ACPI_BUTTON_TYPE_POWERF:
180 if (!acpi_power_dir) 177 if (!acpi_power_dir)
181 acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, 178 acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER,
182 acpi_button_dir); 179 acpi_button_dir);
183 entry = acpi_power_dir; 180 entry = acpi_power_dir;
184 break; 181 break;
185 case ACPI_BUTTON_TYPE_SLEEP: 182 case ACPI_BUTTON_TYPE_SLEEP:
186 case ACPI_BUTTON_TYPE_SLEEPF: 183 case ACPI_BUTTON_TYPE_SLEEPF:
187 if (!acpi_sleep_dir) 184 if (!acpi_sleep_dir)
188 acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP, 185 acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP,
189 acpi_button_dir); 186 acpi_button_dir);
190 entry = acpi_sleep_dir; 187 entry = acpi_sleep_dir;
191 break; 188 break;
192 case ACPI_BUTTON_TYPE_LID: 189 case ACPI_BUTTON_TYPE_LID:
193 if (!acpi_lid_dir) 190 if (!acpi_lid_dir)
194 acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, 191 acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID,
195 acpi_button_dir); 192 acpi_button_dir);
196 entry = acpi_lid_dir; 193 entry = acpi_lid_dir;
197 break; 194 break;
198 } 195 }
@@ -208,11 +205,11 @@ acpi_button_add_fs (
208 205
209 /* 'info' [R] */ 206 /* 'info' [R] */
210 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, 207 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
211 S_IRUGO, acpi_device_dir(device)); 208 S_IRUGO, acpi_device_dir(device));
212 if (!entry) 209 if (!entry)
213 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 210 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
214 "Unable to create '%s' fs entry\n", 211 "Unable to create '%s' fs entry\n",
215 ACPI_BUTTON_FILE_INFO)); 212 ACPI_BUTTON_FILE_INFO));
216 else { 213 else {
217 entry->proc_fops = &acpi_button_info_fops; 214 entry->proc_fops = &acpi_button_info_fops;
218 entry->data = acpi_driver_data(device); 215 entry->data = acpi_driver_data(device);
@@ -222,11 +219,11 @@ acpi_button_add_fs (
222 /* show lid state [R] */ 219 /* show lid state [R] */
223 if (button->type == ACPI_BUTTON_TYPE_LID) { 220 if (button->type == ACPI_BUTTON_TYPE_LID) {
224 entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, 221 entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
225 S_IRUGO, acpi_device_dir(device)); 222 S_IRUGO, acpi_device_dir(device));
226 if (!entry) 223 if (!entry)
227 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 224 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
228 "Unable to create '%s' fs entry\n", 225 "Unable to create '%s' fs entry\n",
229 ACPI_BUTTON_FILE_INFO)); 226 ACPI_BUTTON_FILE_INFO));
230 else { 227 else {
231 entry->proc_fops = &acpi_button_state_fops; 228 entry->proc_fops = &acpi_button_state_fops;
232 entry->data = acpi_driver_data(device); 229 entry->data = acpi_driver_data(device);
@@ -237,12 +234,9 @@ acpi_button_add_fs (
237 return_VALUE(0); 234 return_VALUE(0);
238} 235}
239 236
240 237static int acpi_button_remove_fs(struct acpi_device *device)
241static int
242acpi_button_remove_fs (
243 struct acpi_device *device)
244{ 238{
245 struct acpi_button *button = NULL; 239 struct acpi_button *button = NULL;
246 240
247 ACPI_FUNCTION_TRACE("acpi_button_remove_fs"); 241 ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
248 242
@@ -250,30 +244,25 @@ acpi_button_remove_fs (
250 if (acpi_device_dir(device)) { 244 if (acpi_device_dir(device)) {
251 if (button->type == ACPI_BUTTON_TYPE_LID) 245 if (button->type == ACPI_BUTTON_TYPE_LID)
252 remove_proc_entry(ACPI_BUTTON_FILE_STATE, 246 remove_proc_entry(ACPI_BUTTON_FILE_STATE,
253 acpi_device_dir(device)); 247 acpi_device_dir(device));
254 remove_proc_entry(ACPI_BUTTON_FILE_INFO, 248 remove_proc_entry(ACPI_BUTTON_FILE_INFO,
255 acpi_device_dir(device)); 249 acpi_device_dir(device));
256 250
257 remove_proc_entry(acpi_device_bid(device), 251 remove_proc_entry(acpi_device_bid(device),
258 acpi_device_dir(device)->parent); 252 acpi_device_dir(device)->parent);
259 acpi_device_dir(device) = NULL; 253 acpi_device_dir(device) = NULL;
260 } 254 }
261 255
262 return_VALUE(0); 256 return_VALUE(0);
263} 257}
264 258
265
266/* -------------------------------------------------------------------------- 259/* --------------------------------------------------------------------------
267 Driver Interface 260 Driver Interface
268 -------------------------------------------------------------------------- */ 261 -------------------------------------------------------------------------- */
269 262
270static void 263static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
271acpi_button_notify (
272 acpi_handle handle,
273 u32 event,
274 void *data)
275{ 264{
276 struct acpi_button *button = (struct acpi_button *) data; 265 struct acpi_button *button = (struct acpi_button *)data;
277 266
278 ACPI_FUNCTION_TRACE("acpi_button_notify"); 267 ACPI_FUNCTION_TRACE("acpi_button_notify");
279 268
@@ -282,24 +271,22 @@ acpi_button_notify (
282 271
283 switch (event) { 272 switch (event) {
284 case ACPI_BUTTON_NOTIFY_STATUS: 273 case ACPI_BUTTON_NOTIFY_STATUS:
285 acpi_bus_generate_event(button->device, event, ++button->pushed); 274 acpi_bus_generate_event(button->device, event,
275 ++button->pushed);
286 break; 276 break;
287 default: 277 default:
288 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 278 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
289 "Unsupported event [0x%x]\n", event)); 279 "Unsupported event [0x%x]\n", event));
290 break; 280 break;
291 } 281 }
292 282
293 return_VOID; 283 return_VOID;
294} 284}
295 285
296 286static acpi_status acpi_button_notify_fixed(void *data)
297static acpi_status
298acpi_button_notify_fixed (
299 void *data)
300{ 287{
301 struct acpi_button *button = (struct acpi_button *) data; 288 struct acpi_button *button = (struct acpi_button *)data;
302 289
303 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); 290 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
304 291
305 if (!button) 292 if (!button)
@@ -310,14 +297,11 @@ acpi_button_notify_fixed (
310 return_ACPI_STATUS(AE_OK); 297 return_ACPI_STATUS(AE_OK);
311} 298}
312 299
313 300static int acpi_button_add(struct acpi_device *device)
314static int
315acpi_button_add (
316 struct acpi_device *device)
317{ 301{
318 int result = 0; 302 int result = 0;
319 acpi_status status = AE_OK; 303 acpi_status status = AE_OK;
320 struct acpi_button *button = NULL; 304 struct acpi_button *button = NULL;
321 305
322 ACPI_FUNCTION_TRACE("acpi_button_add"); 306 ACPI_FUNCTION_TRACE("acpi_button_add");
323 307
@@ -339,42 +323,34 @@ acpi_button_add (
339 */ 323 */
340 if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) { 324 if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) {
341 button->type = ACPI_BUTTON_TYPE_POWER; 325 button->type = ACPI_BUTTON_TYPE_POWER;
342 strcpy(acpi_device_name(device), 326 strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_POWER);
343 ACPI_BUTTON_DEVICE_NAME_POWER); 327 sprintf(acpi_device_class(device), "%s/%s",
344 sprintf(acpi_device_class(device), "%s/%s",
345 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); 328 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
346 } 329 } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) {
347 else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) {
348 button->type = ACPI_BUTTON_TYPE_POWERF; 330 button->type = ACPI_BUTTON_TYPE_POWERF;
349 strcpy(acpi_device_name(device), 331 strcpy(acpi_device_name(device),
350 ACPI_BUTTON_DEVICE_NAME_POWERF); 332 ACPI_BUTTON_DEVICE_NAME_POWERF);
351 sprintf(acpi_device_class(device), "%s/%s", 333 sprintf(acpi_device_class(device), "%s/%s",
352 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); 334 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
353 } 335 } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) {
354 else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) {
355 button->type = ACPI_BUTTON_TYPE_SLEEP; 336 button->type = ACPI_BUTTON_TYPE_SLEEP;
356 strcpy(acpi_device_name(device), 337 strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_SLEEP);
357 ACPI_BUTTON_DEVICE_NAME_SLEEP); 338 sprintf(acpi_device_class(device), "%s/%s",
358 sprintf(acpi_device_class(device), "%s/%s",
359 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); 339 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
360 } 340 } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) {
361 else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) {
362 button->type = ACPI_BUTTON_TYPE_SLEEPF; 341 button->type = ACPI_BUTTON_TYPE_SLEEPF;
363 strcpy(acpi_device_name(device), 342 strcpy(acpi_device_name(device),
364 ACPI_BUTTON_DEVICE_NAME_SLEEPF); 343 ACPI_BUTTON_DEVICE_NAME_SLEEPF);
365 sprintf(acpi_device_class(device), "%s/%s", 344 sprintf(acpi_device_class(device), "%s/%s",
366 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); 345 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
367 } 346 } else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) {
368 else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) {
369 button->type = ACPI_BUTTON_TYPE_LID; 347 button->type = ACPI_BUTTON_TYPE_LID;
370 strcpy(acpi_device_name(device), 348 strcpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_LID);
371 ACPI_BUTTON_DEVICE_NAME_LID); 349 sprintf(acpi_device_class(device), "%s/%s",
372 sprintf(acpi_device_class(device), "%s/%s",
373 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); 350 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
374 } 351 } else {
375 else {
376 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", 352 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n",
377 acpi_device_hid(device))); 353 acpi_device_hid(device)));
378 result = -ENODEV; 354 result = -ENODEV;
379 goto end; 355 goto end;
380 } 356 }
@@ -385,46 +361,46 @@ acpi_button_add (
385 361
386 switch (button->type) { 362 switch (button->type) {
387 case ACPI_BUTTON_TYPE_POWERF: 363 case ACPI_BUTTON_TYPE_POWERF:
388 status = acpi_install_fixed_event_handler ( 364 status =
389 ACPI_EVENT_POWER_BUTTON, 365 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
390 acpi_button_notify_fixed, 366 acpi_button_notify_fixed,
391 button); 367 button);
392 break; 368 break;
393 case ACPI_BUTTON_TYPE_SLEEPF: 369 case ACPI_BUTTON_TYPE_SLEEPF:
394 status = acpi_install_fixed_event_handler ( 370 status =
395 ACPI_EVENT_SLEEP_BUTTON, 371 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
396 acpi_button_notify_fixed, 372 acpi_button_notify_fixed,
397 button); 373 button);
398 break; 374 break;
399 default: 375 default:
400 status = acpi_install_notify_handler ( 376 status = acpi_install_notify_handler(button->handle,
401 button->handle, 377 ACPI_DEVICE_NOTIFY,
402 ACPI_DEVICE_NOTIFY, 378 acpi_button_notify,
403 acpi_button_notify, 379 button);
404 button);
405 break; 380 break;
406 } 381 }
407 382
408 if (ACPI_FAILURE(status)) { 383 if (ACPI_FAILURE(status)) {
409 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 384 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
410 "Error installing notify handler\n")); 385 "Error installing notify handler\n"));
411 result = -ENODEV; 386 result = -ENODEV;
412 goto end; 387 goto end;
413 } 388 }
414 389
415 if (device->wakeup.flags.valid) { 390 if (device->wakeup.flags.valid) {
416 /* Button's GPE is run-wake GPE */ 391 /* Button's GPE is run-wake GPE */
417 acpi_set_gpe_type(device->wakeup.gpe_device, 392 acpi_set_gpe_type(device->wakeup.gpe_device,
418 device->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); 393 device->wakeup.gpe_number,
419 acpi_enable_gpe(device->wakeup.gpe_device, 394 ACPI_GPE_TYPE_WAKE_RUN);
420 device->wakeup.gpe_number, ACPI_NOT_ISR); 395 acpi_enable_gpe(device->wakeup.gpe_device,
396 device->wakeup.gpe_number, ACPI_NOT_ISR);
421 device->wakeup.state.enabled = 1; 397 device->wakeup.state.enabled = 1;
422 } 398 }
423 399
424 printk(KERN_INFO PREFIX "%s [%s]\n", 400 printk(KERN_INFO PREFIX "%s [%s]\n",
425 acpi_device_name(device), acpi_device_bid(device)); 401 acpi_device_name(device), acpi_device_bid(device));
426 402
427end: 403 end:
428 if (result) { 404 if (result) {
429 acpi_button_remove_fs(device); 405 acpi_button_remove_fs(device);
430 kfree(button); 406 kfree(button);
@@ -433,12 +409,10 @@ end:
433 return_VALUE(result); 409 return_VALUE(result);
434} 410}
435 411
436 412static int acpi_button_remove(struct acpi_device *device, int type)
437static int
438acpi_button_remove (struct acpi_device *device, int type)
439{ 413{
440 acpi_status status = 0; 414 acpi_status status = 0;
441 struct acpi_button *button = NULL; 415 struct acpi_button *button = NULL;
442 416
443 ACPI_FUNCTION_TRACE("acpi_button_remove"); 417 ACPI_FUNCTION_TRACE("acpi_button_remove");
444 418
@@ -450,35 +424,36 @@ acpi_button_remove (struct acpi_device *device, int type)
450 /* Unregister for device notifications. */ 424 /* Unregister for device notifications. */
451 switch (button->type) { 425 switch (button->type) {
452 case ACPI_BUTTON_TYPE_POWERF: 426 case ACPI_BUTTON_TYPE_POWERF:
453 status = acpi_remove_fixed_event_handler( 427 status =
454 ACPI_EVENT_POWER_BUTTON, acpi_button_notify_fixed); 428 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
429 acpi_button_notify_fixed);
455 break; 430 break;
456 case ACPI_BUTTON_TYPE_SLEEPF: 431 case ACPI_BUTTON_TYPE_SLEEPF:
457 status = acpi_remove_fixed_event_handler( 432 status =
458 ACPI_EVENT_SLEEP_BUTTON, acpi_button_notify_fixed); 433 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
434 acpi_button_notify_fixed);
459 break; 435 break;
460 default: 436 default:
461 status = acpi_remove_notify_handler(button->handle, 437 status = acpi_remove_notify_handler(button->handle,
462 ACPI_DEVICE_NOTIFY, acpi_button_notify); 438 ACPI_DEVICE_NOTIFY,
439 acpi_button_notify);
463 break; 440 break;
464 } 441 }
465 442
466 if (ACPI_FAILURE(status)) 443 if (ACPI_FAILURE(status))
467 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 444 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
468 "Error removing notify handler\n")); 445 "Error removing notify handler\n"));
469 446
470 acpi_button_remove_fs(device); 447 acpi_button_remove_fs(device);
471 448
472 kfree(button); 449 kfree(button);
473 450
474 return_VALUE(0); 451 return_VALUE(0);
475} 452}
476 453
477 454static int __init acpi_button_init(void)
478static int __init
479acpi_button_init (void)
480{ 455{
481 int result = 0; 456 int result = 0;
482 457
483 ACPI_FUNCTION_TRACE("acpi_button_init"); 458 ACPI_FUNCTION_TRACE("acpi_button_init");
484 459
@@ -495,15 +470,13 @@ acpi_button_init (void)
495 return_VALUE(0); 470 return_VALUE(0);
496} 471}
497 472
498 473static void __exit acpi_button_exit(void)
499static void __exit
500acpi_button_exit (void)
501{ 474{
502 ACPI_FUNCTION_TRACE("acpi_button_exit"); 475 ACPI_FUNCTION_TRACE("acpi_button_exit");
503 476
504 acpi_bus_unregister_driver(&acpi_button_driver); 477 acpi_bus_unregister_driver(&acpi_button_driver);
505 478
506 if (acpi_power_dir) 479 if (acpi_power_dir)
507 remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir); 480 remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir);
508 if (acpi_sleep_dir) 481 if (acpi_sleep_dir)
509 remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir); 482 remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir);
@@ -514,6 +487,5 @@ acpi_button_exit (void)
514 return_VOID; 487 return_VOID;
515} 488}
516 489
517
518module_init(acpi_button_init); 490module_init(acpi_button_init);
519module_exit(acpi_button_exit); 491module_exit(acpi_button_exit);