From 24445eb420045f3e0806dce909e1a91e36fd981e Mon Sep 17 00:00:00 2001 From: Bjarki Arge Andreasen Date: Fri, 25 Jul 2025 16:20:00 +0200 Subject: [PATCH] pm: device: runtime: Only select EVENTS if PM_DEVICE_RUNTIME_ASYNC The k_event event is only used if CONFIG_PM_DEVICE_RUNTIME_ASYNC is selected, but EVENTS is selected, and the k_event included in the struct pm_device if CONFIG_PM_DEVICE_RUNTIME is selected. Correct to only include event and EVENTS if CONFIG_PM_DEVICE_RUNTIME_ASYNC is selected. This saves us 1 struct event per PM DEVICE. Signed-off-by: Bjarki Arge Andreasen --- include/zephyr/pm/device.h | 7 +++++-- subsys/pm/Kconfig | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/zephyr/pm/device.h b/include/zephyr/pm/device.h index 5badda9fa68f3..3423f2dc4c453 100644 --- a/include/zephyr/pm/device.h +++ b/include/zephyr/pm/device.h @@ -168,9 +168,9 @@ struct pm_device { const struct device *dev; /** Lock to synchronize the get/put operations */ struct k_sem lock; +#if defined(CONFIG_PM_DEVICE_RUNTIME_ASYNC) || defined(__DOXYGEN__) /** Event var to listen to the sync request events */ struct k_event event; -#if defined(CONFIG_PM_DEVICE_RUNTIME_ASYNC) || defined(__DOXYGEN__) /** Work object for asynchronous calls */ struct k_work_delayable work; #endif /* CONFIG_PM_DEVICE_RUNTIME_ASYNC */ @@ -199,10 +199,13 @@ BUILD_ASSERT(offsetof(struct pm_device_isr, base) == 0); /** @cond INTERNAL_HIDDEN */ -#ifdef CONFIG_PM_DEVICE_RUNTIME +#ifdef CONFIG_PM_DEVICE_RUNTIME_ASYNC #define Z_PM_DEVICE_RUNTIME_INIT(obj) \ .lock = Z_SEM_INITIALIZER(obj.lock, 1, 1), \ .event = Z_EVENT_INITIALIZER(obj.event), +#elif CONFIG_PM_DEVICE_RUNTIME +#define Z_PM_DEVICE_RUNTIME_INIT(obj) \ + .lock = Z_SEM_INITIALIZER(obj.lock, 1, 1), #else #define Z_PM_DEVICE_RUNTIME_INIT(obj) #endif /* CONFIG_PM_DEVICE_RUNTIME */ diff --git a/subsys/pm/Kconfig b/subsys/pm/Kconfig index 96bb4c4c00245..1a1001b41877f 100644 --- a/subsys/pm/Kconfig +++ b/subsys/pm/Kconfig @@ -115,7 +115,6 @@ config PM_DEVICE_POWER_DOMAIN_DYNAMIC_NUM config PM_DEVICE_RUNTIME bool "Runtime Device Power Management" - select EVENTS help Enable Runtime Power Management to save power. With device runtime PM enabled, devices can be suspended or resumed based on the device @@ -128,6 +127,7 @@ config PM_DEVICE_DRIVER_NEEDS_DEDICATED_WQ config PM_DEVICE_RUNTIME_ASYNC bool "Asynchronous device runtime power management" + select EVENTS default y help Use this option to enable support for asynchronous operation