From 11ac18abc280bd12ccc108469d059edffb31dcd3 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Mon, 19 Apr 2021 19:36:10 -0700 Subject: [PATCH] power: Add an assert for an unexpected condition Exit latency time should never be greater than the residency time. Just add an assert in case the policy does not properly handle it. Signed-off-by: Flavio Ceolin --- subsys/power/power.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/subsys/power/power.c b/subsys/power/power.c index 9f4b26f8ed..aa958da91e 100644 --- a/subsys/power/power.c +++ b/subsys/power/power.c @@ -182,6 +182,14 @@ enum pm_state pm_system_suspend(int32_t ticks) post_ops_done = 0; if (ticks != K_TICKS_FOREVER) { + /* + * Just a sanity check in case the policy manager does not + * handle this error condition properly. + */ + __ASSERT(z_power_state.min_residency_us >= + z_power_state.exit_latency_us, + "min_residency_us < exit_latency_us"); + /* * We need to set the timer to interrupt a little bit early to * accommodate the time required by the CPU to fully wake up.