From b6429254914ab36050f69f86ee1034fd14e21cd8 Mon Sep 17 00:00:00 2001 From: Bjarki Arge Andreasen Date: Thu, 1 May 2025 17:14:04 +0200 Subject: [PATCH] pm: policy: fix mocks of CONFIG_PM_POLICY_DEVICE_CONSTRAINTS The APIs pm_policy_device_power_lock_get and pm_policy_device_power_lock_put are not mocked properly as they should be excluded based on CONFIG_PM_POLICY_DEVICE_CONSTRAINTS, not CONFIG_PM. Signed-off-by: Bjarki Arge Andreasen --- include/zephyr/pm/policy.h | 70 ++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/include/zephyr/pm/policy.h b/include/zephyr/pm/policy.h index 0bc0ca6874f..eab33582b92 100644 --- a/include/zephyr/pm/policy.h +++ b/include/zephyr/pm/policy.h @@ -204,32 +204,6 @@ void pm_policy_event_update(struct pm_policy_event *evt, int64_t uptime_ticks); */ void pm_policy_event_unregister(struct pm_policy_event *evt); -/** - * @brief Increase power state locks. - * - * Set power state locks in all power states that disable power in the given - * device. - * - * @param dev Device reference. - * - * @see pm_policy_device_power_lock_put() - * @see pm_policy_state_lock_get() - */ -void pm_policy_device_power_lock_get(const struct device *dev); - -/** - * @brief Decrease power state locks. - * - * Remove power state locks in all power states that disable power in the given - * device. - * - * @param dev Device reference. - * - * @see pm_policy_device_power_lock_get() - * @see pm_policy_state_lock_put() - */ -void pm_policy_device_power_lock_put(const struct device *dev); - /** * @brief Check if a state will disable a device * @@ -295,22 +269,52 @@ static inline void pm_policy_event_unregister(struct pm_policy_event *evt) ARG_UNUSED(evt); } -static inline void pm_policy_device_power_lock_get(const struct device *dev) +static inline int64_t pm_policy_next_event_ticks(void) { - ARG_UNUSED(dev); + return -1; } -static inline void pm_policy_device_power_lock_put(const struct device *dev) +#endif /* CONFIG_PM */ + +#if defined(CONFIG_PM_POLICY_DEVICE_CONSTRAINTS) || defined(__DOXYGEN__) +/** + * @brief Increase power state locks. + * + * Set power state locks in all power states that disable power in the given + * device. + * + * @param dev Device reference. + * + * @see pm_policy_device_power_lock_put() + * @see pm_policy_state_lock_get() + */ +void pm_policy_device_power_lock_get(const struct device *dev); + +/** + * @brief Decrease power state locks. + * + * Remove power state locks in all power states that disable power in the given + * device. + * + * @param dev Device reference. + * + * @see pm_policy_device_power_lock_get() + * @see pm_policy_state_lock_put() + */ +void pm_policy_device_power_lock_put(const struct device *dev); + +#else + +static inline void pm_policy_device_power_lock_get(const struct device *dev) { ARG_UNUSED(dev); } -static inline int64_t pm_policy_next_event_ticks(void) +static inline void pm_policy_device_power_lock_put(const struct device *dev) { - return -1; + ARG_UNUSED(dev); } - -#endif /* CONFIG_PM */ +#endif /* CONFIG_PM_POLICY_DEVICE_CONSTRAINTS */ #if defined(CONFIG_PM) || defined(CONFIG_PM_POLICY_LATENCY_STANDALONE) || defined(__DOXYGEN__) /**