From 5d658206dfcd24c1906a13a5a3fdb1ca7de2f4fa Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sun, 23 Jan 2022 16:43:58 +0900 Subject: [PATCH] Check if any device is busy before sleep Some devices might be in the middle of something that can't be interrupted. Device drivers can communicate with the power management module with the device busy API but the pm module also needs to check the busy flags. --- app/src/power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/power.c b/app/src/power.c index 47ef3a3b..f168ce87 100644 --- a/app/src/power.c +++ b/app/src/power.c @@ -24,7 +24,7 @@ bool is_usb_power_present() { } struct pm_state_info pm_policy_next_state(int32_t ticks) { - if (zmk_activity_get_state() == ZMK_ACTIVITY_SLEEP && !is_usb_power_present()) { + if (zmk_activity_get_state() == ZMK_ACTIVITY_SLEEP && !is_usb_power_present() && !device_any_busy_check()) { return (struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0}; }