PCI: check saved state before restore
authorAlek Du <alek.du@intel.com>
Sat, 8 Aug 2009 00:46:19 +0000 (08:46 +0800)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Thu, 20 Aug 2009 16:08:45 +0000 (09:08 -0700)
Without the check, the config space may be filled with zeros. Though
the driver should try to avoid call restoring before saving, but the
pci layer also should check this.

Also removes the existing check in pci_restore_standard_config, since
it's superfluous with the new check in restore_state.

Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Alek Du <alek.du@intel.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/pci-driver.c
drivers/pci/pci.c

index d76c4c85367e4368963c9d71092bdaaad6888ce3..f99bc7f089f1ab8c0839775c58f2cabc487e37cf 100644 (file)
@@ -508,7 +508,7 @@ static int pci_restore_standard_config(struct pci_dev *pci_dev)
                        return error;
        }
 
-       return pci_dev->state_saved ? pci_restore_state(pci_dev) : 0;
+       return pci_restore_state(pci_dev);
 }
 
 static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
index dbd0f947f49728a3849f7e96b03a2de1f2ae180f..7b70312181d78a28cdfba11639c673626ee8eed6 100644 (file)
@@ -846,6 +846,8 @@ pci_restore_state(struct pci_dev *dev)
        int i;
        u32 val;
 
+       if (!dev->state_saved)
+               return 0;
        /* PCI Express register must be restored first */
        pci_restore_pcie_state(dev);