aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/power/domain.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 83aa694a8efe..49fdd4002b9f 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1615,16 +1615,24 @@ EXPORT_SYMBOL_GPL(__pm_genpd_remove_callbacks);
1615static int pm_genpd_default_save_state(struct device *dev) 1615static int pm_genpd_default_save_state(struct device *dev)
1616{ 1616{
1617 int (*cb)(struct device *__dev); 1617 int (*cb)(struct device *__dev);
1618 struct device_driver *drv = dev->driver;
1619 1618
1620 cb = dev_gpd_data(dev)->ops.save_state; 1619 cb = dev_gpd_data(dev)->ops.save_state;
1621 if (cb) 1620 if (cb)
1622 return cb(dev); 1621 return cb(dev);
1623 1622
1624 if (drv && drv->pm && drv->pm->runtime_suspend) 1623 if (dev->type && dev->type->pm)
1625 return drv->pm->runtime_suspend(dev); 1624 cb = dev->type->pm->runtime_suspend;
1625 else if (dev->class && dev->class->pm)
1626 cb = dev->class->pm->runtime_suspend;
1627 else if (dev->bus && dev->bus->pm)
1628 cb = dev->bus->pm->runtime_suspend;
1629 else
1630 cb = NULL;
1626 1631
1627 return 0; 1632 if (!cb && dev->driver && dev->driver->pm)
1633 cb = dev->driver->pm->runtime_suspend;
1634
1635 return cb ? cb(dev) : 0;
1628} 1636}
1629 1637
1630/** 1638/**
@@ -1634,16 +1642,24 @@ static int pm_genpd_default_save_state(struct device *dev)
1634static int pm_genpd_default_restore_state(struct device *dev) 1642static int pm_genpd_default_restore_state(struct device *dev)
1635{ 1643{
1636 int (*cb)(struct device *__dev); 1644 int (*cb)(struct device *__dev);
1637 struct device_driver *drv = dev->driver;
1638 1645
1639 cb = dev_gpd_data(dev)->ops.restore_state; 1646 cb = dev_gpd_data(dev)->ops.restore_state;
1640 if (cb) 1647 if (cb)
1641 return cb(dev); 1648 return cb(dev);
1642 1649
1643 if (drv && drv->pm && drv->pm->runtime_resume) 1650 if (dev->type && dev->type->pm)
1644 return drv->pm->runtime_resume(dev); 1651 cb = dev->type->pm->runtime_resume;
1652 else if (dev->class && dev->class->pm)
1653 cb = dev->class->pm->runtime_resume;
1654 else if (dev->bus && dev->bus->pm)
1655 cb = dev->bus->pm->runtime_resume;
1656 else
1657 cb = NULL;
1645 1658
1646 return 0; 1659 if (!cb && dev->driver && dev->driver->pm)
1660 cb = dev->driver->pm->runtime_resume;
1661
1662 return cb ? cb(dev) : 0;
1647} 1663}
1648 1664
1649#ifdef CONFIG_PM_SLEEP 1665#ifdef CONFIG_PM_SLEEP