aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-06-15 18:02:22 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-07-01 07:31:29 -0400
commit0b589741b8b83a33e25fb32bb714ea1b972af5aa (patch)
tree40fb1a027166ad3da78848174ec644bf004ad20e
parent6887a4131da3adaab011613776d865f4bcfb5678 (diff)
PM / Domains: Use subsystem runtime suspend/resume callbacks by default
Currently, the default "save state" and "restore state" routines for generic PM domains, pm_genpd_default_save_state() and pm_genpd_default_restore_state(), respectively, only use runtime PM callbacks provided by device drivers, but in general those callbacks need not provide the entire necessary functionality. Namely, in general it may be necessary to execute subsystem (i.e. device type, device class or bus type) callbacks that will carry out all of the necessary operations. For this reason, modify pm_genpd_default_save_state() and pm_genpd_default_restore_state() to execute subsystem callbacks, if they are provided, and fall back to driver callbacks otherwise. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
-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