2 * scan.c - support for transforming the ACPI namespace into individual objects
5 #include <linux/init.h>
6 #include <linux/acpi.h>
8 #include "acpi_drivers.h"
9 #include "include/acinterp.h" /* for acpi_ex_eisa_id_to_string() */
12 #define _COMPONENT ACPI_BUS_COMPONENT
13 ACPI_MODULE_NAME ("scan")
15 #define STRUCT_TO_INT(s) (*((int*)&s))
17 extern struct acpi_device
*acpi_root
;
20 #define ACPI_BUS_CLASS "system_bus"
21 #define ACPI_BUS_HID "ACPI_BUS"
22 #define ACPI_BUS_DRIVER_NAME "ACPI Bus Driver"
23 #define ACPI_BUS_DEVICE_NAME "System Bus"
25 static LIST_HEAD(acpi_device_list
);
26 static spinlock_t acpi_device_lock
= SPIN_LOCK_UNLOCKED
;
28 static void acpi_device_release(struct kobject
* kobj
)
30 struct acpi_device
* dev
= container_of(kobj
,struct acpi_device
,kobj
);
34 static struct kobj_type ktype_acpi_ns
= {
35 .release
= acpi_device_release
,
38 static struct kset acpi_namespace_kset
= {
42 .subsys
= &acpi_subsys
,
43 .ktype
= &ktype_acpi_ns
,
47 static void acpi_device_register(struct acpi_device
* device
, struct acpi_device
* parent
)
52 * Link this device to its parent and siblings.
54 INIT_LIST_HEAD(&device
->children
);
55 INIT_LIST_HEAD(&device
->node
);
56 INIT_LIST_HEAD(&device
->g_list
);
58 spin_lock(&acpi_device_lock
);
60 list_add_tail(&device
->node
, &device
->parent
->children
);
61 list_add_tail(&device
->g_list
,&device
->parent
->g_list
);
63 list_add_tail(&device
->g_list
,&acpi_device_list
);
64 spin_unlock(&acpi_device_lock
);
66 kobject_init(&device
->kobj
);
67 strncpy(device
->kobj
.name
,device
->pnp
.bus_id
,KOBJ_NAME_LEN
);
69 device
->kobj
.parent
= &parent
->kobj
;
70 device
->kobj
.ktype
= &ktype_acpi_ns
;
71 device
->kobj
.kset
= &acpi_namespace_kset
;
72 kobject_register(&device
->kobj
);
76 acpi_device_unregister (
77 struct acpi_device
*device
,
80 kobject_unregister(&device
->kobj
);
85 acpi_bus_data_handler (
90 ACPI_FUNCTION_TRACE("acpi_bus_data_handler");
98 acpi_bus_get_power_flags (
99 struct acpi_device
*device
)
101 acpi_status status
= 0;
102 acpi_handle handle
= 0;
105 ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags");
108 * Power Management Flags
110 status
= acpi_get_handle(device
->handle
, "_PSC", &handle
);
111 if (ACPI_SUCCESS(status
))
112 device
->power
.flags
.explicit_get
= 1;
113 status
= acpi_get_handle(device
->handle
, "_IRC", &handle
);
114 if (ACPI_SUCCESS(status
))
115 device
->power
.flags
.inrush_current
= 1;
116 status
= acpi_get_handle(device
->handle
, "_PRW", &handle
);
117 if (ACPI_SUCCESS(status
))
118 device
->power
.flags
.wake_capable
= 1;
121 * Enumerate supported power management states
123 for (i
= ACPI_STATE_D0
; i
<= ACPI_STATE_D3
; i
++) {
124 struct acpi_device_power_state
*ps
= &device
->power
.states
[i
];
125 char object_name
[5] = {'_','P','R','0'+i
,'\0'};
127 /* Evaluate "_PRx" to se if power resources are referenced */
128 acpi_evaluate_reference(device
->handle
, object_name
, NULL
,
130 if (ps
->resources
.count
) {
131 device
->power
.flags
.power_resources
= 1;
135 /* Evaluate "_PSx" to see if we can do explicit sets */
136 object_name
[2] = 'S';
137 status
= acpi_get_handle(device
->handle
, object_name
, &handle
);
138 if (ACPI_SUCCESS(status
)) {
139 ps
->flags
.explicit_set
= 1;
143 /* State is valid if we have some power control */
144 if (ps
->resources
.count
|| ps
->flags
.explicit_set
)
147 ps
->power
= -1; /* Unknown - driver assigned */
148 ps
->latency
= -1; /* Unknown - driver assigned */
151 /* Set defaults for D0 and D3 states (always valid) */
152 device
->power
.states
[ACPI_STATE_D0
].flags
.valid
= 1;
153 device
->power
.states
[ACPI_STATE_D0
].power
= 100;
154 device
->power
.states
[ACPI_STATE_D3
].flags
.valid
= 1;
155 device
->power
.states
[ACPI_STATE_D3
].power
= 0;
157 /* TBD: System wake support and resource requirements. */
159 device
->power
.state
= ACPI_STATE_UNKNOWN
;
165 /* --------------------------------------------------------------------------
166 Performance Management
167 -------------------------------------------------------------------------- */
170 acpi_bus_get_perf_flags (
171 struct acpi_device
*device
)
173 device
->performance
.state
= ACPI_STATE_UNKNOWN
;
177 /* --------------------------------------------------------------------------
179 -------------------------------------------------------------------------- */
181 static LIST_HEAD(acpi_bus_drivers
);
182 static DECLARE_MUTEX(acpi_bus_drivers_lock
);
188 * Checks the device's hardware (_HID) or compatible (_CID) ids to see if it
189 * matches the specified driver's criteria.
193 struct acpi_device
*device
,
194 struct acpi_driver
*driver
)
197 struct acpi_buffer buffer
= {ACPI_ALLOCATE_BUFFER
, NULL
};
199 if (device
->flags
.hardware_id
)
200 if (strstr(driver
->ids
, device
->pnp
.hardware_id
))
203 if (device
->flags
.compatible_ids
) {
204 acpi_status status
= AE_OK
;
205 union acpi_object
*object
= NULL
;
208 status
= acpi_evaluate_object(device
->handle
, "_CID", NULL
,
210 if (ACPI_FAILURE(status
) || !buffer
.pointer
)
213 object
= (union acpi_object
*) buffer
.pointer
;
215 switch (object
->type
) {
216 case ACPI_TYPE_INTEGER
:
217 acpi_ex_eisa_id_to_string((u32
) object
->integer
.value
,
220 case ACPI_TYPE_STRING
:
221 strncpy(cid
, object
->string
.pointer
, sizeof(cid
) - 1);
223 case ACPI_TYPE_PACKAGE
:
224 /* TBD: Support CID packages */
228 if (strlen(cid
) && strstr(driver
->ids
,cid
))
235 acpi_os_free(buffer
.pointer
);
241 * acpi_bus_driver_init
242 * --------------------
243 * Used to initialize a device via its device driver. Called whenever a
244 * driver is bound to a device. Invokes the driver's add() and start() ops.
247 acpi_bus_driver_init (
248 struct acpi_device
*device
,
249 struct acpi_driver
*driver
)
253 ACPI_FUNCTION_TRACE("acpi_bus_driver_init");
255 if (!device
|| !driver
)
256 return_VALUE(-EINVAL
);
258 if (!driver
->ops
.add
)
259 return_VALUE(-ENOSYS
);
261 result
= driver
->ops
.add(device
);
263 device
->driver
= NULL
;
264 acpi_driver_data(device
) = NULL
;
265 return_VALUE(result
);
268 device
->driver
= driver
;
271 * TBD - Configuration Management: Assign resources to device based
272 * upon possible configuration and currently allocated resources.
275 if (driver
->ops
.start
) {
276 result
= driver
->ops
.start(device
);
277 if (result
&& driver
->ops
.remove
)
278 driver
->ops
.remove(device
, ACPI_BUS_REMOVAL_NORMAL
);
279 return_VALUE(result
);
282 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Driver successfully bound to device\n"));
284 if (driver
->ops
.scan
) {
285 driver
->ops
.scan(device
);
291 static int acpi_driver_attach(struct acpi_driver
* drv
)
293 struct list_head
* node
, * next
;
295 ACPI_FUNCTION_TRACE("acpi_driver_attach");
297 spin_lock(&acpi_device_lock
);
298 list_for_each_safe(node
,next
,&acpi_device_list
) {
299 struct acpi_device
* dev
= container_of(node
,struct acpi_device
,g_list
);
301 if (dev
->driver
|| !dev
->status
.present
)
303 spin_unlock(&acpi_device_lock
);
305 if (!acpi_bus_match(dev
,drv
)) {
306 if (!acpi_bus_driver_init(dev
,drv
)) {
307 atomic_inc(&drv
->references
);
308 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Found driver [%s] for device [%s]\n",
309 drv
->name
, dev
->pnp
.bus_id
));
312 spin_lock(&acpi_device_lock
);
314 spin_unlock(&acpi_device_lock
);
318 static int acpi_driver_detach(struct acpi_driver
* drv
)
320 struct list_head
* node
, * next
;
322 ACPI_FUNCTION_TRACE("acpi_driver_detach");
324 spin_lock(&acpi_device_lock
);
325 list_for_each_safe(node
,next
,&acpi_device_list
) {
326 struct acpi_device
* dev
= container_of(node
,struct acpi_device
,g_list
);
328 if (dev
->driver
== drv
) {
330 drv
->ops
.remove(dev
,ACPI_BUS_REMOVAL_NORMAL
);
332 dev
->driver_data
= NULL
;
333 atomic_dec(&drv
->references
);
336 spin_unlock(&acpi_device_lock
);
341 * acpi_bus_register_driver
342 * ------------------------
343 * Registers a driver with the ACPI bus. Searches the namespace for all
344 * devices that match the driver's criteria and binds.
347 acpi_bus_register_driver (
348 struct acpi_driver
*driver
)
352 ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
355 spin_lock(&acpi_device_lock
);
356 list_add_tail(&driver
->node
, &acpi_bus_drivers
);
357 spin_unlock(&acpi_device_lock
);
358 acpi_driver_attach(driver
);
367 * acpi_bus_unregister_driver
368 * --------------------------
369 * Unregisters a driver with the ACPI bus. Searches the namespace for all
370 * devices that match the driver's criteria and unbinds.
373 acpi_bus_unregister_driver (
374 struct acpi_driver
*driver
)
378 ACPI_FUNCTION_TRACE("acpi_bus_unregister_driver");
381 acpi_driver_detach(driver
);
383 if (!atomic_read(&driver
->references
)) {
384 spin_lock(&acpi_device_lock
);
385 list_del_init(&driver
->node
);
386 spin_unlock(&acpi_device_lock
);
394 * acpi_bus_find_driver
395 * --------------------
396 * Parses the list of registered drivers looking for a driver applicable for
397 * the specified device.
400 acpi_bus_find_driver (
401 struct acpi_device
*device
)
404 struct list_head
* node
, *next
;
406 ACPI_FUNCTION_TRACE("acpi_bus_find_driver");
408 if (!device
->flags
.hardware_id
&& !device
->flags
.compatible_ids
)
411 spin_lock(&acpi_device_lock
);
412 list_for_each_safe(node
,next
,&acpi_bus_drivers
) {
413 struct acpi_driver
* driver
= container_of(node
,struct acpi_driver
,node
);
415 atomic_inc(&driver
->references
);
416 spin_unlock(&acpi_device_lock
);
417 if (!acpi_bus_match(device
, driver
)) {
418 result
= acpi_bus_driver_init(device
, driver
);
422 atomic_dec(&driver
->references
);
423 spin_lock(&acpi_device_lock
);
425 spin_unlock(&acpi_device_lock
);
428 return_VALUE(result
);
432 /* --------------------------------------------------------------------------
434 -------------------------------------------------------------------------- */
438 struct acpi_device
*device
)
440 acpi_status status
= AE_OK
;
441 acpi_handle temp
= NULL
;
443 ACPI_FUNCTION_TRACE("acpi_bus_get_flags");
445 /* Presence of _STA indicates 'dynamic_status' */
446 status
= acpi_get_handle(device
->handle
, "_STA", &temp
);
447 if (ACPI_SUCCESS(status
))
448 device
->flags
.dynamic_status
= 1;
450 /* Presence of _CID indicates 'compatible_ids' */
451 status
= acpi_get_handle(device
->handle
, "_CID", &temp
);
452 if (ACPI_SUCCESS(status
))
453 device
->flags
.compatible_ids
= 1;
455 /* Presence of _RMV indicates 'removable' */
456 status
= acpi_get_handle(device
->handle
, "_RMV", &temp
);
457 if (ACPI_SUCCESS(status
))
458 device
->flags
.removable
= 1;
460 /* Presence of _EJD|_EJ0 indicates 'ejectable' */
461 status
= acpi_get_handle(device
->handle
, "_EJD", &temp
);
462 if (ACPI_SUCCESS(status
))
463 device
->flags
.ejectable
= 1;
465 status
= acpi_get_handle(device
->handle
, "_EJ0", &temp
);
466 if (ACPI_SUCCESS(status
))
467 device
->flags
.ejectable
= 1;
470 /* Presence of _LCK indicates 'lockable' */
471 status
= acpi_get_handle(device
->handle
, "_LCK", &temp
);
472 if (ACPI_SUCCESS(status
))
473 device
->flags
.lockable
= 1;
475 /* Presence of _PS0|_PR0 indicates 'power manageable' */
476 status
= acpi_get_handle(device
->handle
, "_PS0", &temp
);
477 if (ACPI_FAILURE(status
))
478 status
= acpi_get_handle(device
->handle
, "_PR0", &temp
);
479 if (ACPI_SUCCESS(status
))
480 device
->flags
.power_manageable
= 1;
482 /* TBD: Peformance management */
487 static void acpi_device_get_busid(struct acpi_device
* device
, acpi_handle handle
, int type
)
489 char bus_id
[5] = {'?',0};
490 struct acpi_buffer buffer
= {sizeof(bus_id
), bus_id
};
496 * The device's Bus ID is simply the object name.
497 * TBD: Shouldn't this value be unique (within the ACPI namespace)?
500 case ACPI_BUS_TYPE_SYSTEM
:
501 sprintf(device
->pnp
.bus_id
, "%s", "ACPI");
503 case ACPI_BUS_TYPE_POWER_BUTTON
:
504 sprintf(device
->pnp
.bus_id
, "%s", "PWRF");
506 case ACPI_BUS_TYPE_SLEEP_BUTTON
:
507 sprintf(device
->pnp
.bus_id
, "%s", "SLPF");
510 acpi_get_name(handle
, ACPI_SINGLE_NAME
, &buffer
);
511 /* Clean up trailing underscores (if any) */
512 for (i
= 3; i
> 1; i
--) {
513 if (bus_id
[i
] == '_')
518 sprintf(device
->pnp
.bus_id
, "%s", bus_id
);
523 static void acpi_device_set_id(struct acpi_device
* device
, struct acpi_device
* parent
,
524 acpi_handle handle
, int type
)
526 struct acpi_device_info info
;
532 case ACPI_BUS_TYPE_DEVICE
:
533 status
= acpi_get_object_info(handle
, &info
);
534 if (ACPI_FAILURE(status
)) {
535 printk("%s: Error reading device info\n",__FUNCTION__
);
538 /* Clean up info strings (not NULL terminated) */
539 info
.hardware_id
[sizeof(info
.hardware_id
)-1] = '\0';
540 info
.unique_id
[sizeof(info
.unique_id
)-1] = '\0';
541 if (info
.valid
& ACPI_VALID_HID
)
542 hid
= info
.hardware_id
;
543 if (info
.valid
& ACPI_VALID_UID
)
544 uid
= info
.unique_id
;
545 if (info
.valid
& ACPI_VALID_ADR
) {
546 device
->pnp
.bus_address
= info
.address
;
547 device
->flags
.bus_address
= 1;
550 case ACPI_BUS_TYPE_POWER
:
551 hid
= ACPI_POWER_HID
;
553 case ACPI_BUS_TYPE_PROCESSOR
:
554 hid
= ACPI_PROCESSOR_HID
;
556 case ACPI_BUS_TYPE_SYSTEM
:
557 hid
= ACPI_SYSTEM_HID
;
559 case ACPI_BUS_TYPE_THERMAL
:
560 hid
= ACPI_THERMAL_HID
;
562 case ACPI_BUS_TYPE_POWER_BUTTON
:
563 hid
= ACPI_BUTTON_HID_POWERF
;
565 case ACPI_BUS_TYPE_SLEEP_BUTTON
:
566 hid
= ACPI_BUTTON_HID_SLEEPF
;
573 * Fix for the system root bus device -- the only root-level device.
575 if ((parent
== ACPI_ROOT_OBJECT
) && (type
== ACPI_BUS_TYPE_DEVICE
)) {
577 sprintf(device
->pnp
.device_name
, "%s", ACPI_BUS_DEVICE_NAME
);
578 sprintf(device
->pnp
.device_class
, "%s", ACPI_BUS_CLASS
);
582 sprintf(device
->pnp
.hardware_id
, "%s", hid
);
583 device
->flags
.hardware_id
= 1;
586 sprintf(device
->pnp
.unique_id
, "%s", uid
);
587 device
->flags
.unique_id
= 1;
591 int acpi_device_set_context(struct acpi_device
* device
, int type
)
593 acpi_status status
= AE_OK
;
598 * Attach this 'struct acpi_device' to the ACPI object. This makes
599 * resolutions from handle->device very efficient. Note that we need
600 * to be careful with fixed-feature devices as they all attach to the
603 if (type
!= ACPI_BUS_TYPE_POWER_BUTTON
&&
604 type
!= ACPI_BUS_TYPE_SLEEP_BUTTON
) {
605 status
= acpi_attach_data(device
->handle
,
606 acpi_bus_data_handler
, device
);
608 if (ACPI_FAILURE(status
)) {
609 printk("Error attaching device data\n");
616 void acpi_device_get_debug_info(struct acpi_device
* device
, acpi_handle handle
, int type
)
618 #ifdef CONFIG_ACPI_DEBUG_OUTPUT
619 char *type_string
= NULL
;
620 char name
[80] = {'?','\0'};
621 acpi_buffer buffer
= {sizeof(name
), name
};
624 case ACPI_BUS_TYPE_DEVICE
:
625 type_string
= "Device";
626 acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
);
628 case ACPI_BUS_TYPE_POWER
:
629 type_string
= "Power Resource";
630 acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
);
632 case ACPI_BUS_TYPE_PROCESSOR
:
633 type_string
= "Processor";
634 acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
);
636 case ACPI_BUS_TYPE_SYSTEM
:
637 type_string
= "System";
638 acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
);
640 case ACPI_BUS_TYPE_THERMAL
:
641 type_string
= "Thermal Zone";
642 acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
);
644 case ACPI_BUS_TYPE_POWER_BUTTON
:
645 type_string
= "Power Button";
646 sprintf(name
, "PWRB");
648 case ACPI_BUS_TYPE_SLEEP_BUTTON
:
649 type_string
= "Sleep Button";
650 sprintf(name
, "SLPB");
654 printk(KERN_DEBUG
"Found %s %s [%p]\n", type_string
, name
, handle
);
655 #endif /*CONFIG_ACPI_DEBUG_OUTPUT*/
660 struct acpi_device
**child
,
661 struct acpi_device
*parent
,
666 struct acpi_device
*device
= NULL
;
668 ACPI_FUNCTION_TRACE("acpi_bus_add");
671 return_VALUE(-EINVAL
);
673 device
= kmalloc(sizeof(struct acpi_device
), GFP_KERNEL
);
675 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Memory allocation error\n"));
676 return_VALUE(-ENOMEM
);
678 memset(device
, 0, sizeof(struct acpi_device
));
680 device
->handle
= handle
;
681 device
->parent
= parent
;
683 acpi_device_get_busid(device
,handle
,type
);
688 * Get prior to calling acpi_bus_get_status() so we know whether
689 * or not _STA is present. Note that we only look for object
690 * handles -- cannot evaluate objects until we know the device is
691 * present and properly initialized.
693 result
= acpi_bus_get_flags(device
);
700 * See if the device is present. We always assume that non-Device()
701 * objects (e.g. thermal zones, power resources, processors, etc.) are
702 * present, functioning, etc. (at least when parent object is present).
703 * Note that _STA has a different meaning for some objects (e.g.
704 * power resources) so we need to be careful how we use it.
707 case ACPI_BUS_TYPE_DEVICE
:
708 result
= acpi_bus_get_status(device
);
711 if (!device
->status
.present
)
715 STRUCT_TO_INT(device
->status
) = 0x0F;
722 * TBD: Synch with Core's enumeration/initialization process.
726 * Hardware ID, Unique ID, & Bus Address
727 * -------------------------------------
729 acpi_device_set_id(device
,parent
,handle
,type
);
735 if (device
->flags
.power_manageable
) {
736 result
= acpi_bus_get_power_flags(device
);
742 * Performance Management
743 * ----------------------
745 if (device
->flags
.performance_manageable
) {
746 result
= acpi_bus_get_perf_flags(device
);
751 if ((result
= acpi_device_set_context(device
,type
)))
754 acpi_device_get_debug_info(device
,handle
,type
);
756 acpi_device_register(device
,parent
);
759 * Bind _ADR-Based Devices
760 * -----------------------
761 * If there's a a bus address (_ADR) then we utilize the parent's
762 * 'bind' function (if exists) to bind the ACPI- and natively-
763 * enumerated device representations.
765 if (device
->flags
.bus_address
) {
766 if (device
->parent
&& device
->parent
->ops
.bind
)
767 device
->parent
->ops
.bind(device
);
771 * Locate & Attach Driver
772 * ----------------------
773 * If there's a hardware id (_HID) or compatible ids (_CID) we check
774 * to see if there's a driver installed for this kind of device. Note
775 * that drivers can install before or after a device is enumerated.
777 * TBD: Assumes LDM provides driver hot-plug capability.
779 acpi_bus_find_driver(device
);
786 return_VALUE(result
);
791 static int acpi_bus_scan (struct acpi_device
*start
)
793 acpi_status status
= AE_OK
;
794 struct acpi_device
*parent
= NULL
;
795 struct acpi_device
*child
= NULL
;
796 acpi_handle phandle
= 0;
797 acpi_handle chandle
= 0;
798 acpi_object_type type
= 0;
801 ACPI_FUNCTION_TRACE("acpi_bus_scan");
804 return_VALUE(-EINVAL
);
807 phandle
= start
->handle
;
810 * Parse through the ACPI namespace, identify all 'devices', and
811 * create a new 'struct acpi_device' for each.
813 while ((level
> 0) && parent
) {
815 status
= acpi_get_next_object(ACPI_TYPE_ANY
, phandle
,
819 * If this scope is exhausted then move our way back up.
821 if (ACPI_FAILURE(status
)) {
824 acpi_get_parent(phandle
, &phandle
);
826 parent
= parent
->parent
;
830 status
= acpi_get_type(chandle
, &type
);
831 if (ACPI_FAILURE(status
))
835 * If this is a scope object then parse it (depth-first).
837 if (type
== ACPI_TYPE_LOCAL_SCOPE
) {
845 * We're only interested in objects that we consider 'devices'.
848 case ACPI_TYPE_DEVICE
:
849 type
= ACPI_BUS_TYPE_DEVICE
;
851 case ACPI_TYPE_PROCESSOR
:
852 type
= ACPI_BUS_TYPE_PROCESSOR
;
854 case ACPI_TYPE_THERMAL
:
855 type
= ACPI_BUS_TYPE_THERMAL
;
857 case ACPI_TYPE_POWER
:
858 type
= ACPI_BUS_TYPE_POWER
;
864 status
= acpi_bus_add(&child
, parent
, chandle
, type
);
865 if (ACPI_FAILURE(status
))
869 * If the device is present, enabled, and functioning then
870 * parse its scope (depth-first). Note that we need to
871 * represent absent devices to facilitate PnP notifications
872 * -- but only the subtree head (not all of its children,
873 * which will be enumerated when the parent is inserted).
875 * TBD: Need notifications and other detection mechanisms
876 * in place before we can fully implement this.
878 if (child
->status
.present
) {
879 status
= acpi_get_next_object(ACPI_TYPE_ANY
, chandle
,
881 if (ACPI_SUCCESS(status
)) {
895 acpi_bus_scan_fixed (
896 struct acpi_device
*root
)
899 struct acpi_device
*device
= NULL
;
901 ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed");
904 return_VALUE(-ENODEV
);
907 * Enumerate all fixed-feature devices.
909 if (acpi_fadt
.pwr_button
== 0)
910 result
= acpi_bus_add(&device
, acpi_root
,
911 NULL
, ACPI_BUS_TYPE_POWER_BUTTON
);
913 if (acpi_fadt
.sleep_button
== 0)
914 result
= acpi_bus_add(&device
, acpi_root
,
915 NULL
, ACPI_BUS_TYPE_SLEEP_BUTTON
);
917 return_VALUE(result
);
921 static int __init
acpi_scan_init(void)
925 ACPI_FUNCTION_TRACE("acpi_scan_init");
930 kset_register(&acpi_namespace_kset
);
933 * Create the root device in the bus's device tree
935 result
= acpi_bus_add(&acpi_root
, NULL
, ACPI_ROOT_OBJECT
,
936 ACPI_BUS_TYPE_SYSTEM
);
941 * Enumerate devices in the ACPI namespace.
943 result
= acpi_bus_scan_fixed(acpi_root
);
945 result
= acpi_bus_scan(acpi_root
);
948 acpi_device_unregister(acpi_root
, ACPI_BUS_REMOVAL_NORMAL
);
951 return_VALUE(result
);
954 subsys_initcall(acpi_scan_init
);