Lines Matching refs:device
31 #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent)
35 static const char *dummy_hid = "device";
47 * The UART device described by the SPCR table is the only object which needs
144 struct acpi_device *device = NULL;
149 if (acpi_bus_get_device(handle, &device))
152 if (device->handler && !device->handler->hotplug.enabled) {
153 *ret_p = &device->dev;
157 mutex_lock(&device->physical_node_lock);
159 list_for_each_entry(pn, &device->physical_node_list, node) {
181 mutex_unlock(&device->physical_node_lock);
189 struct acpi_device *device = NULL;
192 if (acpi_bus_get_device(handle, &device))
195 mutex_lock(&device->physical_node_lock);
197 list_for_each_entry(pn, &device->physical_node_list, node)
203 mutex_unlock(&device->physical_node_lock);
208 static int acpi_scan_try_to_offline(struct acpi_device *device)
210 acpi_handle handle = device->handle;
211 struct device *errdev = NULL;
254 static int acpi_scan_hot_remove(struct acpi_device *device)
256 acpi_handle handle = device->handle;
260 if (device->handler && device->handler->hotplug.demand_offline) {
261 if (!acpi_scan_is_offline(device, true))
264 int error = acpi_scan_try_to_offline(device);
270 "Hot-removing device %s...\n", dev_name(&device->dev)));
272 acpi_bus_trim(device);
317 * This function is only called for device objects for which
319 * the scan handler is not attached to this device object yet
320 * is when the device has just appeared (either it wasn't
399 * The device object's ACPI handle cannot become invalid as long as we
417 * There may be additional notify handlers for device objects
449 static void acpi_free_power_resources_lists(struct acpi_device *device)
453 if (device->wakeup.flags.valid)
454 acpi_power_resources_list_free(&device->wakeup.resources);
456 if (!device->power.flags.power_resources)
460 struct acpi_device_power_state *ps = &device->power.states[i];
465 static void acpi_device_release(struct device *dev)
475 static void acpi_device_del(struct acpi_device *device)
480 if (device->parent)
481 list_del(&device->node);
485 acpi_device_hid(device))) {
486 ida_simple_remove(&acpi_device_bus_id->instance_ida, device->pnp.instance_no);
495 list_del(&device->wakeup_list);
498 acpi_power_add_remove_device(device, false);
499 acpi_device_remove_files(device);
500 if (device->remove)
501 device->remove(device);
503 device_del(&device->dev);
534 * used by the device.
542 * acpi_scan_drop_device - Drop an ACPI device object.
544 * @context: Address of the ACPI device object to drop.
547 * namespace node the device object pointed to by @context is attached to.
551 * ensure the correct ordering (the device objects must be unregistered in the
564 * prevents attempts to register device objects identical to those being
568 * those work items to ensure that they are not accessing stale device
581 static int acpi_get_device_data(acpi_handle handle, struct acpi_device **device,
586 if (!device)
589 *device = NULL;
592 (void **)device, callback);
593 if (ACPI_FAILURE(status) || !*device) {
601 int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
603 return acpi_get_device_data(handle, device, NULL);
638 static int acpi_device_set_name(struct acpi_device *device,
648 device->pnp.instance_no = result;
649 dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, result);
653 int acpi_device_add(struct acpi_device *device,
654 void (*release)(struct device *))
659 if (device->handle) {
662 status = acpi_attach_data(device->handle, acpi_scan_drop_device,
663 device);
665 acpi_handle_err(device->handle,
666 "Unable to attach device data\n");
674 * Link this device to its parent and siblings.
676 INIT_LIST_HEAD(&device->children);
677 INIT_LIST_HEAD(&device->node);
678 INIT_LIST_HEAD(&device->wakeup_list);
679 INIT_LIST_HEAD(&device->physical_node_list);
680 INIT_LIST_HEAD(&device->del_list);
681 mutex_init(&device->physical_node_lock);
685 acpi_device_bus_id = acpi_device_bus_id_match(acpi_device_hid(device));
687 result = acpi_device_set_name(device, acpi_device_bus_id);
698 kstrdup_const(acpi_device_hid(device), GFP_KERNEL);
707 result = acpi_device_set_name(device, acpi_device_bus_id);
717 if (device->parent)
718 list_add_tail(&device->node, &device->parent->children);
720 if (device->wakeup.flags.valid)
721 list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list);
724 if (device->parent)
725 device->dev.parent = &device->parent->dev;
726 device->dev.bus = &acpi_bus_type;
727 device->dev.release = release;
728 result = device_add(&device->dev);
730 dev_err(&device->dev, "Error registering device\n");
734 result = acpi_device_setup_files(device);
736 printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n",
737 dev_name(&device->dev));
743 if (device->parent)
744 list_del(&device->node);
745 list_del(&device->wakeup_list);
750 acpi_detach_data(device->handle, acpi_scan_drop_device);
759 struct acpi_device *device = NULL;
774 } while (acpi_bus_get_device(handle, &device));
775 return device;
881 static bool acpi_wakeup_gpe_init(struct acpi_device *device)
889 struct acpi_device_wakeup *wakeup = &device->wakeup;
895 if (!acpi_match_device_ids(device, button_device_ids)) {
896 if (!acpi_match_device_ids(device, &button_device_ids[1])) {
902 device_set_wakeup_capable(&device->dev, true);
906 status = acpi_setup_gpe_for_wake(device->handle, wakeup->gpe_device,
911 static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
916 if (!acpi_has_method(device->handle, "_PRW"))
919 err = acpi_bus_extract_wakeup_device_power_package(device);
921 dev_err(&device->dev, "_PRW evaluation error: %d\n", err);
925 device->wakeup.flags.valid = acpi_wakeup_gpe_init(device);
926 device->wakeup.prepare_count = 0;
929 * system for the ACPI device with the _PRW object.
934 err = acpi_device_sleep_wake(device, 0, 0, 0);
939 static void acpi_bus_init_power_state(struct acpi_device *device, int state)
941 struct acpi_device_power_state *ps = &device->power.states[state];
949 status = acpi_evaluate_object(device->handle, pathname, NULL, &buffer);
963 if (acpi_has_method(device->handle, pathname))
966 /* State is valid if there are means to put the device into it. */
974 static void acpi_bus_get_power_flags(struct acpi_device *device)
979 if (!acpi_has_method(device->handle, "_PS0") &&
980 !acpi_has_method(device->handle, "_PR0"))
983 device->flags.power_manageable = 1;
988 if (acpi_has_method(device->handle, "_PSC"))
989 device->power.flags.explicit_get = 1;
991 if (acpi_has_method(device->handle, "_IRC"))
992 device->power.flags.inrush_current = 1;
994 if (acpi_has_method(device->handle, "_DSW"))
995 device->power.flags.dsw_present = 1;
1001 acpi_bus_init_power_state(device, i);
1003 INIT_LIST_HEAD(&device->power.states[ACPI_STATE_D3_COLD].resources);
1006 device->power.states[ACPI_STATE_D0].flags.valid = 1;
1007 device->power.states[ACPI_STATE_D0].power = 100;
1008 device->power.states[ACPI_STATE_D3_HOT].flags.valid = 1;
1015 if (!list_empty(&device->power.states[ACPI_STATE_D0].resources)) {
1016 device->power.flags.power_resources = 1;
1021 if (!list_empty(&device->power.states[ACPI_STATE_D3_HOT].resources))
1022 device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1;
1025 if (acpi_bus_init_power(device))
1026 device->flags.power_manageable = 0;
1029 static void acpi_bus_get_flags(struct acpi_device *device)
1032 if (acpi_has_method(device->handle, "_STA"))
1033 device->flags.dynamic_status = 1;
1036 if (acpi_has_method(device->handle, "_RMV"))
1037 device->flags.removable = 1;
1040 if (acpi_has_method(device->handle, "_EJD") ||
1041 acpi_has_method(device->handle, "_EJ0"))
1042 device->flags.ejectable = 1;
1045 static void acpi_device_get_busid(struct acpi_device *device)
1054 * The device's Bus ID is simply the object name.
1057 if (ACPI_IS_ROOT_DEVICE(device)) {
1058 strcpy(device->pnp.bus_id, "ACPI");
1062 switch (device->device_type) {
1064 strcpy(device->pnp.bus_id, "PWRF");
1067 strcpy(device->pnp.bus_id, "SLPF");
1070 strcpy(device->pnp.bus_id, "ECDT");
1073 acpi_get_name(device->handle, ACPI_SINGLE_NAME, &buffer);
1081 strcpy(device->pnp.bus_id, bus_id);
1087 * acpi_ata_match - see if an acpi object is an ATA device
1090 * then we can safely call it an ATA device.
1166 /* Returns true if the ACPI object is a video device which can be
1168 * The device will get a Linux specific CID added in scan.c to
1169 * identify the device as an ACPI graphics device
1170 * Be aware that the graphics device may not be physically present
1178 /* Is this device able to support video switching ? */
1182 /* Is this device able to retrieve a video ROM ? */
1186 /* Is this device able to configure which video head to be POSTed ? */
1202 const char *acpi_device_hid(struct acpi_device *device)
1206 if (list_empty(&device->pnp.ids))
1209 hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list);
1290 pr_err(PREFIX "%s: Error reading device info\n",
1370 * acpi_dma_supported - Check DMA support for the specified device.
1371 * @adev: The pointer to acpi device
1395 * acpi_get_dma_attr - Check the supported DMA attr for the specified device.
1396 * @adev: The pointer to acpi device
1412 * acpi_dma_get_range() - Get device DMA parameters.
1414 * @dev: device to configure
1422 int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map)
1428 struct device *dma_dev = dev;
1432 * Walk the device tree chasing an ACPI companion with a _DMA
1433 * object while we go. Stop if we find a device with an ACPI
1484 * acpi_dma_configure_id - Set-up DMA configuration for the device.
1485 * @dev: The pointer to the device
1486 * @attr: device dma attributes
1487 * @input_id: input device id const value pointer
1489 int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr,
1539 "ACPI device is missing _CCA.\n");
1558 static bool acpi_is_indirect_io_slave(struct acpi_device *device)
1560 struct acpi_device *parent = device->parent;
1569 static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
1587 * HIDs of device with an UartSerialBusV2 resource for which userspace
1597 if (acpi_is_indirect_io_slave(device))
1600 /* Macs use device properties in lieu of _CRS resources */
1602 (fwnode_property_present(&device->fwnode, "spiSclkPeriod") ||
1603 fwnode_property_present(&device->fwnode, "i2cAddress") ||
1604 fwnode_property_present(&device->fwnode, "baud")))
1607 if (!acpi_match_device_ids(device, ignore_serial_bus_ids))
1611 acpi_dev_get_resources(device, &resource_list,
1619 void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
1622 INIT_LIST_HEAD(&device->pnp.ids);
1623 device->device_type = type;
1624 device->handle = handle;
1625 device->parent = acpi_bus_get_parent(handle);
1626 device->fwnode.ops = &acpi_device_fwnode_ops;
1627 acpi_set_device_status(device, sta);
1628 acpi_device_get_busid(device);
1629 acpi_set_pnp_ids(handle, &device->pnp, type);
1630 acpi_init_properties(device);
1631 acpi_bus_get_flags(device);
1632 device->flags.match_driver = false;
1633 device->flags.initialized = true;
1634 device->flags.enumeration_by_parent =
1635 acpi_device_enumeration_by_parent(device);
1636 acpi_device_clear_enumerated(device);
1637 device_initialize(&device->dev);
1638 dev_set_uevent_suppress(&device->dev, true);
1639 acpi_init_coherency(device);
1641 device->dep_unmet = 1;
1644 void acpi_device_add_finalize(struct acpi_device *device)
1646 dev_set_uevent_suppress(&device->dev, false);
1647 kobject_uevent(&device->dev.kobj, KOBJ_ADD);
1655 struct acpi_device *device;
1658 device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL);
1659 if (!device) {
1664 acpi_init_device_object(device, handle, type, sta);
1671 if (acpi_bus_get_status(device) < 0)
1672 acpi_set_device_status(device, 0);
1674 acpi_bus_get_power_flags(device);
1675 acpi_bus_get_wakeup_device_flags(device);
1677 result = acpi_device_add(device, acpi_device_release);
1679 acpi_device_release(&device->dev);
1683 acpi_power_add_remove_device(device, true);
1684 acpi_device_add_finalize(device);
1687 dev_name(&device->dev), (char *) buffer.pointer,
1688 device->parent ? dev_name(&device->parent->dev) : "(null)"));
1690 *child = device;
1710 /* Check if it should ignore the UART device */
1715 * The UART device described in SPCR table is assumed to have only one
1723 acpi_handle_info(handle, "The UART device @%pa in SPCR table will be hidden\n",
1866 dev_dbg(&adev->dev, "Error reading _DEP device info\n");
1899 struct acpi_device *device = NULL;
1904 acpi_bus_get_device(handle, &device);
1905 if (device)
1917 acpi_add_single_object(&device, handle, type, sta);
1918 if (!device)
1921 acpi_scan_init_hotplug(device);
1922 acpi_device_dep_initialize(device);
1926 *return_value = device;
1931 static void acpi_default_enumeration(struct acpi_device *device)
1937 if (!device->flags.enumeration_by_parent) {
1938 acpi_create_platform_device(device, NULL);
1939 acpi_device_set_enumerated(device);
1942 ACPI_RECONFIG_DEVICE_ADD, device);
1969 static int acpi_scan_attach_handler(struct acpi_device *device)
1974 list_for_each_entry(hwid, &device->pnp.ids, list) {
1981 device->pnp.type.platform_id = 0;
1984 device->handler = handler;
1985 ret = handler->attach(device, devid);
1989 device->handler = NULL;
1998 static void acpi_bus_attach(struct acpi_device *device)
2004 if (ACPI_SUCCESS(acpi_bus_get_ejd(device->handle, &ejd)))
2005 register_dock_dependent_device(device, ejd);
2007 acpi_bus_get_status(device);
2009 if (!acpi_device_is_present(device)) {
2010 device->flags.initialized = false;
2011 acpi_device_clear_enumerated(device);
2012 device->flags.power_manageable = 0;
2015 if (device->handler)
2018 if (!device->flags.initialized) {
2019 device->flags.power_manageable =
2020 device->power.states[ACPI_STATE_D0].flags.valid;
2021 if (acpi_bus_init_power(device))
2022 device->flags.power_manageable = 0;
2024 device->flags.initialized = true;
2025 } else if (device->flags.visited) {
2029 ret = acpi_scan_attach_handler(device);
2033 device->flags.match_driver = true;
2034 if (ret > 0 && !device->flags.enumeration_by_parent) {
2035 acpi_device_set_enumerated(device);
2039 ret = device_attach(&device->dev);
2043 if (device->pnp.type.platform_id || device->flags.enumeration_by_parent)
2044 acpi_default_enumeration(device);
2046 acpi_device_set_enumerated(device);
2049 list_for_each_entry(child, &device->children, node)
2052 if (device->handler && device->handler->hotplug.notify_online)
2053 device->handler->hotplug.notify_online(device);
2080 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
2088 * in the table trunk from which the kernel could create a device and add an
2095 void *device = NULL;
2097 if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
2099 acpi_bus_check_add, NULL, NULL, &device);
2101 if (device) {
2102 acpi_bus_attach(device);
2110 * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects.
2133 * Most likely, the device is going away, so put it into D3cold before
2144 struct acpi_device *device = NULL;
2147 result = acpi_add_single_object(&device, NULL,
2152 device->flags.match_driver = true;
2153 return device_attach(&device->dev);
2165 struct acpi_device *device = NULL;
2167 result = acpi_add_single_object(&device, NULL,
2173 device->flags.match_driver = true;
2174 result = device_attach(&device->dev);
2178 device_init_wakeup(&device->dev, true);
2182 struct acpi_device *device = NULL;
2184 result = acpi_add_single_object(&device, NULL,
2190 device->flags.match_driver = true;
2191 result = device_attach(&device->dev);
2240 * device in SPCR table.