diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-05 14:16:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-05 14:16:25 -0400 |
commit | 32fb6c17566ec66de87324a834c7776f40e35e78 (patch) | |
tree | 87b8ed5d66495536fbb452255c3eacd1cfb0c43a /drivers/acpi/scan.c | |
parent | 45e36c1666aa6c8b0c538abcf984b336184d8c3f (diff) | |
parent | 7ec0a7290797f57b780f792d12f4bcc19c83aa4f (diff) |
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (140 commits)
ACPI: processor: use .notify method instead of installing handler directly
ACPI: button: use .notify method instead of installing handler directly
ACPI: support acpi_device_ops .notify methods
toshiba-acpi: remove MAINTAINERS entry
ACPI: battery: asynchronous init
acer-wmi: Update copyright notice & documentation
acer-wmi: Cleanup the failure cleanup handling
acer-wmi: Blacklist Acer Aspire One
video: build fix
thinkpad-acpi: rework brightness support
thinkpad-acpi: enhanced debugging messages for the fan subdriver
thinkpad-acpi: enhanced debugging messages for the hotkey subdriver
thinkpad-acpi: enhanced debugging messages for rfkill subdrivers
thinkpad-acpi: restrict access to some firmware LEDs
thinkpad-acpi: remove HKEY disable functionality
thinkpad-acpi: add new debug helpers and warn of deprecated atts
thinkpad-acpi: add missing log levels
thinkpad-acpi: cleanup debug helpers
thinkpad-acpi: documentation cleanup
thinkpad-acpi: drop ibm-acpi alias
...
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 94 |
1 files changed, 74 insertions, 20 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index c54d7b6c4066..20c23c049207 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -11,6 +11,8 @@ | |||
11 | 11 | ||
12 | #include <acpi/acpi_drivers.h> | 12 | #include <acpi/acpi_drivers.h> |
13 | 13 | ||
14 | #include "internal.h" | ||
15 | |||
14 | #define _COMPONENT ACPI_BUS_COMPONENT | 16 | #define _COMPONENT ACPI_BUS_COMPONENT |
15 | ACPI_MODULE_NAME("scan"); | 17 | ACPI_MODULE_NAME("scan"); |
16 | #define STRUCT_TO_INT(s) (*((int*)&s)) | 18 | #define STRUCT_TO_INT(s) (*((int*)&s)) |
@@ -357,6 +359,61 @@ static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
357 | return 0; | 359 | return 0; |
358 | } | 360 | } |
359 | 361 | ||
362 | static void acpi_device_notify(acpi_handle handle, u32 event, void *data) | ||
363 | { | ||
364 | struct acpi_device *device = data; | ||
365 | |||
366 | device->driver->ops.notify(device, event); | ||
367 | } | ||
368 | |||
369 | static acpi_status acpi_device_notify_fixed(void *data) | ||
370 | { | ||
371 | struct acpi_device *device = data; | ||
372 | |||
373 | acpi_device_notify(device->handle, ACPI_FIXED_HARDWARE_EVENT, device); | ||
374 | return AE_OK; | ||
375 | } | ||
376 | |||
377 | static int acpi_device_install_notify_handler(struct acpi_device *device) | ||
378 | { | ||
379 | acpi_status status; | ||
380 | char *hid; | ||
381 | |||
382 | hid = acpi_device_hid(device); | ||
383 | if (!strcmp(hid, ACPI_BUTTON_HID_POWERF)) | ||
384 | status = | ||
385 | acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, | ||
386 | acpi_device_notify_fixed, | ||
387 | device); | ||
388 | else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) | ||
389 | status = | ||
390 | acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, | ||
391 | acpi_device_notify_fixed, | ||
392 | device); | ||
393 | else | ||
394 | status = acpi_install_notify_handler(device->handle, | ||
395 | ACPI_DEVICE_NOTIFY, | ||
396 | acpi_device_notify, | ||
397 | device); | ||
398 | |||
399 | if (ACPI_FAILURE(status)) | ||
400 | return -EINVAL; | ||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | static void acpi_device_remove_notify_handler(struct acpi_device *device) | ||
405 | { | ||
406 | if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) | ||
407 | acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, | ||
408 | acpi_device_notify_fixed); | ||
409 | else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) | ||
410 | acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, | ||
411 | acpi_device_notify_fixed); | ||
412 | else | ||
413 | acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, | ||
414 | acpi_device_notify); | ||
415 | } | ||
416 | |||
360 | static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); | 417 | static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); |
361 | static int acpi_start_single_object(struct acpi_device *); | 418 | static int acpi_start_single_object(struct acpi_device *); |
362 | static int acpi_device_probe(struct device * dev) | 419 | static int acpi_device_probe(struct device * dev) |
@@ -369,6 +426,20 @@ static int acpi_device_probe(struct device * dev) | |||
369 | if (!ret) { | 426 | if (!ret) { |
370 | if (acpi_dev->bus_ops.acpi_op_start) | 427 | if (acpi_dev->bus_ops.acpi_op_start) |
371 | acpi_start_single_object(acpi_dev); | 428 | acpi_start_single_object(acpi_dev); |
429 | |||
430 | if (acpi_drv->ops.notify) { | ||
431 | ret = acpi_device_install_notify_handler(acpi_dev); | ||
432 | if (ret) { | ||
433 | if (acpi_drv->ops.stop) | ||
434 | acpi_drv->ops.stop(acpi_dev, | ||
435 | acpi_dev->removal_type); | ||
436 | if (acpi_drv->ops.remove) | ||
437 | acpi_drv->ops.remove(acpi_dev, | ||
438 | acpi_dev->removal_type); | ||
439 | return ret; | ||
440 | } | ||
441 | } | ||
442 | |||
372 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 443 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
373 | "Found driver [%s] for device [%s]\n", | 444 | "Found driver [%s] for device [%s]\n", |
374 | acpi_drv->name, acpi_dev->pnp.bus_id)); | 445 | acpi_drv->name, acpi_dev->pnp.bus_id)); |
@@ -383,6 +454,8 @@ static int acpi_device_remove(struct device * dev) | |||
383 | struct acpi_driver *acpi_drv = acpi_dev->driver; | 454 | struct acpi_driver *acpi_drv = acpi_dev->driver; |
384 | 455 | ||
385 | if (acpi_drv) { | 456 | if (acpi_drv) { |
457 | if (acpi_drv->ops.notify) | ||
458 | acpi_device_remove_notify_handler(acpi_dev); | ||
386 | if (acpi_drv->ops.stop) | 459 | if (acpi_drv->ops.stop) |
387 | acpi_drv->ops.stop(acpi_dev, acpi_dev->removal_type); | 460 | acpi_drv->ops.stop(acpi_dev, acpi_dev->removal_type); |
388 | if (acpi_drv->ops.remove) | 461 | if (acpi_drv->ops.remove) |
@@ -395,22 +468,10 @@ static int acpi_device_remove(struct device * dev) | |||
395 | return 0; | 468 | return 0; |
396 | } | 469 | } |
397 | 470 | ||
398 | static void acpi_device_shutdown(struct device *dev) | ||
399 | { | ||
400 | struct acpi_device *acpi_dev = to_acpi_device(dev); | ||
401 | struct acpi_driver *acpi_drv = acpi_dev->driver; | ||
402 | |||
403 | if (acpi_drv && acpi_drv->ops.shutdown) | ||
404 | acpi_drv->ops.shutdown(acpi_dev); | ||
405 | |||
406 | return ; | ||
407 | } | ||
408 | |||
409 | struct bus_type acpi_bus_type = { | 471 | struct bus_type acpi_bus_type = { |
410 | .name = "acpi", | 472 | .name = "acpi", |
411 | .suspend = acpi_device_suspend, | 473 | .suspend = acpi_device_suspend, |
412 | .resume = acpi_device_resume, | 474 | .resume = acpi_device_resume, |
413 | .shutdown = acpi_device_shutdown, | ||
414 | .match = acpi_bus_match, | 475 | .match = acpi_bus_match, |
415 | .probe = acpi_device_probe, | 476 | .probe = acpi_device_probe, |
416 | .remove = acpi_device_remove, | 477 | .remove = acpi_device_remove, |
@@ -1524,16 +1585,11 @@ static int acpi_bus_scan_fixed(struct acpi_device *root) | |||
1524 | return result; | 1585 | return result; |
1525 | } | 1586 | } |
1526 | 1587 | ||
1527 | 1588 | int __init acpi_scan_init(void) | |
1528 | static int __init acpi_scan_init(void) | ||
1529 | { | 1589 | { |
1530 | int result; | 1590 | int result; |
1531 | struct acpi_bus_ops ops; | 1591 | struct acpi_bus_ops ops; |
1532 | 1592 | ||
1533 | |||
1534 | if (acpi_disabled) | ||
1535 | return 0; | ||
1536 | |||
1537 | memset(&ops, 0, sizeof(ops)); | 1593 | memset(&ops, 0, sizeof(ops)); |
1538 | ops.acpi_op_add = 1; | 1594 | ops.acpi_op_add = 1; |
1539 | ops.acpi_op_start = 1; | 1595 | ops.acpi_op_start = 1; |
@@ -1566,5 +1622,3 @@ static int __init acpi_scan_init(void) | |||
1566 | Done: | 1622 | Done: |
1567 | return result; | 1623 | return result; |
1568 | } | 1624 | } |
1569 | |||
1570 | subsys_initcall(acpi_scan_init); | ||