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.
This commit is contained in:
Kan-Ru Chen 2022-01-23 16:43:58 +09:00 committed by GitHub
parent 2ad8f687c0
commit 5d658206df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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};
}