Example #1
0
/**
 * acpi_subsys_prepare - Prepare device for system transition to a sleep state.
 * @dev: Device to prepare.
 */
int acpi_subsys_prepare(struct device *dev)
{
	/*
	 * Follow PCI and resume devices suspended at run time before running
	 * their system suspend callbacks.
	 */
	pm_runtime_resume(dev);
	return pm_generic_prepare(dev);
}
Example #2
0
/**
 * acpi_subsys_prepare - Prepare device for system transition to a sleep state.
 * @dev: Device to prepare.
 */
int acpi_subsys_prepare(struct device *dev)
{
	struct acpi_device *adev = ACPI_COMPANION(dev);
	u32 sys_target;
	int ret, state;

	ret = pm_generic_prepare(dev);
	if (ret < 0)
		return ret;

	if (!adev || !pm_runtime_suspended(dev)
	    || device_may_wakeup(dev) != !!adev->wakeup.prepare_count)
		return 0;

	sys_target = acpi_target_system_state();
	if (sys_target == ACPI_STATE_S0)
		return 1;

	if (adev->power.flags.dsw_present)
		return 0;

	ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state);
	return !ret && state == adev->power.state;
}