diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-04-05 19:41:22 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-05 19:41:22 -0400 |
commit | 9efe21cb82b5dbe3b0b2ae4de4eccc64ecb94e95 (patch) | |
tree | 7ff8833745d2f268f897f6fa4a27263b4a572245 /drivers/acpi/button.c | |
parent | de18836e447c2dc30120c0919b8db8ddc0401cc4 (diff) | |
parent | 0221c81b1b8eb0cbb6b30a0ced52ead32d2b4e4c (diff) |
Merge branch 'linus' into irq/threaded
Conflicts:
include/linux/irq.h
kernel/irq/handle.c
Diffstat (limited to 'drivers/acpi/button.c')
-rw-r--r-- | drivers/acpi/button.c | 80 |
1 files changed, 8 insertions, 72 deletions
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 171fd914f435..d73c94b8441d 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
@@ -78,6 +78,7 @@ MODULE_DEVICE_TABLE(acpi, button_device_ids); | |||
78 | static int acpi_button_add(struct acpi_device *device); | 78 | static int acpi_button_add(struct acpi_device *device); |
79 | static int acpi_button_remove(struct acpi_device *device, int type); | 79 | static int acpi_button_remove(struct acpi_device *device, int type); |
80 | static int acpi_button_resume(struct acpi_device *device); | 80 | static int acpi_button_resume(struct acpi_device *device); |
81 | static void acpi_button_notify(struct acpi_device *device, u32 event); | ||
81 | static int acpi_button_info_open_fs(struct inode *inode, struct file *file); | 82 | 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); | 83 | static int acpi_button_state_open_fs(struct inode *inode, struct file *file); |
83 | 84 | ||
@@ -89,6 +90,7 @@ static struct acpi_driver acpi_button_driver = { | |||
89 | .add = acpi_button_add, | 90 | .add = acpi_button_add, |
90 | .resume = acpi_button_resume, | 91 | .resume = acpi_button_resume, |
91 | .remove = acpi_button_remove, | 92 | .remove = acpi_button_remove, |
93 | .notify = acpi_button_notify, | ||
92 | }, | 94 | }, |
93 | }; | 95 | }; |
94 | 96 | ||
@@ -200,12 +202,10 @@ static int acpi_button_add_fs(struct acpi_device *device) | |||
200 | 202 | ||
201 | if (!entry) | 203 | if (!entry) |
202 | return -ENODEV; | 204 | return -ENODEV; |
203 | entry->owner = THIS_MODULE; | ||
204 | 205 | ||
205 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); | 206 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); |
206 | if (!acpi_device_dir(device)) | 207 | if (!acpi_device_dir(device)) |
207 | return -ENODEV; | 208 | return -ENODEV; |
208 | acpi_device_dir(device)->owner = THIS_MODULE; | ||
209 | 209 | ||
210 | /* 'info' [R] */ | 210 | /* 'info' [R] */ |
211 | entry = proc_create_data(ACPI_BUTTON_FILE_INFO, | 211 | entry = proc_create_data(ACPI_BUTTON_FILE_INFO, |
@@ -265,15 +265,18 @@ static int acpi_lid_send_state(struct acpi_button *button) | |||
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |
267 | 267 | ||
268 | static void acpi_button_notify(acpi_handle handle, u32 event, void *data) | 268 | static void acpi_button_notify(struct acpi_device *device, u32 event) |
269 | { | 269 | { |
270 | struct acpi_button *button = data; | 270 | struct acpi_button *button = acpi_driver_data(device); |
271 | struct input_dev *input; | 271 | struct input_dev *input; |
272 | 272 | ||
273 | if (!button || !button->device) | 273 | if (!button || !button->device) |
274 | return; | 274 | return; |
275 | 275 | ||
276 | switch (event) { | 276 | switch (event) { |
277 | case ACPI_FIXED_HARDWARE_EVENT: | ||
278 | event = ACPI_BUTTON_NOTIFY_STATUS; | ||
279 | /* fall through */ | ||
277 | case ACPI_BUTTON_NOTIFY_STATUS: | 280 | case ACPI_BUTTON_NOTIFY_STATUS: |
278 | input = button->input; | 281 | input = button->input; |
279 | if (button->type == ACPI_BUTTON_TYPE_LID) { | 282 | if (button->type == ACPI_BUTTON_TYPE_LID) { |
@@ -300,46 +303,6 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) | |||
300 | return; | 303 | return; |
301 | } | 304 | } |
302 | 305 | ||
303 | static acpi_status acpi_button_notify_fixed(void *data) | ||
304 | { | ||
305 | struct acpi_button *button = data; | ||
306 | |||
307 | if (!button) | ||
308 | return AE_BAD_PARAMETER; | ||
309 | |||
310 | acpi_button_notify(button->device->handle, ACPI_BUTTON_NOTIFY_STATUS, button); | ||
311 | |||
312 | return AE_OK; | ||
313 | } | ||
314 | |||
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 | |||
343 | static int acpi_button_resume(struct acpi_device *device) | 306 | static int acpi_button_resume(struct acpi_device *device) |
344 | { | 307 | { |
345 | struct acpi_button *button; | 308 | struct acpi_button *button; |
@@ -351,25 +314,6 @@ static int acpi_button_resume(struct acpi_device *device) | |||
351 | return 0; | 314 | return 0; |
352 | } | 315 | } |
353 | 316 | ||
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 | |||
373 | static int acpi_button_add(struct acpi_device *device) | 317 | static int acpi_button_add(struct acpi_device *device) |
374 | { | 318 | { |
375 | int error; | 319 | int error; |
@@ -434,10 +378,6 @@ static int acpi_button_add(struct acpi_device *device) | |||
434 | if (error) | 378 | if (error) |
435 | goto err_free_input; | 379 | goto err_free_input; |
436 | 380 | ||
437 | error = acpi_button_install_notify_handlers(button); | ||
438 | if (error) | ||
439 | goto err_remove_fs; | ||
440 | |||
441 | snprintf(button->phys, sizeof(button->phys), | 381 | snprintf(button->phys, sizeof(button->phys), |
442 | "%s/button/input0", acpi_device_hid(device)); | 382 | "%s/button/input0", acpi_device_hid(device)); |
443 | 383 | ||
@@ -468,7 +408,7 @@ static int acpi_button_add(struct acpi_device *device) | |||
468 | 408 | ||
469 | error = input_register_device(input); | 409 | error = input_register_device(input); |
470 | if (error) | 410 | if (error) |
471 | goto err_remove_handlers; | 411 | goto err_remove_fs; |
472 | if (button->type == ACPI_BUTTON_TYPE_LID) | 412 | if (button->type == ACPI_BUTTON_TYPE_LID) |
473 | acpi_lid_send_state(button); | 413 | acpi_lid_send_state(button); |
474 | 414 | ||
@@ -487,8 +427,6 @@ static int acpi_button_add(struct acpi_device *device) | |||
487 | 427 | ||
488 | return 0; | 428 | return 0; |
489 | 429 | ||
490 | err_remove_handlers: | ||
491 | acpi_button_remove_notify_handlers(button); | ||
492 | err_remove_fs: | 430 | err_remove_fs: |
493 | acpi_button_remove_fs(device); | 431 | acpi_button_remove_fs(device); |
494 | err_free_input: | 432 | err_free_input: |
@@ -507,7 +445,6 @@ static int acpi_button_remove(struct acpi_device *device, int type) | |||
507 | 445 | ||
508 | button = acpi_driver_data(device); | 446 | button = acpi_driver_data(device); |
509 | 447 | ||
510 | acpi_button_remove_notify_handlers(button); | ||
511 | acpi_button_remove_fs(device); | 448 | acpi_button_remove_fs(device); |
512 | input_unregister_device(button->input); | 449 | input_unregister_device(button->input); |
513 | kfree(button); | 450 | kfree(button); |
@@ -522,7 +459,6 @@ static int __init acpi_button_init(void) | |||
522 | acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); | 459 | acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); |
523 | if (!acpi_button_dir) | 460 | if (!acpi_button_dir) |
524 | return -ENODEV; | 461 | return -ENODEV; |
525 | acpi_button_dir->owner = THIS_MODULE; | ||
526 | result = acpi_bus_register_driver(&acpi_button_driver); | 462 | result = acpi_bus_register_driver(&acpi_button_driver); |
527 | if (result < 0) { | 463 | if (result < 0) { |
528 | remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); | 464 | remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); |