示例#1
0
/**
 * acpi_dev_suspend_late - Put device into a low-power state using ACPI.
 * @dev: Device to put into a low-power state.
 *
 * Put the given device into a low-power state during system transition to a
 * sleep state using the standard ACPI mechanism.  Set up system wakeup if
 * desired, choose the state to put the device into (this checks if system
 * wakeup is expected to work too), and set the power state of the device.
 */
int acpi_dev_suspend_late(struct device *dev)
{
	struct acpi_device *adev = ACPI_COMPANION(dev);
	u32 target_state;
	bool wakeup;
	bool can_wakeup;
	int error;

	if (!adev)
		return 0;

	target_state = acpi_target_system_state();
	wakeup = device_may_wakeup(dev);
	can_wakeup = acpi_device_can_wakeup(adev);

	if (can_wakeup) {
		error = __acpi_device_sleep_wake(adev, target_state, wakeup);
		if (wakeup && error)
			return error;
	} else if (wakeup) {
		dev_warn(dev,
			 "device is not wakeup-capable, not enabling wakeup\n");
	}

	error = acpi_dev_pm_low_power(dev, adev, target_state);
	if (error && can_wakeup)
		__acpi_device_sleep_wake(adev, ACPI_STATE_UNKNOWN, false);

	return error;
}
示例#2
0
/**
 * acpi_dev_suspend_late - Put device into a low-power state using ACPI.
 * @dev: Device to put into a low-power state.
 *
 * Put the given device into a low-power state during system transition to a
 * sleep state using the standard ACPI mechanism.  Set up system wakeup if
 * desired, choose the state to put the device into (this checks if system
 * wakeup is expected to work too), and set the power state of the device.
 */
int acpi_dev_suspend_late(struct device *dev)
{
	struct acpi_device *adev = ACPI_COMPANION(dev);
	u32 target_state;
	bool wakeup;
	int error;

	if (!adev)
		return 0;

	target_state = acpi_target_system_state();
	wakeup = device_may_wakeup(dev) && acpi_device_can_wakeup(adev);
	error = acpi_device_wakeup(adev, target_state, wakeup);
	if (wakeup && error)
		return error;

	error = acpi_dev_pm_low_power(dev, adev, target_state);
	if (error)
		acpi_device_wakeup(adev, ACPI_STATE_UNKNOWN, false);

	return error;
}