/* RETURN VALUE: -EINVAL if the requested state is invalid. -EIO if device does not support PCI PM or its PM capabilities register has a wrong version, or device doesn't support the requested state. 0 if device already is in the requested state. 0 if device's power state has been successfully changed.  */
int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
/* RETURN VALUE: -EINVAL if the requested state is invalid. -EIO if device does not support PCI PM or its PM capabilities register has a wrong version, or device doesn't support the requested state. 0 if device already is in the requested state. 0 if device's power state has been successfully changed.  */
int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
{
	int error;
	if (state > PCI_D3hot)
		state = PCI_D3hot;
	else if (state < PCI_D0)
		state = PCI_D0;
	else if ((state == PCI_D1 || state == PCI_D2) && pci_no_d1d2(dev))
		return 0;
	if (dev->current_state == state)
		return 0;
	__pci_start_power_transition(dev, state);
	if (state == PCI_D3hot && (dev->dev_flags & PCI_DEV_FLAGS_NO_D3))
		return 0;
	error = pci_raw_set_power_state(dev, state);
	if (!__pci_complete_power_transition(dev, state))
		error = 0;
	return error;
}