From 54747a52f909a80c92ddbd1a2fe99d2f32766a90 Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Fri, 6 May 2022 13:14:23 -0500 Subject: [PATCH] fix(sleep): use pm_power_state_force for proper device power management --- app/src/activity.c | 4 ++-- app/src/ext_power_generic.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/activity.c b/app/src/activity.c index 469ccdf7..5a1e2385 100644 --- a/app/src/activity.c +++ b/app/src/activity.c @@ -68,9 +68,9 @@ void activity_work_handler(struct k_work *work) { int32_t inactive_time = current - activity_last_uptime; #if IS_ENABLED(CONFIG_ZMK_SLEEP) if (inactive_time > MAX_SLEEP_MS && !is_usb_power_present()) { - // Put devices in low power mode before sleeping + // Put devices in suspend power mode before sleeping set_state(ZMK_ACTIVITY_SLEEP); - pm_power_state_set((struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0}); + pm_power_state_force(0U, (struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0}); } else #endif /* IS_ENABLED(CONFIG_ZMK_SLEEP) */ if (inactive_time > MAX_IDLE_MS) { diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c index 0743d50d..aab09cec 100644 --- a/app/src/ext_power_generic.c +++ b/app/src/ext_power_generic.c @@ -176,10 +176,10 @@ static int ext_power_generic_init(const struct device *dev) { #ifdef CONFIG_PM_DEVICE static int ext_power_generic_pm_action(const struct device *dev, enum pm_device_action action) { switch (action) { - case PM_DEVICE_ACTION_TURN_ON: + case PM_DEVICE_ACTION_RESUME: ext_power_generic_enable(dev); return 0; - case PM_DEVICE_ACTION_TURN_OFF: + case PM_DEVICE_ACTION_SUSPEND: ext_power_generic_disable(dev); return 0; default: