===================================================================
@@ -446,7 +446,7 @@ static int pci_raw_set_power_state(struc
return 0;
if (!dev->pm_cap)
- return -EIO;
+ return -ENOSYS;
if (state < PCI_D0 || state > PCI_D3hot)
return -EINVAL;
@@ -465,7 +465,7 @@ static int pci_raw_set_power_state(struc
/* check if this device supports the desired state */
if ((state == PCI_D1 && !dev->d1_support)
|| (state == PCI_D2 && !dev->d2_support))
- return -EIO;
+ return -ENOSYS;
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
@@ -502,7 +502,11 @@ static int pci_raw_set_power_state(struc
else if (state == PCI_D2 || dev->current_state == PCI_D2)
udelay(PCI_PM_D2_DELAY);
- dev->current_state = state;
+ pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
+ dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
+ /* Return error code if we have failed to change the state */
+ if (dev->current_state != state)
+ return -EIO;
/* According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT
* INTERFACE SPECIFICATION, REV. 1.2", a device transitioning