123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- #include <linux/pm.h>
- #include <linux/pm_runtime.h>
- #include <linux/export.h>
- #include <linux/suspend.h>
- #ifdef CONFIG_PM
- int pm_generic_runtime_suspend(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- int ret;
- ret = pm && pm->runtime_suspend ? pm->runtime_suspend(dev) : 0;
- return ret;
- }
- EXPORT_SYMBOL_GPL(pm_generic_runtime_suspend);
- int pm_generic_runtime_resume(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- int ret;
- ret = pm && pm->runtime_resume ? pm->runtime_resume(dev) : 0;
- return ret;
- }
- EXPORT_SYMBOL_GPL(pm_generic_runtime_resume);
- #endif
- #ifdef CONFIG_PM_SLEEP
- int pm_generic_prepare(struct device *dev)
- {
- struct device_driver *drv = dev->driver;
- int ret = 0;
- if (drv && drv->pm && drv->pm->prepare)
- ret = drv->pm->prepare(dev);
- return ret;
- }
- int pm_generic_suspend_noirq(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->suspend_noirq ? pm->suspend_noirq(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_suspend_noirq);
- int pm_generic_suspend_late(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->suspend_late ? pm->suspend_late(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_suspend_late);
- int pm_generic_suspend(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->suspend ? pm->suspend(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_suspend);
- int pm_generic_freeze_noirq(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->freeze_noirq ? pm->freeze_noirq(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_freeze_noirq);
- int pm_generic_freeze_late(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->freeze_late ? pm->freeze_late(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_freeze_late);
- int pm_generic_freeze(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->freeze ? pm->freeze(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_freeze);
- int pm_generic_poweroff_noirq(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->poweroff_noirq ? pm->poweroff_noirq(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_poweroff_noirq);
- int pm_generic_poweroff_late(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->poweroff_late ? pm->poweroff_late(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_poweroff_late);
- int pm_generic_poweroff(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->poweroff ? pm->poweroff(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_poweroff);
- int pm_generic_thaw_noirq(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->thaw_noirq ? pm->thaw_noirq(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_thaw_noirq);
- int pm_generic_thaw_early(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->thaw_early ? pm->thaw_early(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_thaw_early);
- int pm_generic_thaw(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->thaw ? pm->thaw(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_thaw);
- int pm_generic_resume_noirq(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->resume_noirq ? pm->resume_noirq(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_resume_noirq);
- int pm_generic_resume_early(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->resume_early ? pm->resume_early(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_resume_early);
- int pm_generic_resume(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->resume ? pm->resume(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_resume);
- int pm_generic_restore_noirq(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->restore_noirq ? pm->restore_noirq(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_restore_noirq);
- int pm_generic_restore_early(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->restore_early ? pm->restore_early(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_restore_early);
- int pm_generic_restore(struct device *dev)
- {
- const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
- return pm && pm->restore ? pm->restore(dev) : 0;
- }
- EXPORT_SYMBOL_GPL(pm_generic_restore);
- void pm_generic_complete(struct device *dev)
- {
- struct device_driver *drv = dev->driver;
- if (drv && drv->pm && drv->pm->complete)
- drv->pm->complete(dev);
- }
- void pm_complete_with_resume_check(struct device *dev)
- {
- pm_generic_complete(dev);
-
- if (dev->power.direct_complete && pm_resume_via_firmware())
- pm_request_resume(dev);
- }
- EXPORT_SYMBOL_GPL(pm_complete_with_resume_check);
- #endif
|