chore(lighting): fix deprecation

Removed deprecated macros, replace with correct Zephyr 3 implementation
This commit is contained in:
ReFil 2022-09-13 13:45:52 +01:00 committed by Pete Johanson
parent 3f28a55452
commit cc6dd5fc49

View file

@ -75,7 +75,7 @@ static void backlight_save_work_handler(struct k_work *work) {
settings_save_one("backlight/state", &state, sizeof(state)); settings_save_one("backlight/state", &state, sizeof(state));
} }
static K_DELAYED_WORK_DEFINE(backlight_save_work, backlight_save_work_handler); static struct k_work_delayable backlight_save_work;
#endif #endif
static int zmk_backlight_init(const struct device *_arg) { static int zmk_backlight_init(const struct device *_arg) {
@ -90,6 +90,7 @@ static int zmk_backlight_init(const struct device *_arg) {
if (rc != 0) { if (rc != 0) {
LOG_ERR("Failed to load backlight settings: %d", rc); LOG_ERR("Failed to load backlight settings: %d", rc);
} }
k_work_init_delayable(&backlight_save_work, backlight_save_work_handler);
#endif #endif
#if IS_ENABLED(CONFIG_ZMK_BACKLIGHT_AUTO_OFF_USB) #if IS_ENABLED(CONFIG_ZMK_BACKLIGHT_AUTO_OFF_USB)
state.on = zmk_usb_is_powered(); state.on = zmk_usb_is_powered();
@ -104,8 +105,8 @@ static int zmk_backlight_update_and_save() {
} }
#if IS_ENABLED(CONFIG_SETTINGS) #if IS_ENABLED(CONFIG_SETTINGS)
k_delayed_work_cancel(&backlight_save_work); int ret = k_work_reschedule(&backlight_save_work, K_MSEC(CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE));
return k_delayed_work_submit(&backlight_save_work, K_MSEC(CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE)); return MIN(ret, 0);
#else #else
return 0; return 0;
#endif #endif