The size of drivers/pci/pci-driver.c can be reduced quite a bit if pci_fixup_device() is called from the legacy PM callbacks, so make it happen. No functional changes should result from this. Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx> --- drivers/pci/pci-driver.c | 52 +++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 33 deletions(-) Index: linux-2.6/drivers/pci/pci-driver.c =================================================================== --- linux-2.6.orig/drivers/pci/pci-driver.c +++ linux-2.6/drivers/pci/pci-driver.c @@ -351,6 +351,9 @@ static int pci_legacy_suspend(struct dev */ pci_pm_set_unknown_state(pci_dev); } + + pci_fixup_device(pci_fixup_suspend, pci_dev); + return i; } @@ -373,6 +376,8 @@ static int pci_legacy_resume(struct devi struct pci_dev * pci_dev = to_pci_dev(dev); struct pci_driver * drv = pci_dev->driver; + pci_fixup_device(pci_fixup_resume, pci_dev); + if (drv && drv->resume) { error = drv->resume(pci_dev); } else { @@ -389,6 +394,8 @@ static int pci_legacy_resume_early(struc struct pci_dev * pci_dev = to_pci_dev(dev); struct pci_driver * drv = pci_dev->driver; + pci_fixup_device(pci_fixup_resume_early, pci_dev); + if (drv && drv->resume_early) error = drv->resume_early(pci_dev); return error; @@ -504,10 +511,8 @@ static int pci_pm_suspend(struct device struct device_driver *drv = dev->driver; int error = 0; - if (pci_has_legacy_pm_support(pci_dev)) { - error = pci_legacy_suspend(dev, PMSG_SUSPEND); - goto Exit; - } + if (pci_has_legacy_pm_support(pci_dev)) + return pci_legacy_suspend(dev, PMSG_SUSPEND); if (drv && drv->pm) { if (drv->pm->suspend) { @@ -518,7 +523,6 @@ static int pci_pm_suspend(struct device pci_pm_default_suspend(pci_dev); } - Exit: pci_fixup_device(pci_fixup_suspend, pci_dev); return error; @@ -551,10 +555,8 @@ static int pci_pm_resume(struct device * struct device_driver *drv = dev->driver; int error = 0; - if (pci_has_legacy_pm_support(pci_dev)) { - pci_fixup_device(pci_fixup_resume, pci_dev); + if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_resume(dev); - } if (drv && drv->pm) { pci_fixup_device(pci_fixup_resume, pci_dev); @@ -574,10 +576,8 @@ static int pci_pm_resume_noirq(struct de struct device_driver *drv = dev->driver; int error = 0; - if (pci_has_legacy_pm_support(pci_dev)) { - pci_fixup_device(pci_fixup_resume_early, pci_dev); + if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_resume_early(dev); - } if (drv && drv->pm) { pci_fixup_device(pci_fixup_resume_early, pci_dev); @@ -608,11 +608,8 @@ static int pci_pm_freeze(struct device * struct device_driver *drv = dev->driver; int error = 0; - if (pci_has_legacy_pm_support(pci_dev)) { - error = pci_legacy_suspend(dev, PMSG_FREEZE); - pci_fixup_device(pci_fixup_suspend, pci_dev); - return error; - } + if (pci_has_legacy_pm_support(pci_dev)) + return pci_legacy_suspend(dev, PMSG_FREEZE); if (drv && drv->pm) { if (drv->pm->freeze) { @@ -653,10 +650,8 @@ static int pci_pm_thaw(struct device *de struct device_driver *drv = dev->driver; int error = 0; - if (pci_has_legacy_pm_support(pci_dev)) { - pci_fixup_device(pci_fixup_resume, pci_dev); + if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_resume(dev); - } if (drv && drv->pm) { if (drv->pm->thaw) @@ -674,10 +669,8 @@ static int pci_pm_thaw_noirq(struct devi struct device_driver *drv = dev->driver; int error = 0; - if (pci_has_legacy_pm_support(pci_dev)) { - pci_fixup_device(pci_fixup_resume_early, to_pci_dev(dev)); + if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_resume_early(dev); - } if (drv && drv->pm) { if (drv->pm->thaw_noirq) @@ -695,10 +688,8 @@ static int pci_pm_poweroff(struct device struct device_driver *drv = dev->driver; int error = 0; - if (pci_has_legacy_pm_support(pci_dev)) { - error = pci_legacy_suspend(dev, PMSG_HIBERNATE); - goto Exit; - } + if (pci_has_legacy_pm_support(pci_dev)) + return pci_legacy_suspend(dev, PMSG_HIBERNATE); if (drv && drv->pm) { if (drv->pm->poweroff) { @@ -709,7 +700,6 @@ static int pci_pm_poweroff(struct device pci_pm_default_suspend(pci_dev); } - Exit: pci_fixup_device(pci_fixup_suspend, pci_dev); return error; @@ -739,10 +729,8 @@ static int pci_pm_restore(struct device struct device_driver *drv = dev->driver; int error = 0; - if (pci_has_legacy_pm_support(pci_dev)) { - pci_fixup_device(pci_fixup_resume, pci_dev); + if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_resume(dev); - } if (drv && drv->pm) { pci_fixup_device(pci_fixup_resume, pci_dev); @@ -762,10 +750,8 @@ static int pci_pm_restore_noirq(struct d struct device_driver *drv = dev->driver; int error = 0; - if (pci_has_legacy_pm_support(pci_dev)) { - pci_fixup_device(pci_fixup_resume_early, pci_dev); + if (pci_has_legacy_pm_support(pci_dev)) return pci_legacy_resume_early(dev); - } if (drv && drv->pm) { pci_fixup_device(pci_fixup_resume_early, pci_dev); _______________________________________________ linux-pm mailing list linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/linux-pm