/* Prepare a wakeup device, two steps (Ref ACPI 2.0:P229): */
int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
/* Prepare a wakeup device, two steps (Ref ACPI 2.0:P229): */
int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
{
	int i, err = 0;
	if (!dev || !dev->wakeup.flags.valid)
		return -EINVAL;
	mutex_lock(&acpi_device_lock);
	if (dev->wakeup.prepare_count++)
		goto out;
	for (i = 0; i < dev->wakeup.resources.count; i++) {
		int ret = acpi_power_on(dev->wakeup.resources.handles[i], dev);
		if (ret) {
			printk(KERN_ERR PREFIX "Transition power state\n");
			dev->wakeup.flags.valid = 0;
			err = -ENODEV;
			goto err_out;
		}
	}
	err = acpi_device_sleep_wake(dev, 1, sleep_state, 3);
 err_out:
	if (err)
		dev->wakeup.prepare_count = 0;
 out:
	mutex_unlock(&acpi_device_lock);
	return err;
}