]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
PCI PM: Fix pci_update_current_state
authorRafael J. Wysocki <rjw@sisk.pl>
Sat, 27 Dec 2008 15:30:52 +0000 (16:30 +0100)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Wed, 7 Jan 2009 19:13:08 +0000 (11:13 -0800)
Currently, PCI devices without the PM capability that are power
manageable by the platform (eg. ACPI) are not handled correctly
by pci_set_power_state(), because their current_state field is not
updated to reflect the new power state of the device.  Fix this by
making pci_update_current_state() accept additional argument
representing the power state of the device as set by the platform.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/pci.c

index 1b807330e5005faa8f5f9c1b77d98ecc1bd406ac..9d2aa6366fd047622df85c4dcc56c6d0160a791e 100644 (file)
@@ -525,14 +525,17 @@ pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
  * pci_update_current_state - Read PCI power state of given device from its
  *                            PCI PM registers and cache it
  * @dev: PCI device to handle.
+ * @state: State to cache in case the device doesn't have the PM capability
  */
-static void pci_update_current_state(struct pci_dev *dev)
+static void pci_update_current_state(struct pci_dev *dev, pci_power_t state)
 {
        if (dev->pm_cap) {
                u16 pmcsr;
 
                pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
                dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
+       } else {
+               dev->current_state = state;
        }
 }
 
@@ -575,7 +578,7 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
                 */
                int ret = platform_pci_set_power_state(dev, PCI_D0);
                if (!ret)
-                       pci_update_current_state(dev);
+                       pci_update_current_state(dev, PCI_D0);
        }
        /* This device is quirked not to be put into D3, so
           don't put it in D3 */
@@ -588,7 +591,7 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
                /* Allow the platform to finalize the transition */
                int ret = platform_pci_set_power_state(dev, state);
                if (!ret) {
-                       pci_update_current_state(dev);
+                       pci_update_current_state(dev, state);
                        error = 0;
                }
        }