forked from kofal.net/zmk
chore: Various soft-off review fixes
* Code style to avoid goto. * Enable pm.c compilation via dedicated Kconfig flag. * Comment wakeup trigger PM behavior.
This commit is contained in:
@@ -39,18 +39,17 @@ static int gpio_key_wakeup_trigger_pm_resume(const struct device *dev) {
|
||||
int ret = gpio_pin_interrupt_configure_dt(&config->trigger, GPIO_INT_LEVEL_ACTIVE);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Failed to configure wakeup trigger key GPIO pin interrupt (%d)", ret);
|
||||
goto exit;
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (int i = 0; i < config->extra_gpios_count; i++) {
|
||||
ret = gpio_pin_configure_dt(&config->extra_gpios[i], GPIO_OUTPUT_ACTIVE);
|
||||
if (ret < 0) {
|
||||
LOG_WRN("Failed to set extra GPIO pin active for waker (%d)", ret);
|
||||
goto exit;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -62,9 +61,20 @@ static int gpio_key_wakeup_trigger_pm_suspend(const struct device *dev) {
|
||||
LOG_ERR("Failed to configure wakeup trigger key GPIO pin interrupt (%d)", ret);
|
||||
}
|
||||
|
||||
for (int i = 0; i < config->extra_gpios_count; i++) {
|
||||
ret = gpio_pin_configure_dt(&config->extra_gpios[i], GPIO_DISCONNECTED);
|
||||
if (ret < 0) {
|
||||
LOG_WRN("Failed to set extra GPIO pin disconnected for waker (%d)", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// The waker is "backwards", in as much as it is designed to be resumed/enabled immediately
|
||||
// before a soft-off state is entered, so it can wake the device from that state later.
|
||||
// So this waker correctly resumes and is ready to wake the device later.
|
||||
static int gpio_key_wakeup_trigger_pm_action(const struct device *dev,
|
||||
enum pm_device_action action) {
|
||||
switch (action) {
|
||||
|
||||
@@ -15,6 +15,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||
|
||||
#include <zmk/endpoints.h>
|
||||
|
||||
#if IS_ENABLED(CONFIG_ZMK_PM_SOFT_OFF)
|
||||
|
||||
#define HAS_WAKERS DT_HAS_COMPAT_STATUS_OKAY(zmk_soft_off_wakeup_sources)
|
||||
|
||||
#if HAS_WAKERS
|
||||
@@ -63,3 +65,5 @@ int zmk_pm_soft_off(void) {
|
||||
LOG_DBG("soft-off: go to sleep");
|
||||
return pm_state_force(0U, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0});
|
||||
}
|
||||
|
||||
#endif // IS_ENABLED(CONFIG_ZMK_PM_SOFT_OFF)
|
||||
Reference in New Issue
Block a user