summaryrefslogtreecommitdiff
path: root/tests/power/power_states/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/power/power_states/src/main.c')
-rw-r--r--tests/power/power_states/src/main.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/power/power_states/src/main.c b/tests/power/power_states/src/main.c
index 7d9536c1b..d5a97c030 100644
--- a/tests/power/power_states/src/main.c
+++ b/tests/power/power_states/src/main.c
@@ -32,6 +32,18 @@ static enum power_states states_list[] = {
#define MAX_SUSPEND_DEVICE_COUNT 15
#define NB_STATES ARRAY_SIZE(states_list)
+/* In Tickless Kernel mode, time is passed in milliseconds instead of ticks */
+#ifdef CONFIG_TICKLESS_KERNEL
+#define TICKS_TO_SECONDS_MULTIPLIER 1000
+#define TIME_UNIT_STRING "milliseconds"
+#else
+#define TICKS_TO_SECONDS_MULTIPLIER CONFIG_SYS_CLOCK_TICKS_PER_SEC
+#define TIME_UNIT_STRING "ticks"
+#endif
+
+#define MIN_TIME_TO_SUSPEND ((TIMEOUT * TICKS_TO_SECONDS_MULTIPLIER) - \
+ (TICKS_TO_SECONDS_MULTIPLIER / 2))
+
static struct device *suspend_devices[MAX_SUSPEND_DEVICE_COUNT];
static int suspend_device_count;
static unsigned int current_state = NB_STATES - 1;
@@ -234,9 +246,9 @@ int _sys_soc_suspend(s32_t ticks)
int pm_operation = SYS_PM_NOT_HANDLED;
post_ops_done = 0;
- if (ticks < (TIMEOUT * CONFIG_SYS_CLOCK_TICKS_PER_SEC)) {
- printk("Not enough time for PM operations (ticks: %d).\n",
- ticks);
+ if ((ticks != K_FOREVER) && (ticks < MIN_TIME_TO_SUSPEND)) {
+ printk("Not enough time for PM operations (" TIME_UNIT_STRING
+ ": %d).\n", ticks);
return SYS_PM_NOT_HANDLED;
}