2 * acpi_bus.c - ACPI Bus Driver ($Revision: 77 $)
4 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/init.h>
28 #include <linux/types.h>
29 #include <linux/version.h>
30 #include <linux/ioport.h>
31 #include <linux/list.h>
32 #include <linux/sched.h>
34 #include <linux/proc_fs.h>
36 #include <asm/mpspec.h>
38 #include <acpi/acpi_bus.h>
39 #include <acpi/acpi_drivers.h>
40 #include <acpi/acinterp.h> /* for acpi_ex_eisa_id_to_string() */
43 #define _COMPONENT ACPI_BUS_COMPONENT
44 ACPI_MODULE_NAME ("acpi_bus")
46 MODULE_AUTHOR("Paul Diefenbaugh");
47 MODULE_DESCRIPTION(ACPI_BUS_DRIVER_NAME);
48 MODULE_LICENSE("GPL");
50 #define PREFIX "ACPI: "
52 extern void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger);
54 FADT_DESCRIPTOR acpi_fadt;
55 struct acpi_device *acpi_root;
56 struct proc_dir_entry *acpi_root_dir;
58 #define STRUCT_TO_INT(s) (*((int*)&s))
61 /* --------------------------------------------------------------------------
62 Linux Driver Model (LDM) Support
63 -------------------------------------------------------------------------- */
67 static int acpi_device_probe(struct device *dev);
68 static int acpi_device_remove(struct device *dev);
69 static int acpi_device_suspend(struct device *dev, u32 state, u32 stage);
70 static int acpi_device_resume(struct device *dev, u32 stage);
72 static struct device_driver acpi_bus_driver = {
73 .probe = acpi_device_probe,
74 .remove = acpi_device_remove,
75 .suspend = acpi_device_suspend,
76 .resume = acpi_device_resume,
84 ACPI_FUNCTION_TRACE("acpi_device_probe");
87 return_VALUE(-EINVAL);
99 ACPI_FUNCTION_TRACE("acpi_device_remove");
102 return_VALUE(-EINVAL);
111 acpi_device_suspend (
116 ACPI_FUNCTION_TRACE("acpi_device_suspend");
119 return_VALUE(-EINVAL);
132 ACPI_FUNCTION_TRACE("acpi_device_resume");
135 return_VALUE(-EINVAL);
142 #if 0 /* not used ATM */
147 ACPI_FUNCTION_TRACE("acpi_platform_add");
152 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device %s (%s) added\n",
153 dev->name, dev->bus_id));
162 acpi_platform_remove (
165 ACPI_FUNCTION_TRACE("acpi_platform_add");
170 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device %s (%s) removed\n",
171 dev->name, dev->bus_id));
180 #endif /*CONFIG_LDM*/
184 acpi_device_register (
185 struct acpi_device *device,
186 struct acpi_device *parent)
190 ACPI_FUNCTION_TRACE("acpi_device_register");
193 return_VALUE(-EINVAL);
196 sprintf(device->dev.name, "ACPI device %s:%s",
197 device->pnp.hardware_id, device->pnp.unique_id);
198 strncpy(device->dev.bus_id, device->pnp.bus_id, sizeof(acpi_bus_id));
200 device->dev.parent = &parent->dev;
201 device->dev.driver = &acpi_bus_driver;
203 result = device_register(&device->dev);
204 #endif /*CONFIG_LDM*/
206 return_VALUE(result);
211 acpi_device_unregister (
212 struct acpi_device *device)
214 ACPI_FUNCTION_TRACE("acpi_device_unregister");
217 return_VALUE(-EINVAL);
220 put_device(&device->dev);
221 #endif /*CONFIG_LDM*/
227 /* --------------------------------------------------------------------------
229 -------------------------------------------------------------------------- */
232 acpi_bus_data_handler (
237 ACPI_FUNCTION_TRACE("acpi_bus_data_handler");
246 acpi_bus_get_device (
248 struct acpi_device **device)
250 acpi_status status = AE_OK;
252 ACPI_FUNCTION_TRACE("acpi_bus_get_device");
255 return_VALUE(-EINVAL);
257 /* TBD: Support fixed-feature devices */
259 status = acpi_get_data(handle, acpi_bus_data_handler, (void**) device);
260 if (ACPI_FAILURE(status) || !*device) {
261 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context for object [%p]\n",
263 return_VALUE(-ENODEV);
270 acpi_bus_get_status (
271 struct acpi_device *device)
273 acpi_status status = AE_OK;
274 unsigned long sta = 0;
276 ACPI_FUNCTION_TRACE("acpi_bus_get_status");
279 return_VALUE(-EINVAL);
282 * Evaluate _STA if present.
284 if (device->flags.dynamic_status) {
285 status = acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
286 if (ACPI_FAILURE(status))
287 return_VALUE(-ENODEV);
288 STRUCT_TO_INT(device->status) = (int) sta;
292 * Otherwise we assume the status of our parent (unless we don't
293 * have one, in which case status is implied).
295 else if (device->parent)
296 device->status = device->parent->status;
298 STRUCT_TO_INT(device->status) = 0x0F;
300 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
301 device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status)));
309 acpi_bus_create_device_fs (struct device *device)
311 ACPI_FUNCTION_TRACE("acpi_bus_create_device_fs");
314 return_VALUE(-EINVAL);
316 if (device->dir.entry)
317 return_VALUE(-EEXIST);
320 device->dir.entry = proc_mkdir(device->pnp.bus_id, NULL);
322 device->dir.entry = proc_mkdir(device->pnp.bus_id,
323 device->parent->fs.entry);
325 if (!device->dir.entry) {
326 printk(KERN_ERR PREFIX "Unable to create fs entry '%s'\n",
328 return_VALUE(-ENODEV);
336 acpi_bus_remove_device_fs (struct device *device)
338 ACPI_FUNCTION_TRACE("acpi_bus_create_device_fs");
341 return_VALUE(-EINVAL);
343 if (!device->dir.entry)
344 return_VALUE(-ENODEV);
347 remove_proc_entry(device->pnp_bus_id, NULL);
349 remove_proc_entry(device->pnp.bus_id, device->parent->fs.entry);
351 device->dir.entry = NULL;
358 /* --------------------------------------------------------------------------
360 -------------------------------------------------------------------------- */
368 acpi_status status = 0;
369 struct acpi_device *device = NULL;
370 unsigned long psc = 0;
372 ACPI_FUNCTION_TRACE("acpi_bus_get_power");
374 result = acpi_bus_get_device(handle, &device);
376 return_VALUE(result);
378 *state = ACPI_STATE_UNKNOWN;
380 if (!device->flags.power_manageable) {
381 /* TBD: Non-recursive algorithm for walking up hierarchy */
383 *state = device->parent->power.state;
385 *state = ACPI_STATE_D0;
389 * Get the device's power state either directly (via _PSC) or
390 * indirectly (via power resources).
392 if (device->power.flags.explicit_get) {
393 status = acpi_evaluate_integer(device->handle, "_PSC",
395 if (ACPI_FAILURE(status))
396 return_VALUE(-ENODEV);
397 device->power.state = (int) psc;
399 else if (device->power.flags.power_resources) {
400 result = acpi_power_get_inferred_state(device);
402 return_VALUE(result);
405 *state = device->power.state;
408 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n",
409 device->pnp.bus_id, device->power.state));
421 acpi_status status = AE_OK;
422 struct acpi_device *device = NULL;
423 char object_name[5] = {'_','P','S','0'+state,'\0'};
425 ACPI_FUNCTION_TRACE("acpi_bus_set_power");
427 result = acpi_bus_get_device(handle, &device);
429 return_VALUE(result);
431 if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
432 return_VALUE(-EINVAL);
434 /* Make sure this is a valid target state */
436 if (!device->flags.power_manageable) {
437 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device is not power manageable\n"));
438 return_VALUE(-ENODEV);
440 if (state == device->power.state) {
441 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state));
444 if (!device->power.states[state].flags.valid) {
445 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n", state));
446 return_VALUE(-ENODEV);
448 if (device->parent && (state < device->parent->power.state)) {
449 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Cannot set device to a higher-powered state than parent\n"));
450 return_VALUE(-ENODEV);
456 * On transitions to a high-powered state we first apply power (via
457 * power resources) then evalute _PSx. Conversly for transitions to
458 * a lower-powered state.
460 if (state < device->power.state) {
461 if (device->power.flags.power_resources) {
462 result = acpi_power_transition(device, state);
466 if (device->power.states[state].flags.explicit_set) {
467 status = acpi_evaluate_object(device->handle,
468 object_name, NULL, NULL);
469 if (ACPI_FAILURE(status)) {
476 if (device->power.states[state].flags.explicit_set) {
477 status = acpi_evaluate_object(device->handle,
478 object_name, NULL, NULL);
479 if (ACPI_FAILURE(status)) {
484 if (device->power.flags.power_resources) {
485 result = acpi_power_transition(device, state);
493 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error transitioning device [%s] to D%d\n",
494 device->pnp.bus_id, state));
496 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] transitioned to D%d\n",
497 device->pnp.bus_id, state));
499 return_VALUE(result);
504 acpi_bus_get_power_flags (
505 struct acpi_device *device)
507 acpi_status status = 0;
508 acpi_handle handle = 0;
511 ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags");
517 * Power Management Flags
519 status = acpi_get_handle(device->handle, "_PSC", &handle);
520 if (ACPI_SUCCESS(status))
521 device->power.flags.explicit_get = 1;
522 status = acpi_get_handle(device->handle, "_IRC", &handle);
523 if (ACPI_SUCCESS(status))
524 device->power.flags.inrush_current = 1;
525 status = acpi_get_handle(device->handle, "_PRW", &handle);
526 if (ACPI_SUCCESS(status))
527 device->power.flags.wake_capable = 1;
530 * Enumerate supported power management states
532 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) {
533 struct acpi_device_power_state *ps = &device->power.states[i];
534 char object_name[5] = {'_','P','R','0'+i,'\0'};
536 /* Evaluate "_PRx" to se if power resources are referenced */
537 acpi_evaluate_reference(device->handle, object_name, NULL,
539 if (ps->resources.count) {
540 device->power.flags.power_resources = 1;
544 /* Evaluate "_PSx" to see if we can do explicit sets */
545 object_name[2] = 'S';
546 status = acpi_get_handle(device->handle, object_name, &handle);
547 if (ACPI_SUCCESS(status)) {
548 ps->flags.explicit_set = 1;
552 /* State is valid if we have some power control */
553 if (ps->resources.count || ps->flags.explicit_set)
556 ps->power = -1; /* Unknown - driver assigned */
557 ps->latency = -1; /* Unknown - driver assigned */
560 /* Set defaults for D0 and D3 states (always valid) */
561 device->power.states[ACPI_STATE_D0].flags.valid = 1;
562 device->power.states[ACPI_STATE_D0].power = 100;
563 device->power.states[ACPI_STATE_D3].flags.valid = 1;
564 device->power.states[ACPI_STATE_D3].power = 0;
567 * System Power States
568 * -------------------
570 /* TBD: S1-S4 power state support and resource requirements. */
572 for (i=ACPI_STATE_S1; i<ACPI_STATE_S5; i++) {
573 char name[5] = {'_','S',('0'+i),'D','\0'};
574 status = acpi_evaluate_integer(device->handle, name, NULL,
576 if (ACPI_FAILURE(status))
581 /* TBD: System wake support and resource requirements. */
583 device->power.state = ACPI_STATE_UNKNOWN;
589 /* --------------------------------------------------------------------------
590 Performance Management
591 -------------------------------------------------------------------------- */
594 acpi_bus_get_perf_flags (
595 struct acpi_device *device)
597 ACPI_FUNCTION_TRACE("acpi_bus_get_perf_flags");
602 device->performance.state = ACPI_STATE_UNKNOWN;
608 /* --------------------------------------------------------------------------
610 -------------------------------------------------------------------------- */
612 static spinlock_t acpi_bus_event_lock = SPIN_LOCK_UNLOCKED;
614 LIST_HEAD(acpi_bus_event_list);
615 DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue);
617 extern int event_is_open;
620 acpi_bus_generate_event (
621 struct acpi_device *device,
625 struct acpi_bus_event *event = NULL;
626 unsigned long flags = 0;
628 ACPI_FUNCTION_TRACE("acpi_bus_generate_event");
631 return_VALUE(-EINVAL);
633 /* drop event on the floor if no one's listening */
637 event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
639 return_VALUE(-ENOMEM);
641 sprintf(event->device_class, "%s", device->pnp.device_class);
642 sprintf(event->bus_id, "%s", device->pnp.bus_id);
646 spin_lock_irqsave(&acpi_bus_event_lock, flags);
647 list_add_tail(&event->node, &acpi_bus_event_list);
648 spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
650 wake_up_interruptible(&acpi_bus_event_queue);
656 acpi_bus_receive_event (
657 struct acpi_bus_event *event)
659 unsigned long flags = 0;
660 struct acpi_bus_event *entry = NULL;
662 DECLARE_WAITQUEUE(wait, current);
664 ACPI_FUNCTION_TRACE("acpi_bus_receive_event");
669 if (list_empty(&acpi_bus_event_list)) {
671 set_current_state(TASK_INTERRUPTIBLE);
672 add_wait_queue(&acpi_bus_event_queue, &wait);
674 if (list_empty(&acpi_bus_event_list))
677 remove_wait_queue(&acpi_bus_event_queue, &wait);
678 set_current_state(TASK_RUNNING);
680 if (signal_pending(current))
681 return_VALUE(-ERESTARTSYS);
684 spin_lock_irqsave(&acpi_bus_event_lock, flags);
685 entry = list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node);
687 list_del(&entry->node);
688 spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
691 return_VALUE(-ENODEV);
693 memcpy(event, entry, sizeof(struct acpi_bus_event));
701 /* --------------------------------------------------------------------------
703 -------------------------------------------------------------------------- */
708 typedef int (*acpi_bus_walk_callback)(struct acpi_device*, int, void*);
710 #define HAS_CHILDREN(d) ((d)->children.next != &((d)->children))
711 #define HAS_SIBLINGS(d) (((d)->parent) && ((d)->node.next != &(d)->parent->children))
712 #define NODE_TO_DEVICE(n) (list_entry(n, struct acpi_device, node))
718 * Used to walk the ACPI Bus's device namespace. Can walk down (depth-first)
719 * or up. Able to parse starting at any node in the namespace. Note that a
720 * callback return value of -ELOOP will terminate the walk.
722 * @start: starting point
723 * callback: function to call for every device encountered while parsing
724 * direction: direction to parse (up or down)
725 * @data: context for this search operation
729 struct acpi_device *start,
730 acpi_bus_walk_callback callback,
736 struct acpi_device *device = NULL;
738 if (!start || !callback)
746 * Parse a given subtree (specified by start) in the given direction.
747 * Walking 'up' simply means that we execute the callback on leaf
748 * devices prior to their parents (useful for things like removing
749 * or powering down a subtree).
754 if (direction == WALK_DOWN)
755 if (-ELOOP == callback(device, level, data))
760 if (HAS_CHILDREN(device)) {
761 device = NODE_TO_DEVICE(device->children.next);
766 if (direction == WALK_UP)
767 if (-ELOOP == callback(device, level, data))
772 if (HAS_SIBLINGS(device)) {
773 device = NODE_TO_DEVICE(device->node.next);
777 /* Scope Exhausted - Find Next */
779 while ((device = device->parent)) {
781 if (HAS_SIBLINGS(device)) {
782 device = NODE_TO_DEVICE(device->node.next);
788 if ((direction == WALK_UP) && (result == 0))
789 callback(start, level, data);
795 /* --------------------------------------------------------------------------
796 Notification Handling
797 -------------------------------------------------------------------------- */
800 acpi_bus_check_device (
801 struct acpi_device *device,
804 acpi_status status = 0;
805 struct acpi_device_status old_status;
807 ACPI_FUNCTION_TRACE("acpi_bus_check_device");
810 return_VALUE(-EINVAL);
815 old_status = device->status;
818 * Make sure this device's parent is present before we go about
819 * messing with the device.
821 if (device->parent && !device->parent->status.present) {
822 device->status = device->parent->status;
823 if (STRUCT_TO_INT(old_status) != STRUCT_TO_INT(device->status)) {
830 status = acpi_bus_get_status(device);
831 if (ACPI_FAILURE(status))
832 return_VALUE(-ENODEV);
834 if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
841 * Device Insertion/Removal
843 if ((device->status.present) && !(old_status.present)) {
844 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n"));
845 /* TBD: Handle device insertion */
847 else if (!(device->status.present) && (old_status.present)) {
848 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n"));
849 /* TBD: Handle device removal */
857 acpi_bus_check_scope (
858 struct acpi_device *device)
861 int status_changed = 0;
863 ACPI_FUNCTION_TRACE("acpi_bus_check_scope");
866 return_VALUE(-EINVAL);
869 result = acpi_bus_check_device(device, &status_changed);
871 return_VALUE(result);
877 * TBD: Enumerate child devices within this device's scope and
878 * run acpi_bus_check_device()'s on them.
888 * Callback for all 'system-level' device notifications (values 0x00-0x7F).
897 struct acpi_device *device = NULL;
899 ACPI_FUNCTION_TRACE("acpi_bus_notify");
901 if (acpi_bus_get_device(handle, &device))
906 case ACPI_NOTIFY_BUS_CHECK:
907 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS CHECK notification for device [%s]\n",
908 device->pnp.bus_id));
909 result = acpi_bus_check_scope(device);
911 * TBD: We'll need to outsource certain events to non-ACPI
912 * drivers via the device manager (device.c).
916 case ACPI_NOTIFY_DEVICE_CHECK:
917 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK notification for device [%s]\n",
918 device->pnp.bus_id));
919 result = acpi_bus_check_device(device, NULL);
921 * TBD: We'll need to outsource certain events to non-ACPI
922 * drivers via the device manager (device.c).
926 case ACPI_NOTIFY_DEVICE_WAKE:
927 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE WAKE notification for device [%s]\n",
928 device->pnp.bus_id));
932 case ACPI_NOTIFY_EJECT_REQUEST:
933 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received EJECT REQUEST notification for device [%s]\n",
934 device->pnp.bus_id));
938 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
939 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received DEVICE CHECK LIGHT notification for device [%s]\n",
940 device->pnp.bus_id));
941 /* TBD: Exactly what does 'light' mean? */
944 case ACPI_NOTIFY_FREQUENCY_MISMATCH:
945 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received FREQUENCY MISMATCH notification for device [%s]\n",
946 device->pnp.bus_id));
950 case ACPI_NOTIFY_BUS_MODE_MISMATCH:
951 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received BUS MODE MISMATCH notification for device [%s]\n",
952 device->pnp.bus_id));
956 case ACPI_NOTIFY_POWER_FAULT:
957 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received POWER FAULT notification for device [%s]\n",
958 device->pnp.bus_id));
963 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Received unknown/unsupported notification [%08x]\n",
972 /* --------------------------------------------------------------------------
974 -------------------------------------------------------------------------- */
976 static LIST_HEAD(acpi_bus_drivers);
977 static DECLARE_MUTEX(acpi_bus_drivers_lock);
983 * Checks the device's hardware (_HID) or compatible (_CID) ids to see if it
984 * matches the specified driver's criteria.
988 struct acpi_device *device,
989 struct acpi_driver *driver)
993 if (device->flags.hardware_id)
994 if (strstr(driver->ids, device->pnp.hardware_id))
997 if (device->flags.compatible_ids) {
998 struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
1001 /* compare multiple _CID entries against driver ids */
1002 for (i = 0; i < cid_list->count; i++)
1004 if (strstr(driver->ids, cid_list->id[i].value))
1017 * acpi_bus_driver_init
1018 * --------------------
1019 * Used to initialize a device via its device driver. Called whenever a
1020 * driver is bound to a device. Invokes the driver's add() and start() ops.
1023 acpi_bus_driver_init (
1024 struct acpi_device *device,
1025 struct acpi_driver *driver)
1029 ACPI_FUNCTION_TRACE("acpi_bus_driver_init");
1031 if (!device || !driver)
1032 return_VALUE(-EINVAL);
1034 if (!driver->ops.add)
1035 return_VALUE(-ENOSYS);
1037 result = driver->ops.add(device);
1039 device->driver = NULL;
1040 acpi_driver_data(device) = NULL;
1041 return_VALUE(result);
1044 device->driver = driver;
1047 * TBD - Configuration Management: Assign resources to device based
1048 * upon possible configuration and currently allocated resources.
1051 if (driver->ops.start) {
1052 result = driver->ops.start(device);
1053 if (result && driver->ops.remove)
1054 driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
1055 return_VALUE(result);
1058 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n"));
1062 * Update the device information (in the global device hierarchy) now
1063 * that there's a driver bound to it.
1065 strncpy(device->dev.name, device->pnp.device_name,
1066 sizeof(device->dev.name));
1069 if (driver->ops.scan) {
1070 driver->ops.scan(device);
1080 * Callback for acpi_bus_walk() used to find devices that match a specific
1081 * driver's criteria and then attach the driver.
1085 struct acpi_device *device,
1090 struct acpi_driver *driver = NULL;
1092 ACPI_FUNCTION_TRACE("acpi_bus_attach");
1094 if (!device || !data)
1095 return_VALUE(-EINVAL);
1097 driver = (struct acpi_driver *) data;
1100 return_VALUE(-EEXIST);
1102 if (!device->status.present)
1103 return_VALUE(-ENODEV);
1105 result = acpi_bus_match(device, driver);
1107 return_VALUE(result);
1109 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n",
1110 driver->name, device->pnp.bus_id));
1112 result = acpi_bus_driver_init(device, driver);
1114 return_VALUE(result);
1116 down(&acpi_bus_drivers_lock);
1117 ++driver->references;
1118 up(&acpi_bus_drivers_lock);
1127 * Callback for acpi_bus_walk() used to find devices that match a specific
1128 * driver's criteria and unattach the driver.
1132 struct acpi_device *device,
1137 struct acpi_driver *driver = (struct acpi_driver *) data;
1139 ACPI_FUNCTION_TRACE("acpi_bus_unattach");
1141 if (!device || !driver)
1142 return_VALUE(-EINVAL);
1144 if (device->driver != driver)
1145 return_VALUE(-ENOENT);
1147 if (!driver->ops.remove)
1148 return_VALUE(-ENOSYS);
1150 result = driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
1152 return_VALUE(result);
1154 device->driver = NULL;
1155 acpi_driver_data(device) = NULL;
1157 down(&acpi_bus_drivers_lock);
1158 driver->references--;
1159 up(&acpi_bus_drivers_lock);
1166 * acpi_bus_find_driver
1167 * --------------------
1168 * Parses the list of registered drivers looking for a driver applicable for
1169 * the specified device.
1172 acpi_bus_find_driver (
1173 struct acpi_device *device)
1175 int result = -ENODEV;
1176 struct list_head *entry = NULL;
1177 struct acpi_driver *driver = NULL;
1179 ACPI_FUNCTION_TRACE("acpi_bus_find_driver");
1181 if (!device || device->driver)
1182 return_VALUE(-EINVAL);
1184 down(&acpi_bus_drivers_lock);
1186 list_for_each(entry, &acpi_bus_drivers) {
1188 driver = list_entry(entry, struct acpi_driver, node);
1190 if (acpi_bus_match(device, driver))
1193 result = acpi_bus_driver_init(device, driver);
1195 ++driver->references;
1200 up(&acpi_bus_drivers_lock);
1202 return_VALUE(result);
1207 * acpi_bus_register_driver
1208 * ------------------------
1209 * Registers a driver with the ACPI bus. Searches the namespace for all
1210 * devices that match the driver's criteria and binds.
1213 acpi_bus_register_driver (
1214 struct acpi_driver *driver)
1216 ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
1219 return_VALUE(-EINVAL);
1222 return_VALUE(-ENODEV);
1224 down(&acpi_bus_drivers_lock);
1225 list_add_tail(&driver->node, &acpi_bus_drivers);
1226 up(&acpi_bus_drivers_lock);
1228 acpi_bus_walk(acpi_root, acpi_bus_attach,
1231 return_VALUE(driver->references);
1236 * acpi_bus_unregister_driver
1237 * --------------------------
1238 * Unregisters a driver with the ACPI bus. Searches the namespace for all
1239 * devices that match the driver's criteria and unbinds.
1242 acpi_bus_unregister_driver (
1243 struct acpi_driver *driver)
1245 ACPI_FUNCTION_TRACE("acpi_bus_unregister_driver");
1248 return_VALUE(-EINVAL);
1250 acpi_bus_walk(acpi_root, acpi_bus_unattach, WALK_UP, driver);
1252 if (driver->references)
1253 return_VALUE(driver->references);
1255 down(&acpi_bus_drivers_lock);
1256 list_del(&driver->node);
1257 up(&acpi_bus_drivers_lock);
1263 /* --------------------------------------------------------------------------
1265 -------------------------------------------------------------------------- */
1268 acpi_bus_get_flags (
1269 struct acpi_device *device)
1271 acpi_status status = AE_OK;
1272 acpi_handle temp = NULL;
1274 ACPI_FUNCTION_TRACE("acpi_bus_get_flags");
1276 /* Presence of _STA indicates 'dynamic_status' */
1277 status = acpi_get_handle(device->handle, "_STA", &temp);
1278 if (ACPI_SUCCESS(status))
1279 device->flags.dynamic_status = 1;
1281 /* Presence of _CID indicates 'compatible_ids' */
1282 status = acpi_get_handle(device->handle, "_CID", &temp);
1283 if (ACPI_SUCCESS(status))
1284 device->flags.compatible_ids = 1;
1286 /* Presence of _RMV indicates 'removable' */
1287 status = acpi_get_handle(device->handle, "_RMV", &temp);
1288 if (ACPI_SUCCESS(status))
1289 device->flags.removable = 1;
1291 /* Presence of _EJD|_EJ0 indicates 'ejectable' */
1292 status = acpi_get_handle(device->handle, "_EJD", &temp);
1293 if (ACPI_SUCCESS(status))
1294 device->flags.ejectable = 1;
1296 status = acpi_get_handle(device->handle, "_EJ0", &temp);
1297 if (ACPI_SUCCESS(status))
1298 device->flags.ejectable = 1;
1301 /* Presence of _LCK indicates 'lockable' */
1302 status = acpi_get_handle(device->handle, "_LCK", &temp);
1303 if (ACPI_SUCCESS(status))
1304 device->flags.lockable = 1;
1306 /* Presence of _PS0|_PR0 indicates 'power manageable' */
1307 status = acpi_get_handle(device->handle, "_PS0", &temp);
1308 if (ACPI_FAILURE(status))
1309 status = acpi_get_handle(device->handle, "_PR0", &temp);
1310 if (ACPI_SUCCESS(status))
1311 device->flags.power_manageable = 1;
1313 /* TBD: Peformance management */
1321 struct acpi_device **child,
1322 struct acpi_device *parent,
1327 acpi_status status = AE_OK;
1328 struct acpi_device *device = NULL;
1329 char bus_id[5] = {'?',0};
1330 struct acpi_buffer buffer = {0, NULL};
1331 struct acpi_device_info *info;
1334 struct acpi_compatible_id_list *cid_list = NULL;
1337 ACPI_FUNCTION_TRACE("acpi_bus_add");
1340 return_VALUE(-EINVAL);
1342 device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL);
1344 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));
1345 return_VALUE(-ENOMEM);
1347 memset(device, 0, sizeof(struct acpi_device));
1349 device->handle = handle;
1350 device->parent = parent;
1355 * The device's Bus ID is simply the object name.
1356 * TBD: Shouldn't this value be unique (within the ACPI namespace)?
1359 case ACPI_BUS_TYPE_SYSTEM:
1360 sprintf(device->pnp.bus_id, "%s", "ACPI");
1362 case ACPI_BUS_TYPE_POWER_BUTTON:
1363 sprintf(device->pnp.bus_id, "%s", "PWRF");
1365 case ACPI_BUS_TYPE_SLEEP_BUTTON:
1366 sprintf(device->pnp.bus_id, "%s", "SLPF");
1369 buffer.length = sizeof(bus_id);
1370 buffer.pointer = bus_id;
1371 acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
1372 /* Clean up trailing underscores (if any) */
1373 for (i = 3; i > 1; i--) {
1374 if (bus_id[i] == '_')
1379 sprintf(device->pnp.bus_id, "%s", bus_id);
1380 buffer.pointer = NULL;
1387 * Get prior to calling acpi_bus_get_status() so we know whether
1388 * or not _STA is present. Note that we only look for object
1389 * handles -- cannot evaluate objects until we know the device is
1390 * present and properly initialized.
1392 result = acpi_bus_get_flags(device);
1399 * See if the device is present. We always assume that non-Device()
1400 * objects (e.g. thermal zones, power resources, processors, etc.) are
1401 * present, functioning, etc. (at least when parent object is present).
1402 * Note that _STA has a different meaning for some objects (e.g.
1403 * power resources) so we need to be careful how we use it.
1406 case ACPI_BUS_TYPE_DEVICE:
1407 result = acpi_bus_get_status(device);
1412 STRUCT_TO_INT(device->status) = 0x0F;
1415 if (!device->status.present) {
1423 * TBD: Synch with Core's enumeration/initialization process.
1427 * Hardware ID, Unique ID, & Bus Address
1428 * -------------------------------------
1431 case ACPI_BUS_TYPE_DEVICE:
1432 buffer.length = ACPI_ALLOCATE_BUFFER;
1433 buffer.pointer = NULL;
1434 status = acpi_get_object_info(handle, &buffer);
1435 if (ACPI_FAILURE(status)) {
1436 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1437 "Error reading device info\n"));
1441 info = buffer.pointer;
1442 if (info->valid & ACPI_VALID_HID)
1443 hid = info->hardware_id.value;
1444 if (info->valid & ACPI_VALID_UID)
1445 uid = info->unique_id.value;
1446 if (info->valid & ACPI_VALID_CID) {
1447 cid_list = &info->compatibility_id;
1448 device->pnp.cid_list = kmalloc(cid_list->size, GFP_KERNEL);
1449 if (device->pnp.cid_list)
1450 memcpy(device->pnp.cid_list, cid_list, cid_list->size);
1452 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));
1454 if (info->valid & ACPI_VALID_ADR) {
1455 device->pnp.bus_address = info->address;
1456 device->flags.bus_address = 1;
1459 case ACPI_BUS_TYPE_POWER:
1460 hid = ACPI_POWER_HID;
1462 case ACPI_BUS_TYPE_PROCESSOR:
1463 hid = ACPI_PROCESSOR_HID;
1465 case ACPI_BUS_TYPE_SYSTEM:
1466 hid = ACPI_SYSTEM_HID;
1468 case ACPI_BUS_TYPE_THERMAL:
1469 hid = ACPI_THERMAL_HID;
1471 case ACPI_BUS_TYPE_POWER_BUTTON:
1472 hid = ACPI_BUTTON_HID_POWERF;
1474 case ACPI_BUS_TYPE_SLEEP_BUTTON:
1475 hid = ACPI_BUTTON_HID_SLEEPF;
1482 * Fix for the system root bus device -- the only root-level device.
1484 if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) {
1486 sprintf(device->pnp.device_name, "%s", ACPI_BUS_DEVICE_NAME);
1487 sprintf(device->pnp.device_class, "%s", ACPI_BUS_CLASS);
1491 sprintf(device->pnp.hardware_id, "%s", hid);
1492 device->flags.hardware_id = 1;
1495 sprintf(device->pnp.unique_id, "%s", uid);
1496 device->flags.unique_id = 1;
1500 * If we called get_object_info, we now are finished with the buffer,
1501 * so we can free it.
1504 acpi_os_free(buffer.pointer);
1510 if (device->flags.power_manageable) {
1511 result = acpi_bus_get_power_flags(device);
1517 * Performance Management
1518 * ----------------------
1520 if (device->flags.performance_manageable) {
1521 result = acpi_bus_get_perf_flags(device);
1529 * Attach this 'struct acpi_device' to the ACPI object. This makes
1530 * resolutions from handle->device very efficient. Note that we need
1531 * to be careful with fixed-feature devices as they all attach to the
1535 case ACPI_BUS_TYPE_POWER_BUTTON:
1536 case ACPI_BUS_TYPE_SLEEP_BUTTON:
1539 status = acpi_attach_data(device->handle,
1540 acpi_bus_data_handler, device);
1543 if (ACPI_FAILURE(status)) {
1544 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1545 "Error attaching device data\n"));
1553 * Link this device to its parent and siblings.
1555 INIT_LIST_HEAD(&device->children);
1556 if (!device->parent)
1557 INIT_LIST_HEAD(&device->node);
1559 list_add_tail(&device->node, &device->parent->children);
1561 #ifdef CONFIG_ACPI_DEBUG
1563 char *type_string = NULL;
1564 char name[80] = {'?','\0'};
1565 struct acpi_buffer buffer = {sizeof(name), name};
1567 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
1570 case ACPI_BUS_TYPE_DEVICE:
1571 type_string = "Device";
1573 case ACPI_BUS_TYPE_POWER:
1574 type_string = "Power Resource";
1576 case ACPI_BUS_TYPE_PROCESSOR:
1577 type_string = "Processor";
1579 case ACPI_BUS_TYPE_SYSTEM:
1580 type_string = "System";
1582 case ACPI_BUS_TYPE_THERMAL:
1583 type_string = "Thermal Zone";
1585 case ACPI_BUS_TYPE_POWER_BUTTON:
1586 type_string = "Power Button";
1587 sprintf(name, "PWRB");
1589 case ACPI_BUS_TYPE_SLEEP_BUTTON:
1590 type_string = "Sleep Button";
1591 sprintf(name, "SLPB");
1595 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %s %s [%p]\n",
1596 type_string, name, handle));
1598 #endif /*CONFIG_ACPI_DEBUG*/
1601 * Global Device Hierarchy:
1602 * ------------------------
1603 * Register this device with the global device hierarchy.
1605 acpi_device_register(device, parent);
1608 * Bind _ADR-Based Devices
1609 * -----------------------
1610 * If there's a a bus address (_ADR) then we utilize the parent's
1611 * 'bind' function (if exists) to bind the ACPI- and natively-
1612 * enumerated device representations.
1614 if (device->flags.bus_address) {
1615 if (device->parent && device->parent->ops.bind)
1616 device->parent->ops.bind(device);
1620 * Locate & Attach Driver
1621 * ----------------------
1622 * If there's a hardware id (_HID) or compatible ids (_CID) we check
1623 * to see if there's a driver installed for this kind of device. Note
1624 * that drivers can install before or after a device is enumerated.
1626 * TBD: Assumes LDM provides driver hot-plug capability.
1628 if (device->flags.hardware_id || device->flags.compatible_ids)
1629 acpi_bus_find_driver(device);
1633 if (device->pnp.cid_list) {
1634 kfree(device->pnp.cid_list);
1637 return_VALUE(result);
1647 struct acpi_device *device,
1650 ACPI_FUNCTION_TRACE("acpi_bus_remove");
1653 return_VALUE(-ENODEV);
1655 acpi_device_unregister(device);
1658 if (device->pnp.cid_list)
1659 kfree(device->pnp.cid_list);
1669 struct acpi_device *start)
1671 acpi_status status = AE_OK;
1672 struct acpi_device *parent = NULL;
1673 struct acpi_device *child = NULL;
1674 acpi_handle phandle = 0;
1675 acpi_handle chandle = 0;
1676 acpi_object_type type = 0;
1679 ACPI_FUNCTION_TRACE("acpi_bus_scan");
1682 return_VALUE(-EINVAL);
1685 phandle = start->handle;
1688 * Parse through the ACPI namespace, identify all 'devices', and
1689 * create a new 'struct acpi_device' for each.
1691 while ((level > 0) && parent) {
1693 status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
1697 * If this scope is exhausted then move our way back up.
1699 if (ACPI_FAILURE(status)) {
1702 acpi_get_parent(phandle, &phandle);
1704 parent = parent->parent;
1708 status = acpi_get_type(chandle, &type);
1709 if (ACPI_FAILURE(status))
1713 * If this is a scope object then parse it (depth-first).
1715 if (type == ACPI_TYPE_LOCAL_SCOPE) {
1723 * We're only interested in objects that we consider 'devices'.
1726 case ACPI_TYPE_DEVICE:
1727 type = ACPI_BUS_TYPE_DEVICE;
1729 case ACPI_TYPE_PROCESSOR:
1730 type = ACPI_BUS_TYPE_PROCESSOR;
1732 case ACPI_TYPE_THERMAL:
1733 type = ACPI_BUS_TYPE_THERMAL;
1735 case ACPI_TYPE_POWER:
1736 type = ACPI_BUS_TYPE_POWER;
1742 status = acpi_bus_add(&child, parent, chandle, type);
1743 if (ACPI_FAILURE(status))
1747 * If the device is present, enabled, and functioning then
1748 * parse its scope (depth-first). Note that we need to
1749 * represent absent devices to facilitate PnP notifications
1750 * -- but only the subtree head (not all of its children,
1751 * which will be enumerated when the parent is inserted).
1753 * TBD: Need notifications and other detection mechanisms
1754 * in place before we can fully implement this.
1756 if (child->status.present) {
1757 status = acpi_get_next_object(ACPI_TYPE_ANY, chandle,
1759 if (ACPI_SUCCESS(status)) {
1773 acpi_bus_scan_fixed (
1774 struct acpi_device *root)
1777 struct acpi_device *device = NULL;
1779 ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed");
1782 return_VALUE(-ENODEV);
1785 * Enumerate all fixed-feature devices.
1787 if (acpi_fadt.pwr_button == 0)
1788 result = acpi_bus_add(&device, acpi_root,
1789 NULL, ACPI_BUS_TYPE_POWER_BUTTON);
1791 if (acpi_fadt.sleep_button == 0)
1792 result = acpi_bus_add(&device, acpi_root,
1793 NULL, ACPI_BUS_TYPE_SLEEP_BUTTON);
1795 return_VALUE(result);
1799 /* --------------------------------------------------------------------------
1800 Initialization/Cleanup
1801 -------------------------------------------------------------------------- */
1804 acpi_bus_init_irq (void)
1806 acpi_status status = AE_OK;
1807 union acpi_object arg = {ACPI_TYPE_INTEGER};
1808 struct acpi_object_list arg_list = {1, &arg};
1809 char *message = NULL;
1811 ACPI_FUNCTION_TRACE("acpi_bus_init_irq");
1814 * Let the system know what interrupt model we are using by
1815 * evaluating the \_PIC object, if exists.
1818 switch (acpi_irq_model) {
1819 case ACPI_IRQ_MODEL_PIC:
1822 case ACPI_IRQ_MODEL_IOAPIC:
1825 case ACPI_IRQ_MODEL_IOSAPIC:
1826 message = "IOSAPIC";
1829 printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n");
1830 return_VALUE(-ENODEV);
1833 printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);
1835 arg.integer.value = acpi_irq_model;
1837 status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL);
1838 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
1839 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PIC\n"));
1840 return_VALUE(-ENODEV);
1848 acpi_early_init (void)
1850 acpi_status status = AE_OK;
1851 struct acpi_buffer buffer = {sizeof(acpi_fadt), &acpi_fadt};
1853 ACPI_FUNCTION_TRACE("acpi_early_init");
1858 status = acpi_initialize_subsystem();
1859 if (ACPI_FAILURE(status)) {
1860 printk(KERN_ERR PREFIX "Unable to initialize the ACPI Interpreter\n");
1864 status = acpi_load_tables();
1865 if (ACPI_FAILURE(status)) {
1866 printk(KERN_ERR PREFIX "Unable to load the System Description Tables\n");
1871 * Get a separate copy of the FADT for use by other drivers.
1873 status = acpi_get_table(ACPI_TABLE_FADT, 1, &buffer);
1874 if (ACPI_FAILURE(status)) {
1875 printk(KERN_ERR PREFIX "Unable to get the FADT\n");
1881 extern acpi_interrupt_flags acpi_sci_flags;
1883 /* compatible (0) means level (3) */
1884 if (acpi_sci_flags.trigger == 0)
1885 acpi_sci_flags.trigger = 3;
1887 /* Set PIC-mode SCI trigger type */
1888 acpi_pic_sci_set_trigger(acpi_fadt.sci_int, acpi_sci_flags.trigger);
1890 extern int acpi_sci_override_gsi;
1892 * now that acpi_fadt is initialized,
1893 * update it with result from INT_SRC_OVR parsing
1895 acpi_fadt.sci_int = acpi_sci_override_gsi;
1899 status = acpi_enable_subsystem(~(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE));
1900 if (ACPI_FAILURE(status)) {
1901 printk(KERN_ERR PREFIX "Unable to enable ACPI\n");
1913 acpi_bus_init (void)
1916 acpi_status status = AE_OK;
1917 extern acpi_status acpi_os_initialize1(void);
1919 ACPI_FUNCTION_TRACE("acpi_bus_init");
1921 status = acpi_os_initialize1();
1923 status = acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE);
1924 if (ACPI_FAILURE(status)) {
1925 printk(KERN_ERR PREFIX "Unable to start the ACPI Interpreter\n");
1929 if (ACPI_FAILURE(status)) {
1930 printk(KERN_ERR PREFIX "Unable to initialize ACPI OS objects\n");
1933 #ifdef CONFIG_ACPI_EC
1935 * ACPI 2.0 requires the EC driver to be loaded and work before
1936 * the EC device is found in the namespace. This is accomplished
1937 * by looking for the ECDT table, and getting the EC parameters out
1940 result = acpi_ec_ecdt_probe();
1941 /* Ignore result. Not having an ECDT is not fatal. */
1944 status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
1945 if (ACPI_FAILURE(status)) {
1946 printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
1950 printk(KERN_INFO PREFIX "Interpreter enabled\n");
1953 * Get the system interrupt model and evaluate \_PIC.
1955 result = acpi_bus_init_irq();
1960 * Register the for all standard device notifications.
1962 status = acpi_install_notify_handler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, &acpi_bus_notify, NULL);
1963 if (ACPI_FAILURE(status)) {
1964 printk(KERN_ERR PREFIX "Unable to register for device notifications\n");
1970 * Create the root device in the bus's device tree
1972 result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT,
1973 ACPI_BUS_TYPE_SYSTEM);
1978 * Create the top ACPI proc directory
1980 acpi_device_dir(acpi_root) = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL);
1985 acpi_root_dir = acpi_device_dir(acpi_root);
1988 * Install drivers required for proper enumeration of the
1991 acpi_system_init(); /* ACPI System */
1992 acpi_power_init(); /* ACPI Bus Power Management */
1993 #ifdef CONFIG_ACPI_EC
1994 acpi_ec_init(); /* ACPI Embedded Controller */
1996 #ifdef CONFIG_ACPI_PCI
1997 if (!acpi_pci_disabled) {
1998 acpi_pci_link_init(); /* ACPI PCI Interrupt Link */
1999 acpi_pci_root_init(); /* ACPI PCI Root Bridge */
2003 * Enumerate devices in the ACPI namespace.
2005 result = acpi_bus_scan_fixed(acpi_root);
2008 result = acpi_bus_scan(acpi_root);
2012 acpi_motherboard_init();
2015 /* Mimic structured exception handling */
2017 remove_proc_entry(ACPI_BUS_FILE_ROOT, NULL);
2019 acpi_bus_remove(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
2021 acpi_remove_notify_handler(ACPI_ROOT_OBJECT,
2022 ACPI_SYSTEM_NOTIFY, &acpi_bus_notify);
2025 return_VALUE(-ENODEV);
2030 acpi_bus_exit (void)
2032 acpi_status status = AE_OK;
2034 ACPI_FUNCTION_TRACE("acpi_bus_exit");
2036 status = acpi_remove_notify_handler(ACPI_ROOT_OBJECT,
2037 ACPI_SYSTEM_NOTIFY, acpi_bus_notify);
2038 if (ACPI_FAILURE(status))
2039 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
2040 "Error removing notify handler\n"));
2042 #ifdef CONFIG_ACPI_PCI
2043 acpi_pci_root_exit();
2044 acpi_pci_link_exit();
2046 #ifdef CONFIG_ACPI_EC
2052 acpi_bus_remove(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
2054 remove_proc_entry(ACPI_BUS_FILE_ROOT, NULL);
2056 status = acpi_terminate();
2057 if (ACPI_FAILURE(status))
2058 printk(KERN_ERR PREFIX "Unable to terminate the ACPI Interpreter\n");
2060 printk(KERN_ERR PREFIX "Interpreter disabled\n");
2071 ACPI_FUNCTION_TRACE("acpi_init");
2073 printk(KERN_INFO PREFIX "Subsystem revision %08x\n",
2076 /* Initial core debug level excludes drivers, so include them now */
2077 acpi_set_debug(ACPI_DEBUG_LOW);
2079 if (acpi_disabled) {
2080 printk(KERN_INFO PREFIX "Interpreter disabled.\n");
2085 if (PM_IS_ACTIVE()) {
2086 printk(KERN_INFO PREFIX "APM is already active, exiting\n");
2091 result = acpi_bus_init();
2094 return_VALUE(result);
2108 ACPI_FUNCTION_TRACE("acpi_exit");