/* Use underlying platform code to find a supported low power state for @dev. If the platform can't manage @dev, return the deepest state from which it can generate wake events, based on any available PME info.  */
pci_power_t pci_target_state(struct pci_dev *dev)
/* Use underlying platform code to find a supported low power state for @dev. If the platform can't manage @dev, return the deepest state from which it can generate wake events, based on any available PME info.  */
pci_power_t pci_target_state(struct pci_dev *dev)
{
	pci_power_t target_state = PCI_D3hot;
	if (platform_pci_power_manageable(dev)) {
		pci_power_t state = platform_pci_choose_state(dev);
		switch (state) {
		case PCI_POWER_ERROR:
		case PCI_UNKNOWN:
			break;
		case PCI_D1:
		case PCI_D2:
			if (pci_no_d1d2(dev))
				break;
		default:
			target_state = state;
		}
	} else if (!dev->pm_cap) {
		target_state = PCI_D0;
	} else if (device_may_wakeup(&dev->dev)) {
		if (dev->pme_support) {
			while (target_state
			      && !(dev->pme_support & (1 << target_state)))
				target_state--;
		}
	}
	return target_state;
}