Lines Matching defs:adev

140 static int acpi_dev_pm_explicit_set(struct acpi_device *adev, int state)
142 if (adev->power.states[state].flags.explicit_set) {
146 status = acpi_evaluate_object(adev->handle, method, NULL, NULL);
447 struct acpi_device *adev;
454 adev = acpi_bus_get_acpi_device(handle);
455 if (!adev)
460 if (adev->wakeup.flags.notifier_present) {
461 pm_wakeup_ws_event(adev->wakeup.ws, 0, acpi_s2idle_wakeup());
462 if (adev->wakeup.context.func) {
464 adev->wakeup.context.func,
465 dev_name(adev->wakeup.context.dev));
466 adev->wakeup.context.func(&adev->wakeup.context);
472 acpi_bus_put_acpi_device(adev);
477 * @adev: ACPI device to add the notify handler for.
481 * NOTE: @adev need not be a run-wake or wakeup device to be a valid source of
486 acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev,
496 if (adev->wakeup.flags.notifier_present)
499 status = acpi_install_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY,
505 adev->wakeup.ws = wakeup_source_register(&adev->dev,
506 dev_name(&adev->dev));
507 adev->wakeup.context.dev = dev;
508 adev->wakeup.context.func = func;
509 adev->wakeup.flags.notifier_present = true;
519 * @adev: ACPI device to remove the notifier from.
521 acpi_status acpi_remove_pm_notifier(struct acpi_device *adev)
527 if (!adev->wakeup.flags.notifier_present)
530 status = acpi_remove_notify_handler(adev->handle,
537 adev->wakeup.context.func = NULL;
538 adev->wakeup.context.dev = NULL;
539 wakeup_source_unregister(adev->wakeup.ws);
540 adev->wakeup.flags.notifier_present = false;
560 struct acpi_device *adev = ACPI_COMPANION(dev);
562 return adev ? acpi_device_can_wakeup(adev) : false;
568 * @adev: ACPI device node corresponding to @dev.
579 * Callers must ensure that @dev and @adev are valid pointers and that @adev
586 static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev,
590 acpi_handle handle = adev->handle;
627 if (!adev->power.states[ret].flags.valid) {
638 wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid
639 && adev->wakeup.sleep_state >= target_state;
641 wakeup = adev->wakeup.flags.valid;
663 if (!adev->power.states[ret].flags.valid)
694 struct acpi_device *adev;
708 adev = ACPI_COMPANION(dev);
709 if (!adev) {
714 ret = acpi_dev_pm_get_state(dev, adev, acpi_target_system_state(),
724 if (adev->power.states[d_max].flags.valid)
752 static int __acpi_device_wakeup_enable(struct acpi_device *adev,
755 struct acpi_device_wakeup *wakeup = &adev->wakeup;
762 acpi_handle_info(adev->handle, "Wakeup enable count out of bounds!\n");
768 error = acpi_enable_wakeup_device_power(adev, target_state);
774 acpi_disable_wakeup_device_power(adev);
779 acpi_handle_debug(adev->handle, "GPE%2X enabled for wakeup\n",
792 * @adev: ACPI device to enable wakeup functionality for.
795 * Enable the GPE associated with @adev so that it can generate wakeup signals
799 * Callers must ensure that @adev is a valid ACPI device node before executing
802 static int acpi_device_wakeup_enable(struct acpi_device *adev, u32 target_state)
804 return __acpi_device_wakeup_enable(adev, target_state);
809 * @adev: ACPI device to disable wakeup functionality for.
811 * Disable the GPE associated with @adev and disable wakeup power for it.
813 * Callers must ensure that @adev is a valid ACPI device node before executing
816 static void acpi_device_wakeup_disable(struct acpi_device *adev)
818 struct acpi_device_wakeup *wakeup = &adev->wakeup;
826 acpi_disable_wakeup_device_power(adev);
841 struct acpi_device *adev;
844 adev = ACPI_COMPANION(dev);
845 if (!adev) {
850 if (!acpi_device_can_wakeup(adev))
854 acpi_device_wakeup_disable(adev);
859 error = __acpi_device_wakeup_enable(adev, acpi_target_system_state());
870 * @adev: ACPI device node corresponding to @dev.
873 static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev,
878 if (!acpi_device_power_manageable(adev))
881 ret = acpi_dev_pm_get_state(dev, adev, system_state, NULL, &state);
882 return ret ? ret : acpi_device_set_power(adev, state);
887 * @adev: ACPI device node to put into the full-power state.
889 static int acpi_dev_pm_full_power(struct acpi_device *adev)
891 return acpi_device_power_manageable(adev) ?
892 acpi_device_set_power(adev, ACPI_STATE_D0) : 0;
907 struct acpi_device *adev = ACPI_COMPANION(dev);
911 if (!adev)
914 if (wakeup && acpi_device_can_wakeup(adev)) {
915 error = acpi_device_wakeup_enable(adev, target_state);
922 error = acpi_dev_pm_low_power(dev, adev, target_state);
924 acpi_device_wakeup_disable(adev);
939 struct acpi_device *adev = ACPI_COMPANION(dev);
942 if (!adev)
945 error = acpi_dev_pm_full_power(adev);
946 acpi_device_wakeup_disable(adev);
980 static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev)
985 if (!pm_runtime_suspended(dev) || !adev || (adev->wakeup.flags.valid &&
986 device_may_wakeup(dev) != !!adev->wakeup.prepare_count))
992 if (adev->power.flags.dsw_present)
995 ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state);
999 return state != adev->power.state;
1008 struct acpi_device *adev = ACPI_COMPANION(dev);
1020 return !acpi_dev_needs_resume(dev, adev);
1258 struct acpi_device *adev = ACPI_COMPANION(dev);
1260 if (adev && dev->pm_domain == &acpi_general_pm_domain) {
1262 acpi_remove_pm_notifier(adev);
1272 acpi_device_wakeup_disable(adev);
1273 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
1305 struct acpi_device *adev = ACPI_COMPANION(dev);
1307 if (!adev || !acpi_match_device_ids(adev, special_pm_ids))
1315 if (!acpi_device_is_first_physical_node(adev, dev))
1318 acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func);
1321 acpi_dev_pm_full_power(adev);
1322 acpi_device_wakeup_disable(adev);
1346 struct acpi_device *adev = ACPI_COMPANION(dev);
1349 if (!adev)
1351 if (fwnode_property_read_u8(acpi_fwnode_handle(adev), "StorageD3Enable",