git: 4052b0e4b218 - main - LinuxKPI: pm.h add pm_sleep_ptr and DEFINE_SIMPLE_DEV_PM_OPS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 31 Dec 2022 02:52:41 UTC
The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=4052b0e4b218f916b1f491a5ec9e41d38029215b commit 4052b0e4b218f916b1f491a5ec9e41d38029215b Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2022-11-28 22:31:28 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2022-12-31 02:51:09 +0000 LinuxKPI: pm.h add pm_sleep_ptr and DEFINE_SIMPLE_DEV_PM_OPS Extend pm.h by pm_sleep_ptr and DEFINE_SIMPLE_DEV_PM_OPS(). For the moment this duplicates some parts (as can be seen in the earlier review I tried to simplify bits but given our implementation this was easier in the end). While here and cleanup the SIMPLE_DEV_PM_OPS() bits (white-space only). MFC after: 3 days Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D37527 --- sys/compat/linuxkpi/common/include/linux/pm.h | 28 +++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pm.h b/sys/compat/linuxkpi/common/include/linux/pm.h index d054a95f17a3..085b180642aa 100644 --- a/sys/compat/linuxkpi/common/include/linux/pm.h +++ b/sys/compat/linuxkpi/common/include/linux/pm.h @@ -53,20 +53,36 @@ struct dev_pm_info { #define PM_EVENT_FREEZE 0x0001 #define PM_EVENT_SUSPEND 0x0002 +#define pm_sleep_ptr(_p) \ + IS_ENABLED(CONFIG_PM_SLEEP) ? (_p) : NULL + #ifdef CONFIG_PM_SLEEP #define SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \ const struct dev_pm_ops _name = { \ - .suspend = _suspendfunc, \ - .resume = _resumefunc, \ - .freeze = _suspendfunc, \ - .thaw = _resumefunc, \ - .poweroff = _suspendfunc, \ - .restore = _resumefunc, \ + .suspend = _suspendfunc, \ + .resume = _resumefunc, \ + .freeze = _suspendfunc, \ + .thaw = _resumefunc, \ + .poweroff = _suspendfunc, \ + .restore = _resumefunc, \ +} + +#define DEFINE_SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \ +const struct dev_pm_ops _name = { \ + .suspend = _suspendfunc, \ + .resume = _resumefunc, \ + .freeze = _suspendfunc, \ + .thaw = _resumefunc, \ + .poweroff = _suspendfunc, \ + .restore = _resumefunc, \ } #else #define SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \ const struct dev_pm_ops _name = { \ } +#define DEFINE_SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \ +const struct dev_pm_ops _name = { \ +} #endif #endif /* _LINUXKPI_LINUX_PM_H */