fix(sleep): use pm_power_state_force for proper device power management
This commit is contained in:
parent
d7ba7a1bee
commit
54747a52f9
2 changed files with 4 additions and 4 deletions
|
@ -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) {
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue