2 * scan.c - support for transforming the ACPI namespace into individual objects
5 #include <linux/module.h>
6 #include <linux/init.h>
7 #include <linux/slab.h>
8 #include <linux/kernel.h>
9 #include <linux/acpi.h>
10 #include <linux/signal.h>
11 #include <linux/kthread.h>
12 #include <linux/dmi.h>
13 #include <linux/nls.h>
15 #include <acpi/acpi_drivers.h>
19 #define _COMPONENT ACPI_BUS_COMPONENT
20 ACPI_MODULE_NAME("scan");
21 #define STRUCT_TO_INT(s) (*((int*)&s))
22 extern struct acpi_device
*acpi_root
;
24 #define ACPI_BUS_CLASS "system_bus"
25 #define ACPI_BUS_HID "LNXSYBUS"
26 #define ACPI_BUS_DEVICE_NAME "System Bus"
28 #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent)
30 static const char *dummy_hid
= "device";
32 static LIST_HEAD(acpi_device_list
);
33 static LIST_HEAD(acpi_bus_id_list
);
34 DEFINE_MUTEX(acpi_device_lock
);
35 LIST_HEAD(acpi_wakeup_device_list
);
37 struct acpi_device_bus_id
{
39 unsigned int instance_no
;
40 struct list_head node
;
44 * Creates hid/cid(s) string needed for modalias and uevent
45 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
46 * char *modalias: "acpi:IBM0001:ACPI0001"
48 static int create_modalias(struct acpi_device
*acpi_dev
, char *modalias
,
53 struct acpi_hardware_id
*id
;
55 if (list_empty(&acpi_dev
->pnp
.ids
))
58 len
= snprintf(modalias
, size
, "acpi:");
61 list_for_each_entry(id
, &acpi_dev
->pnp
.ids
, list
) {
62 count
= snprintf(&modalias
[len
], size
, "%s:", id
->id
);
63 if (count
< 0 || count
>= size
)
74 acpi_device_modalias_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
) {
75 struct acpi_device
*acpi_dev
= to_acpi_device(dev
);
78 /* Device has no HID and no CID or string is >1024 */
79 len
= create_modalias(acpi_dev
, buf
, 1024);
85 static DEVICE_ATTR(modalias
, 0444, acpi_device_modalias_show
, NULL
);
88 * acpi_bus_hot_remove_device: hot-remove a device and its children
89 * @context: struct acpi_eject_event pointer (freed in this func)
91 * Hot-remove a device and its children. This function frees up the
92 * memory space passed by arg context, so that the caller may call
93 * this function asynchronously through acpi_os_hotplug_execute().
95 void acpi_bus_hot_remove_device(void *context
)
97 struct acpi_eject_event
*ej_event
= (struct acpi_eject_event
*) context
;
98 struct acpi_device
*device
;
99 acpi_handle handle
= ej_event
->handle
;
101 struct acpi_object_list arg_list
;
102 union acpi_object arg
;
103 acpi_status status
= AE_OK
;
104 u32 ost_code
= ACPI_OST_SC_NON_SPECIFIC_FAILURE
; /* default */
106 if (acpi_bus_get_device(handle
, &device
))
112 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
113 "Hot-removing device %s...\n", dev_name(&device
->dev
)));
115 if (acpi_bus_trim(device
, 1)) {
116 printk(KERN_ERR PREFIX
117 "Removing device failed\n");
121 /* device has been freed */
124 /* power off device */
125 status
= acpi_evaluate_object(handle
, "_PS3", NULL
, NULL
);
126 if (ACPI_FAILURE(status
) && status
!= AE_NOT_FOUND
)
127 printk(KERN_WARNING PREFIX
128 "Power-off device failed\n");
130 if (ACPI_SUCCESS(acpi_get_handle(handle
, "_LCK", &temp
))) {
132 arg_list
.pointer
= &arg
;
133 arg
.type
= ACPI_TYPE_INTEGER
;
134 arg
.integer
.value
= 0;
135 acpi_evaluate_object(handle
, "_LCK", &arg_list
, NULL
);
139 arg_list
.pointer
= &arg
;
140 arg
.type
= ACPI_TYPE_INTEGER
;
141 arg
.integer
.value
= 1;
146 status
= acpi_evaluate_object(handle
, "_EJ0", &arg_list
, NULL
);
147 if (ACPI_FAILURE(status
)) {
148 if (status
!= AE_NOT_FOUND
)
149 printk(KERN_WARNING PREFIX
150 "Eject device failed\n");
158 /* Inform firmware the hot-remove operation has completed w/ error */
159 (void) acpi_evaluate_hotplug_ost(handle
,
160 ej_event
->event
, ost_code
, NULL
);
166 acpi_eject_store(struct device
*d
, struct device_attribute
*attr
,
167 const char *buf
, size_t count
)
171 acpi_object_type type
= 0;
172 struct acpi_device
*acpi_device
= to_acpi_device(d
);
173 struct acpi_eject_event
*ej_event
;
175 if ((!count
) || (buf
[0] != '1')) {
179 if (acpi_device
->driver
== NULL
) {
184 status
= acpi_get_type(acpi_device
->handle
, &type
);
185 if (ACPI_FAILURE(status
) || (!acpi_device
->flags
.ejectable
)) {
190 ej_event
= kmalloc(sizeof(*ej_event
), GFP_KERNEL
);
196 ej_event
->handle
= acpi_device
->handle
;
197 if (acpi_device
->flags
.eject_pending
) {
198 /* event originated from ACPI eject notification */
199 ej_event
->event
= ACPI_NOTIFY_EJECT_REQUEST
;
200 acpi_device
->flags
.eject_pending
= 0;
202 /* event originated from user */
203 ej_event
->event
= ACPI_OST_EC_OSPM_EJECT
;
204 (void) acpi_evaluate_hotplug_ost(ej_event
->handle
,
205 ej_event
->event
, ACPI_OST_SC_EJECT_IN_PROGRESS
, NULL
);
208 acpi_os_hotplug_execute(acpi_bus_hot_remove_device
, (void *)ej_event
);
213 static DEVICE_ATTR(eject
, 0200, NULL
, acpi_eject_store
);
216 acpi_device_hid_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
) {
217 struct acpi_device
*acpi_dev
= to_acpi_device(dev
);
219 return sprintf(buf
, "%s\n", acpi_device_hid(acpi_dev
));
221 static DEVICE_ATTR(hid
, 0444, acpi_device_hid_show
, NULL
);
224 acpi_device_path_show(struct device
*dev
, struct device_attribute
*attr
, char *buf
) {
225 struct acpi_device
*acpi_dev
= to_acpi_device(dev
);
226 struct acpi_buffer path
= {ACPI_ALLOCATE_BUFFER
, NULL
};
229 result
= acpi_get_name(acpi_dev
->handle
, ACPI_FULL_PATHNAME
, &path
);
233 result
= sprintf(buf
, "%s\n", (char*)path
.pointer
);
238 static DEVICE_ATTR(path
, 0444, acpi_device_path_show
, NULL
);
240 /* sysfs file that shows description text from the ACPI _STR method */
241 static ssize_t
description_show(struct device
*dev
,
242 struct device_attribute
*attr
,
244 struct acpi_device
*acpi_dev
= to_acpi_device(dev
);
247 if (acpi_dev
->pnp
.str_obj
== NULL
)
251 * The _STR object contains a Unicode identifier for a device.
252 * We need to convert to utf-8 so it can be displayed.
254 result
= utf16s_to_utf8s(
255 (wchar_t *)acpi_dev
->pnp
.str_obj
->buffer
.pointer
,
256 acpi_dev
->pnp
.str_obj
->buffer
.length
,
257 UTF16_LITTLE_ENDIAN
, buf
,
260 buf
[result
++] = '\n';
264 static DEVICE_ATTR(description
, 0444, description_show
, NULL
);
266 static int acpi_device_setup_files(struct acpi_device
*dev
)
268 struct acpi_buffer buffer
= {ACPI_ALLOCATE_BUFFER
, NULL
};
274 * Devices gotten from FADT don't have a "path" attribute
277 result
= device_create_file(&dev
->dev
, &dev_attr_path
);
282 if (!list_empty(&dev
->pnp
.ids
)) {
283 result
= device_create_file(&dev
->dev
, &dev_attr_hid
);
287 result
= device_create_file(&dev
->dev
, &dev_attr_modalias
);
293 * If device has _STR, 'description' file is created
295 status
= acpi_get_handle(dev
->handle
, "_STR", &temp
);
296 if (ACPI_SUCCESS(status
)) {
297 status
= acpi_evaluate_object(dev
->handle
, "_STR",
299 if (ACPI_FAILURE(status
))
300 buffer
.pointer
= NULL
;
301 dev
->pnp
.str_obj
= buffer
.pointer
;
302 result
= device_create_file(&dev
->dev
, &dev_attr_description
);
308 * If device has _EJ0, 'eject' file is created that is used to trigger
309 * hot-removal function from userland.
311 status
= acpi_get_handle(dev
->handle
, "_EJ0", &temp
);
312 if (ACPI_SUCCESS(status
))
313 result
= device_create_file(&dev
->dev
, &dev_attr_eject
);
318 static void acpi_device_remove_files(struct acpi_device
*dev
)
324 * If device has _STR, remove 'description' file
326 status
= acpi_get_handle(dev
->handle
, "_STR", &temp
);
327 if (ACPI_SUCCESS(status
)) {
328 kfree(dev
->pnp
.str_obj
);
329 device_remove_file(&dev
->dev
, &dev_attr_description
);
332 * If device has _EJ0, remove 'eject' file.
334 status
= acpi_get_handle(dev
->handle
, "_EJ0", &temp
);
335 if (ACPI_SUCCESS(status
))
336 device_remove_file(&dev
->dev
, &dev_attr_eject
);
338 device_remove_file(&dev
->dev
, &dev_attr_modalias
);
339 device_remove_file(&dev
->dev
, &dev_attr_hid
);
341 device_remove_file(&dev
->dev
, &dev_attr_path
);
343 /* --------------------------------------------------------------------------
345 -------------------------------------------------------------------------- */
347 int acpi_match_device_ids(struct acpi_device
*device
,
348 const struct acpi_device_id
*ids
)
350 const struct acpi_device_id
*id
;
351 struct acpi_hardware_id
*hwid
;
354 * If the device is not present, it is unnecessary to load device
357 if (!device
->status
.present
)
360 for (id
= ids
; id
->id
[0]; id
++)
361 list_for_each_entry(hwid
, &device
->pnp
.ids
, list
)
362 if (!strcmp((char *) id
->id
, hwid
->id
))
367 EXPORT_SYMBOL(acpi_match_device_ids
);
369 static void acpi_free_ids(struct acpi_device
*device
)
371 struct acpi_hardware_id
*id
, *tmp
;
373 list_for_each_entry_safe(id
, tmp
, &device
->pnp
.ids
, list
) {
379 static void acpi_device_release(struct device
*dev
)
381 struct acpi_device
*acpi_dev
= to_acpi_device(dev
);
383 acpi_free_ids(acpi_dev
);
387 static int acpi_bus_match(struct device
*dev
, struct device_driver
*drv
)
389 struct acpi_device
*acpi_dev
= to_acpi_device(dev
);
390 struct acpi_driver
*acpi_drv
= to_acpi_driver(drv
);
392 return !acpi_match_device_ids(acpi_dev
, acpi_drv
->ids
);
395 static int acpi_device_uevent(struct device
*dev
, struct kobj_uevent_env
*env
)
397 struct acpi_device
*acpi_dev
= to_acpi_device(dev
);
400 if (list_empty(&acpi_dev
->pnp
.ids
))
403 if (add_uevent_var(env
, "MODALIAS="))
405 len
= create_modalias(acpi_dev
, &env
->buf
[env
->buflen
- 1],
406 sizeof(env
->buf
) - env
->buflen
);
407 if (len
>= (sizeof(env
->buf
) - env
->buflen
))
413 static void acpi_device_notify(acpi_handle handle
, u32 event
, void *data
)
415 struct acpi_device
*device
= data
;
417 device
->driver
->ops
.notify(device
, event
);
420 static acpi_status
acpi_device_notify_fixed(void *data
)
422 struct acpi_device
*device
= data
;
424 /* Fixed hardware devices have no handles */
425 acpi_device_notify(NULL
, ACPI_FIXED_HARDWARE_EVENT
, device
);
429 static int acpi_device_install_notify_handler(struct acpi_device
*device
)
433 if (device
->device_type
== ACPI_BUS_TYPE_POWER_BUTTON
)
435 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON
,
436 acpi_device_notify_fixed
,
438 else if (device
->device_type
== ACPI_BUS_TYPE_SLEEP_BUTTON
)
440 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON
,
441 acpi_device_notify_fixed
,
444 status
= acpi_install_notify_handler(device
->handle
,
449 if (ACPI_FAILURE(status
))
454 static void acpi_device_remove_notify_handler(struct acpi_device
*device
)
456 if (device
->device_type
== ACPI_BUS_TYPE_POWER_BUTTON
)
457 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON
,
458 acpi_device_notify_fixed
);
459 else if (device
->device_type
== ACPI_BUS_TYPE_SLEEP_BUTTON
)
460 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON
,
461 acpi_device_notify_fixed
);
463 acpi_remove_notify_handler(device
->handle
, ACPI_DEVICE_NOTIFY
,
467 static int acpi_bus_driver_init(struct acpi_device
*, struct acpi_driver
*);
468 static int acpi_start_single_object(struct acpi_device
*);
469 static int acpi_device_probe(struct device
* dev
)
471 struct acpi_device
*acpi_dev
= to_acpi_device(dev
);
472 struct acpi_driver
*acpi_drv
= to_acpi_driver(dev
->driver
);
475 ret
= acpi_bus_driver_init(acpi_dev
, acpi_drv
);
477 if (acpi_dev
->bus_ops
.acpi_op_start
)
478 acpi_start_single_object(acpi_dev
);
480 if (acpi_drv
->ops
.notify
) {
481 ret
= acpi_device_install_notify_handler(acpi_dev
);
483 if (acpi_drv
->ops
.remove
)
484 acpi_drv
->ops
.remove(acpi_dev
,
485 acpi_dev
->removal_type
);
490 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
491 "Found driver [%s] for device [%s]\n",
492 acpi_drv
->name
, acpi_dev
->pnp
.bus_id
));
498 static int acpi_device_remove(struct device
* dev
)
500 struct acpi_device
*acpi_dev
= to_acpi_device(dev
);
501 struct acpi_driver
*acpi_drv
= acpi_dev
->driver
;
504 if (acpi_drv
->ops
.notify
)
505 acpi_device_remove_notify_handler(acpi_dev
);
506 if (acpi_drv
->ops
.remove
)
507 acpi_drv
->ops
.remove(acpi_dev
, acpi_dev
->removal_type
);
509 acpi_dev
->driver
= NULL
;
510 acpi_dev
->driver_data
= NULL
;
516 struct bus_type acpi_bus_type
= {
518 .match
= acpi_bus_match
,
519 .probe
= acpi_device_probe
,
520 .remove
= acpi_device_remove
,
521 .uevent
= acpi_device_uevent
,
524 static int acpi_device_register(struct acpi_device
*device
)
527 struct acpi_device_bus_id
*acpi_device_bus_id
, *new_bus_id
;
533 * Link this device to its parent and siblings.
535 INIT_LIST_HEAD(&device
->children
);
536 INIT_LIST_HEAD(&device
->node
);
537 INIT_LIST_HEAD(&device
->wakeup_list
);
538 INIT_LIST_HEAD(&device
->physical_node_list
);
539 mutex_init(&device
->physical_node_lock
);
541 new_bus_id
= kzalloc(sizeof(struct acpi_device_bus_id
), GFP_KERNEL
);
543 printk(KERN_ERR PREFIX
"Memory allocation error\n");
547 mutex_lock(&acpi_device_lock
);
549 * Find suitable bus_id and instance number in acpi_bus_id_list
550 * If failed, create one and link it into acpi_bus_id_list
552 list_for_each_entry(acpi_device_bus_id
, &acpi_bus_id_list
, node
) {
553 if (!strcmp(acpi_device_bus_id
->bus_id
,
554 acpi_device_hid(device
))) {
555 acpi_device_bus_id
->instance_no
++;
562 acpi_device_bus_id
= new_bus_id
;
563 strcpy(acpi_device_bus_id
->bus_id
, acpi_device_hid(device
));
564 acpi_device_bus_id
->instance_no
= 0;
565 list_add_tail(&acpi_device_bus_id
->node
, &acpi_bus_id_list
);
567 dev_set_name(&device
->dev
, "%s:%02x", acpi_device_bus_id
->bus_id
, acpi_device_bus_id
->instance_no
);
570 list_add_tail(&device
->node
, &device
->parent
->children
);
572 if (device
->wakeup
.flags
.valid
)
573 list_add_tail(&device
->wakeup_list
, &acpi_wakeup_device_list
);
574 mutex_unlock(&acpi_device_lock
);
577 device
->dev
.parent
= &device
->parent
->dev
;
578 device
->dev
.bus
= &acpi_bus_type
;
579 device
->dev
.release
= &acpi_device_release
;
580 result
= device_register(&device
->dev
);
582 dev_err(&device
->dev
, "Error registering device\n");
586 result
= acpi_device_setup_files(device
);
588 printk(KERN_ERR PREFIX
"Error creating sysfs interface for device %s\n",
589 dev_name(&device
->dev
));
591 device
->removal_type
= ACPI_BUS_REMOVAL_NORMAL
;
594 mutex_lock(&acpi_device_lock
);
596 list_del(&device
->node
);
597 list_del(&device
->wakeup_list
);
598 mutex_unlock(&acpi_device_lock
);
602 static void acpi_device_unregister(struct acpi_device
*device
, int type
)
604 mutex_lock(&acpi_device_lock
);
606 list_del(&device
->node
);
608 list_del(&device
->wakeup_list
);
609 mutex_unlock(&acpi_device_lock
);
611 acpi_detach_data(device
->handle
, acpi_bus_data_handler
);
613 acpi_device_remove_files(device
);
614 device_unregister(&device
->dev
);
617 /* --------------------------------------------------------------------------
619 -------------------------------------------------------------------------- */
621 * acpi_bus_driver_init - add a device to a driver
622 * @device: the device to add and initialize
623 * @driver: driver for the device
625 * Used to initialize a device via its device driver. Called whenever a
626 * driver is bound to a device. Invokes the driver's add() ops.
629 acpi_bus_driver_init(struct acpi_device
*device
, struct acpi_driver
*driver
)
633 if (!device
|| !driver
)
636 if (!driver
->ops
.add
)
639 result
= driver
->ops
.add(device
);
641 device
->driver
= NULL
;
642 device
->driver_data
= NULL
;
646 device
->driver
= driver
;
649 * TBD - Configuration Management: Assign resources to device based
650 * upon possible configuration and currently allocated resources.
653 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
654 "Driver successfully bound to device\n"));
658 static int acpi_start_single_object(struct acpi_device
*device
)
661 struct acpi_driver
*driver
;
664 if (!(driver
= device
->driver
))
667 if (driver
->ops
.start
) {
668 result
= driver
->ops
.start(device
);
669 if (result
&& driver
->ops
.remove
)
670 driver
->ops
.remove(device
, ACPI_BUS_REMOVAL_NORMAL
);
677 * acpi_bus_register_driver - register a driver with the ACPI bus
678 * @driver: driver being registered
680 * Registers a driver with the ACPI bus. Searches the namespace for all
681 * devices that match the driver's criteria and binds. Returns zero for
682 * success or a negative error status for failure.
684 int acpi_bus_register_driver(struct acpi_driver
*driver
)
690 driver
->drv
.name
= driver
->name
;
691 driver
->drv
.bus
= &acpi_bus_type
;
692 driver
->drv
.owner
= driver
->owner
;
694 ret
= driver_register(&driver
->drv
);
698 EXPORT_SYMBOL(acpi_bus_register_driver
);
701 * acpi_bus_unregister_driver - unregisters a driver with the APIC bus
702 * @driver: driver to unregister
704 * Unregisters a driver with the ACPI bus. Searches the namespace for all
705 * devices that match the driver's criteria and unbinds.
707 void acpi_bus_unregister_driver(struct acpi_driver
*driver
)
709 driver_unregister(&driver
->drv
);
712 EXPORT_SYMBOL(acpi_bus_unregister_driver
);
714 /* --------------------------------------------------------------------------
716 -------------------------------------------------------------------------- */
717 static struct acpi_device
*acpi_bus_get_parent(acpi_handle handle
)
721 struct acpi_device
*device
;
724 * Fixed hardware devices do not appear in the namespace and do not
725 * have handles, but we fabricate acpi_devices for them, so we have
726 * to deal with them specially.
732 status
= acpi_get_parent(handle
, &handle
);
733 if (status
== AE_NULL_ENTRY
)
735 if (ACPI_FAILURE(status
))
738 ret
= acpi_bus_get_device(handle
, &device
);
745 acpi_bus_get_ejd(acpi_handle handle
, acpi_handle
*ejd
)
749 struct acpi_buffer buffer
= {ACPI_ALLOCATE_BUFFER
, NULL
};
750 union acpi_object
*obj
;
752 status
= acpi_get_handle(handle
, "_EJD", &tmp
);
753 if (ACPI_FAILURE(status
))
756 status
= acpi_evaluate_object(handle
, "_EJD", NULL
, &buffer
);
757 if (ACPI_SUCCESS(status
)) {
758 obj
= buffer
.pointer
;
759 status
= acpi_get_handle(ACPI_ROOT_OBJECT
, obj
->string
.pointer
,
761 kfree(buffer
.pointer
);
765 EXPORT_SYMBOL_GPL(acpi_bus_get_ejd
);
767 void acpi_bus_data_handler(acpi_handle handle
, void *context
)
775 static int acpi_bus_get_perf_flags(struct acpi_device
*device
)
777 device
->performance
.state
= ACPI_STATE_UNKNOWN
;
782 acpi_bus_extract_wakeup_device_power_package(acpi_handle handle
,
783 struct acpi_device_wakeup
*wakeup
)
785 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
786 union acpi_object
*package
= NULL
;
787 union acpi_object
*element
= NULL
;
792 return AE_BAD_PARAMETER
;
795 status
= acpi_evaluate_object(handle
, "_PRW", NULL
, &buffer
);
796 if (ACPI_FAILURE(status
)) {
797 ACPI_EXCEPTION((AE_INFO
, status
, "Evaluating _PRW"));
801 package
= (union acpi_object
*)buffer
.pointer
;
803 if (!package
|| (package
->package
.count
< 2)) {
804 status
= AE_BAD_DATA
;
808 element
= &(package
->package
.elements
[0]);
810 status
= AE_BAD_DATA
;
813 if (element
->type
== ACPI_TYPE_PACKAGE
) {
814 if ((element
->package
.count
< 2) ||
815 (element
->package
.elements
[0].type
!=
816 ACPI_TYPE_LOCAL_REFERENCE
)
817 || (element
->package
.elements
[1].type
!= ACPI_TYPE_INTEGER
)) {
818 status
= AE_BAD_DATA
;
822 element
->package
.elements
[0].reference
.handle
;
824 (u32
) element
->package
.elements
[1].integer
.value
;
825 } else if (element
->type
== ACPI_TYPE_INTEGER
) {
826 wakeup
->gpe_device
= NULL
;
827 wakeup
->gpe_number
= element
->integer
.value
;
829 status
= AE_BAD_DATA
;
833 element
= &(package
->package
.elements
[1]);
834 if (element
->type
!= ACPI_TYPE_INTEGER
) {
835 status
= AE_BAD_DATA
;
838 wakeup
->sleep_state
= element
->integer
.value
;
840 if ((package
->package
.count
- 2) > ACPI_MAX_HANDLES
) {
841 status
= AE_NO_MEMORY
;
844 wakeup
->resources
.count
= package
->package
.count
- 2;
845 for (i
= 0; i
< wakeup
->resources
.count
; i
++) {
846 element
= &(package
->package
.elements
[i
+ 2]);
847 if (element
->type
!= ACPI_TYPE_LOCAL_REFERENCE
) {
848 status
= AE_BAD_DATA
;
852 wakeup
->resources
.handles
[i
] = element
->reference
.handle
;
855 acpi_setup_gpe_for_wake(handle
, wakeup
->gpe_device
, wakeup
->gpe_number
);
858 kfree(buffer
.pointer
);
863 static void acpi_bus_set_run_wake_flags(struct acpi_device
*device
)
865 struct acpi_device_id button_device_ids
[] = {
872 acpi_event_status event_status
;
874 device
->wakeup
.flags
.notifier_present
= 0;
876 /* Power button, Lid switch always enable wakeup */
877 if (!acpi_match_device_ids(device
, button_device_ids
)) {
878 device
->wakeup
.flags
.run_wake
= 1;
879 device_set_wakeup_capable(&device
->dev
, true);
883 status
= acpi_get_gpe_status(device
->wakeup
.gpe_device
,
884 device
->wakeup
.gpe_number
,
887 device
->wakeup
.flags
.run_wake
=
888 !!(event_status
& ACPI_EVENT_FLAG_HANDLE
);
891 static void acpi_bus_get_wakeup_device_flags(struct acpi_device
*device
)
894 acpi_status status
= 0;
897 /* Presence of _PRW indicates wake capable */
898 status
= acpi_get_handle(device
->handle
, "_PRW", &temp
);
899 if (ACPI_FAILURE(status
))
902 status
= acpi_bus_extract_wakeup_device_power_package(device
->handle
,
904 if (ACPI_FAILURE(status
)) {
905 ACPI_EXCEPTION((AE_INFO
, status
, "Extracting _PRW package"));
909 device
->wakeup
.flags
.valid
= 1;
910 device
->wakeup
.prepare_count
= 0;
911 acpi_bus_set_run_wake_flags(device
);
912 /* Call _PSW/_DSW object to disable its ability to wake the sleeping
913 * system for the ACPI device with the _PRW object.
914 * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
915 * So it is necessary to call _DSW object first. Only when it is not
916 * present will the _PSW object used.
918 psw_error
= acpi_device_sleep_wake(device
, 0, 0, 0);
920 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
921 "error in _DSW or _PSW evaluation\n"));
924 static void acpi_bus_add_power_resource(acpi_handle handle
);
926 static int acpi_bus_get_power_flags(struct acpi_device
*device
)
928 acpi_status status
= 0;
929 acpi_handle handle
= NULL
;
934 * Power Management Flags
936 status
= acpi_get_handle(device
->handle
, "_PSC", &handle
);
937 if (ACPI_SUCCESS(status
))
938 device
->power
.flags
.explicit_get
= 1;
939 status
= acpi_get_handle(device
->handle
, "_IRC", &handle
);
940 if (ACPI_SUCCESS(status
))
941 device
->power
.flags
.inrush_current
= 1;
944 * Enumerate supported power management states
946 for (i
= ACPI_STATE_D0
; i
<= ACPI_STATE_D3_HOT
; i
++) {
947 struct acpi_device_power_state
*ps
= &device
->power
.states
[i
];
948 char object_name
[5] = { '_', 'P', 'R', '0' + i
, '\0' };
950 /* Evaluate "_PRx" to se if power resources are referenced */
951 acpi_evaluate_reference(device
->handle
, object_name
, NULL
,
953 if (ps
->resources
.count
) {
956 device
->power
.flags
.power_resources
= 1;
957 for (j
= 0; j
< ps
->resources
.count
; j
++)
958 acpi_bus_add_power_resource(ps
->resources
.handles
[j
]);
961 /* Evaluate "_PSx" to see if we can do explicit sets */
962 object_name
[2] = 'S';
963 status
= acpi_get_handle(device
->handle
, object_name
, &handle
);
964 if (ACPI_SUCCESS(status
))
965 ps
->flags
.explicit_set
= 1;
968 * State is valid if there are means to put the device into it.
969 * D3hot is only valid if _PR3 present.
971 if (ps
->resources
.count
||
972 (ps
->flags
.explicit_set
&& i
< ACPI_STATE_D3_HOT
))
975 ps
->power
= -1; /* Unknown - driver assigned */
976 ps
->latency
= -1; /* Unknown - driver assigned */
979 /* Set defaults for D0 and D3 states (always valid) */
980 device
->power
.states
[ACPI_STATE_D0
].flags
.valid
= 1;
981 device
->power
.states
[ACPI_STATE_D0
].power
= 100;
982 device
->power
.states
[ACPI_STATE_D3
].flags
.valid
= 1;
983 device
->power
.states
[ACPI_STATE_D3
].power
= 0;
985 /* Set D3cold's explicit_set flag if _PS3 exists. */
986 if (device
->power
.states
[ACPI_STATE_D3_HOT
].flags
.explicit_set
)
987 device
->power
.states
[ACPI_STATE_D3_COLD
].flags
.explicit_set
= 1;
989 acpi_bus_init_power(device
);
994 static int acpi_bus_get_flags(struct acpi_device
*device
)
996 acpi_status status
= AE_OK
;
997 acpi_handle temp
= NULL
;
1000 /* Presence of _STA indicates 'dynamic_status' */
1001 status
= acpi_get_handle(device
->handle
, "_STA", &temp
);
1002 if (ACPI_SUCCESS(status
))
1003 device
->flags
.dynamic_status
= 1;
1005 /* Presence of _RMV indicates 'removable' */
1006 status
= acpi_get_handle(device
->handle
, "_RMV", &temp
);
1007 if (ACPI_SUCCESS(status
))
1008 device
->flags
.removable
= 1;
1010 /* Presence of _EJD|_EJ0 indicates 'ejectable' */
1011 status
= acpi_get_handle(device
->handle
, "_EJD", &temp
);
1012 if (ACPI_SUCCESS(status
))
1013 device
->flags
.ejectable
= 1;
1015 status
= acpi_get_handle(device
->handle
, "_EJ0", &temp
);
1016 if (ACPI_SUCCESS(status
))
1017 device
->flags
.ejectable
= 1;
1020 /* Power resources cannot be power manageable. */
1021 if (device
->device_type
== ACPI_BUS_TYPE_POWER
)
1024 /* Presence of _PS0|_PR0 indicates 'power manageable' */
1025 status
= acpi_get_handle(device
->handle
, "_PS0", &temp
);
1026 if (ACPI_FAILURE(status
))
1027 status
= acpi_get_handle(device
->handle
, "_PR0", &temp
);
1028 if (ACPI_SUCCESS(status
))
1029 device
->flags
.power_manageable
= 1;
1031 /* TBD: Performance management */
1036 static void acpi_device_get_busid(struct acpi_device
*device
)
1038 char bus_id
[5] = { '?', 0 };
1039 struct acpi_buffer buffer
= { sizeof(bus_id
), bus_id
};
1045 * The device's Bus ID is simply the object name.
1046 * TBD: Shouldn't this value be unique (within the ACPI namespace)?
1048 if (ACPI_IS_ROOT_DEVICE(device
)) {
1049 strcpy(device
->pnp
.bus_id
, "ACPI");
1053 switch (device
->device_type
) {
1054 case ACPI_BUS_TYPE_POWER_BUTTON
:
1055 strcpy(device
->pnp
.bus_id
, "PWRF");
1057 case ACPI_BUS_TYPE_SLEEP_BUTTON
:
1058 strcpy(device
->pnp
.bus_id
, "SLPF");
1061 acpi_get_name(device
->handle
, ACPI_SINGLE_NAME
, &buffer
);
1062 /* Clean up trailing underscores (if any) */
1063 for (i
= 3; i
> 1; i
--) {
1064 if (bus_id
[i
] == '_')
1069 strcpy(device
->pnp
.bus_id
, bus_id
);
1075 * acpi_bay_match - see if a device is an ejectable driver bay
1077 * If an acpi object is ejectable and has one of the ACPI ATA methods defined,
1078 * then we can safely call it an ejectable drive bay
1080 static int acpi_bay_match(struct acpi_device
*device
){
1084 acpi_handle phandle
;
1086 handle
= device
->handle
;
1088 status
= acpi_get_handle(handle
, "_EJ0", &tmp
);
1089 if (ACPI_FAILURE(status
))
1092 if ((ACPI_SUCCESS(acpi_get_handle(handle
, "_GTF", &tmp
))) ||
1093 (ACPI_SUCCESS(acpi_get_handle(handle
, "_GTM", &tmp
))) ||
1094 (ACPI_SUCCESS(acpi_get_handle(handle
, "_STM", &tmp
))) ||
1095 (ACPI_SUCCESS(acpi_get_handle(handle
, "_SDD", &tmp
))))
1098 if (acpi_get_parent(handle
, &phandle
))
1101 if ((ACPI_SUCCESS(acpi_get_handle(phandle
, "_GTF", &tmp
))) ||
1102 (ACPI_SUCCESS(acpi_get_handle(phandle
, "_GTM", &tmp
))) ||
1103 (ACPI_SUCCESS(acpi_get_handle(phandle
, "_STM", &tmp
))) ||
1104 (ACPI_SUCCESS(acpi_get_handle(phandle
, "_SDD", &tmp
))))
1111 * acpi_dock_match - see if a device has a _DCK method
1113 static int acpi_dock_match(struct acpi_device
*device
)
1116 return acpi_get_handle(device
->handle
, "_DCK", &tmp
);
1119 const char *acpi_device_hid(struct acpi_device
*device
)
1121 struct acpi_hardware_id
*hid
;
1123 if (list_empty(&device
->pnp
.ids
))
1126 hid
= list_first_entry(&device
->pnp
.ids
, struct acpi_hardware_id
, list
);
1129 EXPORT_SYMBOL(acpi_device_hid
);
1131 static void acpi_add_id(struct acpi_device
*device
, const char *dev_id
)
1133 struct acpi_hardware_id
*id
;
1135 id
= kmalloc(sizeof(*id
), GFP_KERNEL
);
1139 id
->id
= kstrdup(dev_id
, GFP_KERNEL
);
1145 list_add_tail(&id
->list
, &device
->pnp
.ids
);
1149 * Old IBM workstations have a DSDT bug wherein the SMBus object
1150 * lacks the SMBUS01 HID and the methods do not have the necessary "_"
1151 * prefix. Work around this.
1153 static int acpi_ibm_smbus_match(struct acpi_device
*device
)
1155 acpi_handle h_dummy
;
1156 struct acpi_buffer path
= {ACPI_ALLOCATE_BUFFER
, NULL
};
1159 if (!dmi_name_in_vendors("IBM"))
1162 /* Look for SMBS object */
1163 result
= acpi_get_name(device
->handle
, ACPI_SINGLE_NAME
, &path
);
1167 if (strcmp("SMBS", path
.pointer
)) {
1172 /* Does it have the necessary (but misnamed) methods? */
1174 if (ACPI_SUCCESS(acpi_get_handle(device
->handle
, "SBI", &h_dummy
)) &&
1175 ACPI_SUCCESS(acpi_get_handle(device
->handle
, "SBR", &h_dummy
)) &&
1176 ACPI_SUCCESS(acpi_get_handle(device
->handle
, "SBW", &h_dummy
)))
1179 kfree(path
.pointer
);
1183 static void acpi_device_set_id(struct acpi_device
*device
)
1186 struct acpi_device_info
*info
;
1187 struct acpica_device_id_list
*cid_list
;
1190 switch (device
->device_type
) {
1191 case ACPI_BUS_TYPE_DEVICE
:
1192 if (ACPI_IS_ROOT_DEVICE(device
)) {
1193 acpi_add_id(device
, ACPI_SYSTEM_HID
);
1197 status
= acpi_get_object_info(device
->handle
, &info
);
1198 if (ACPI_FAILURE(status
)) {
1199 printk(KERN_ERR PREFIX
"%s: Error reading device info\n", __func__
);
1203 if (info
->valid
& ACPI_VALID_HID
)
1204 acpi_add_id(device
, info
->hardware_id
.string
);
1205 if (info
->valid
& ACPI_VALID_CID
) {
1206 cid_list
= &info
->compatible_id_list
;
1207 for (i
= 0; i
< cid_list
->count
; i
++)
1208 acpi_add_id(device
, cid_list
->ids
[i
].string
);
1210 if (info
->valid
& ACPI_VALID_ADR
) {
1211 device
->pnp
.bus_address
= info
->address
;
1212 device
->flags
.bus_address
= 1;
1218 * Some devices don't reliably have _HIDs & _CIDs, so add
1219 * synthetic HIDs to make sure drivers can find them.
1221 if (acpi_is_video_device(device
))
1222 acpi_add_id(device
, ACPI_VIDEO_HID
);
1223 else if (ACPI_SUCCESS(acpi_bay_match(device
)))
1224 acpi_add_id(device
, ACPI_BAY_HID
);
1225 else if (ACPI_SUCCESS(acpi_dock_match(device
)))
1226 acpi_add_id(device
, ACPI_DOCK_HID
);
1227 else if (!acpi_ibm_smbus_match(device
))
1228 acpi_add_id(device
, ACPI_SMBUS_IBM_HID
);
1229 else if (!acpi_device_hid(device
) &&
1230 ACPI_IS_ROOT_DEVICE(device
->parent
)) {
1231 acpi_add_id(device
, ACPI_BUS_HID
); /* \_SB, LNXSYBUS */
1232 strcpy(device
->pnp
.device_name
, ACPI_BUS_DEVICE_NAME
);
1233 strcpy(device
->pnp
.device_class
, ACPI_BUS_CLASS
);
1237 case ACPI_BUS_TYPE_POWER
:
1238 acpi_add_id(device
, ACPI_POWER_HID
);
1240 case ACPI_BUS_TYPE_PROCESSOR
:
1241 acpi_add_id(device
, ACPI_PROCESSOR_OBJECT_HID
);
1243 case ACPI_BUS_TYPE_THERMAL
:
1244 acpi_add_id(device
, ACPI_THERMAL_HID
);
1246 case ACPI_BUS_TYPE_POWER_BUTTON
:
1247 acpi_add_id(device
, ACPI_BUTTON_HID_POWERF
);
1249 case ACPI_BUS_TYPE_SLEEP_BUTTON
:
1250 acpi_add_id(device
, ACPI_BUTTON_HID_SLEEPF
);
1255 static int acpi_device_set_context(struct acpi_device
*device
)
1262 * Attach this 'struct acpi_device' to the ACPI object. This makes
1263 * resolutions from handle->device very efficient. Fixed hardware
1264 * devices have no handles, so we skip them.
1266 if (!device
->handle
)
1269 status
= acpi_attach_data(device
->handle
,
1270 acpi_bus_data_handler
, device
);
1271 if (ACPI_SUCCESS(status
))
1274 printk(KERN_ERR PREFIX
"Error attaching device data\n");
1278 static int acpi_bus_remove(struct acpi_device
*dev
, int rmdevice
)
1283 dev
->removal_type
= ACPI_BUS_REMOVAL_EJECT
;
1284 device_release_driver(&dev
->dev
);
1290 * unbind _ADR-Based Devices when hot removal
1292 if (dev
->flags
.bus_address
) {
1293 if ((dev
->parent
) && (dev
->parent
->ops
.unbind
))
1294 dev
->parent
->ops
.unbind(dev
);
1296 acpi_device_unregister(dev
, ACPI_BUS_REMOVAL_EJECT
);
1301 static int acpi_add_single_object(struct acpi_device
**child
,
1302 acpi_handle handle
, int type
,
1303 unsigned long long sta
,
1304 struct acpi_bus_ops
*ops
)
1307 struct acpi_device
*device
;
1308 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
1310 device
= kzalloc(sizeof(struct acpi_device
), GFP_KERNEL
);
1312 printk(KERN_ERR PREFIX
"Memory allocation error\n");
1316 INIT_LIST_HEAD(&device
->pnp
.ids
);
1317 device
->device_type
= type
;
1318 device
->handle
= handle
;
1319 device
->parent
= acpi_bus_get_parent(handle
);
1320 device
->bus_ops
= *ops
; /* workround for not call .start */
1321 STRUCT_TO_INT(device
->status
) = sta
;
1323 acpi_device_get_busid(device
);
1328 * Note that we only look for object handles -- cannot evaluate objects
1329 * until we know the device is present and properly initialized.
1331 result
= acpi_bus_get_flags(device
);
1338 * TBD: Synch with Core's enumeration/initialization process.
1340 acpi_device_set_id(device
);
1346 if (device
->flags
.power_manageable
) {
1347 result
= acpi_bus_get_power_flags(device
);
1353 * Wakeup device management
1354 *-----------------------
1356 acpi_bus_get_wakeup_device_flags(device
);
1359 * Performance Management
1360 * ----------------------
1362 if (device
->flags
.performance_manageable
) {
1363 result
= acpi_bus_get_perf_flags(device
);
1368 if ((result
= acpi_device_set_context(device
)))
1371 result
= acpi_device_register(device
);
1374 * Bind _ADR-Based Devices when hot add
1376 if (device
->flags
.bus_address
) {
1377 if (device
->parent
&& device
->parent
->ops
.bind
)
1378 device
->parent
->ops
.bind(device
);
1383 acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
);
1384 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
1385 "Adding %s [%s] parent %s\n", dev_name(&device
->dev
),
1386 (char *) buffer
.pointer
,
1387 device
->parent
? dev_name(&device
->parent
->dev
) :
1389 kfree(buffer
.pointer
);
1392 acpi_device_release(&device
->dev
);
1397 #define ACPI_STA_DEFAULT (ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | \
1398 ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING)
1400 static void acpi_bus_add_power_resource(acpi_handle handle
)
1402 struct acpi_bus_ops ops
= {
1406 struct acpi_device
*device
= NULL
;
1408 acpi_bus_get_device(handle
, &device
);
1410 acpi_add_single_object(&device
, handle
, ACPI_BUS_TYPE_POWER
,
1411 ACPI_STA_DEFAULT
, &ops
);
1414 static int acpi_bus_type_and_status(acpi_handle handle
, int *type
,
1415 unsigned long long *sta
)
1418 acpi_object_type acpi_type
;
1420 status
= acpi_get_type(handle
, &acpi_type
);
1421 if (ACPI_FAILURE(status
))
1424 switch (acpi_type
) {
1425 case ACPI_TYPE_ANY
: /* for ACPI_ROOT_OBJECT */
1426 case ACPI_TYPE_DEVICE
:
1427 *type
= ACPI_BUS_TYPE_DEVICE
;
1428 status
= acpi_bus_get_status_handle(handle
, sta
);
1429 if (ACPI_FAILURE(status
))
1432 case ACPI_TYPE_PROCESSOR
:
1433 *type
= ACPI_BUS_TYPE_PROCESSOR
;
1434 status
= acpi_bus_get_status_handle(handle
, sta
);
1435 if (ACPI_FAILURE(status
))
1438 case ACPI_TYPE_THERMAL
:
1439 *type
= ACPI_BUS_TYPE_THERMAL
;
1440 *sta
= ACPI_STA_DEFAULT
;
1442 case ACPI_TYPE_POWER
:
1443 *type
= ACPI_BUS_TYPE_POWER
;
1444 *sta
= ACPI_STA_DEFAULT
;
1453 static acpi_status
acpi_bus_check_add(acpi_handle handle
, u32 lvl
,
1454 void *context
, void **return_value
)
1456 struct acpi_bus_ops
*ops
= context
;
1458 unsigned long long sta
;
1459 struct acpi_device
*device
;
1463 result
= acpi_bus_type_and_status(handle
, &type
, &sta
);
1467 if (!(sta
& ACPI_STA_DEVICE_PRESENT
) &&
1468 !(sta
& ACPI_STA_DEVICE_FUNCTIONING
)) {
1469 struct acpi_device_wakeup wakeup
;
1472 status
= acpi_get_handle(handle
, "_PRW", &temp
);
1473 if (ACPI_SUCCESS(status
))
1474 acpi_bus_extract_wakeup_device_power_package(handle
,
1476 return AE_CTRL_DEPTH
;
1480 * We may already have an acpi_device from a previous enumeration. If
1481 * so, we needn't add it again, but we may still have to start it.
1484 acpi_bus_get_device(handle
, &device
);
1485 if (ops
->acpi_op_add
&& !device
)
1486 acpi_add_single_object(&device
, handle
, type
, sta
, ops
);
1489 return AE_CTRL_DEPTH
;
1491 if (ops
->acpi_op_start
&& !(ops
->acpi_op_add
)) {
1492 status
= acpi_start_single_object(device
);
1493 if (ACPI_FAILURE(status
))
1494 return AE_CTRL_DEPTH
;
1498 *return_value
= device
;
1502 static int acpi_bus_scan(acpi_handle handle
, struct acpi_bus_ops
*ops
,
1503 struct acpi_device
**child
)
1506 void *device
= NULL
;
1508 status
= acpi_bus_check_add(handle
, 0, ops
, &device
);
1509 if (ACPI_SUCCESS(status
))
1510 acpi_walk_namespace(ACPI_TYPE_ANY
, handle
, ACPI_UINT32_MAX
,
1511 acpi_bus_check_add
, NULL
, ops
, &device
);
1523 * acpi_bus_add and acpi_bus_start
1525 * scan a given ACPI tree and (probably recently hot-plugged)
1526 * create and add or starts found devices.
1528 * If no devices were found -ENODEV is returned which does not
1529 * mean that this is a real error, there just have been no suitable
1530 * ACPI objects in the table trunk from which the kernel could create
1531 * a device and add/start an appropriate driver.
1535 acpi_bus_add(struct acpi_device
**child
,
1536 struct acpi_device
*parent
, acpi_handle handle
, int type
)
1538 struct acpi_bus_ops ops
;
1540 memset(&ops
, 0, sizeof(ops
));
1541 ops
.acpi_op_add
= 1;
1543 return acpi_bus_scan(handle
, &ops
, child
);
1545 EXPORT_SYMBOL(acpi_bus_add
);
1547 int acpi_bus_start(struct acpi_device
*device
)
1549 struct acpi_bus_ops ops
;
1555 memset(&ops
, 0, sizeof(ops
));
1556 ops
.acpi_op_start
= 1;
1558 result
= acpi_bus_scan(device
->handle
, &ops
, NULL
);
1560 acpi_update_all_gpes();
1564 EXPORT_SYMBOL(acpi_bus_start
);
1566 int acpi_bus_trim(struct acpi_device
*start
, int rmdevice
)
1569 struct acpi_device
*parent
, *child
;
1570 acpi_handle phandle
, chandle
;
1571 acpi_object_type type
;
1576 phandle
= start
->handle
;
1577 child
= chandle
= NULL
;
1579 while ((level
> 0) && parent
&& (!err
)) {
1580 status
= acpi_get_next_object(ACPI_TYPE_ANY
, phandle
,
1584 * If this scope is exhausted then move our way back up.
1586 if (ACPI_FAILURE(status
)) {
1589 acpi_get_parent(phandle
, &phandle
);
1591 parent
= parent
->parent
;
1594 err
= acpi_bus_remove(child
, rmdevice
);
1596 err
= acpi_bus_remove(child
, 1);
1601 status
= acpi_get_type(chandle
, &type
);
1602 if (ACPI_FAILURE(status
)) {
1606 * If there is a device corresponding to chandle then
1607 * parse it (depth-first).
1609 if (acpi_bus_get_device(chandle
, &child
) == 0) {
1619 EXPORT_SYMBOL_GPL(acpi_bus_trim
);
1621 static int acpi_bus_scan_fixed(void)
1624 struct acpi_device
*device
= NULL
;
1625 struct acpi_bus_ops ops
;
1627 memset(&ops
, 0, sizeof(ops
));
1628 ops
.acpi_op_add
= 1;
1629 ops
.acpi_op_start
= 1;
1632 * Enumerate all fixed-feature devices.
1634 if ((acpi_gbl_FADT
.flags
& ACPI_FADT_POWER_BUTTON
) == 0) {
1635 result
= acpi_add_single_object(&device
, NULL
,
1636 ACPI_BUS_TYPE_POWER_BUTTON
,
1639 device_init_wakeup(&device
->dev
, true);
1642 if ((acpi_gbl_FADT
.flags
& ACPI_FADT_SLEEP_BUTTON
) == 0) {
1643 result
= acpi_add_single_object(&device
, NULL
,
1644 ACPI_BUS_TYPE_SLEEP_BUTTON
,
1652 int __init
acpi_scan_init(void)
1655 struct acpi_bus_ops ops
;
1657 memset(&ops
, 0, sizeof(ops
));
1658 ops
.acpi_op_add
= 1;
1659 ops
.acpi_op_start
= 1;
1661 result
= bus_register(&acpi_bus_type
);
1663 /* We don't want to quit even if we failed to add suspend/resume */
1664 printk(KERN_ERR PREFIX
"Could not register bus type\n");
1670 * Enumerate devices in the ACPI namespace.
1672 result
= acpi_bus_scan(ACPI_ROOT_OBJECT
, &ops
, &acpi_root
);
1675 result
= acpi_bus_scan_fixed();
1678 acpi_device_unregister(acpi_root
, ACPI_BUS_REMOVAL_NORMAL
);
1680 acpi_update_all_gpes();