From d6de8a3acce86136c2d6fe944ab5afbc3e10be86 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Thu, 9 Nov 2023 00:17:44 -0800 Subject: [PATCH] refactor: Move to POST_KERNEL phase for behavior inits. --- app/src/behaviors/behavior_backlight.c | 2 +- app/src/behaviors/behavior_bt.c | 2 +- app/src/behaviors/behavior_caps_word.c | 2 +- app/src/behaviors/behavior_ext_power.c | 2 +- app/src/behaviors/behavior_hold_tap.c | 2 +- app/src/behaviors/behavior_key_press.c | 2 +- app/src/behaviors/behavior_key_repeat.c | 2 +- app/src/behaviors/behavior_key_toggle.c | 2 +- app/src/behaviors/behavior_macro.c | 2 +- app/src/behaviors/behavior_mod_morph.c | 2 +- app/src/behaviors/behavior_momentary_layer.c | 2 +- app/src/behaviors/behavior_mouse_key_press.c | 2 +- app/src/behaviors/behavior_none.c | 2 +- app/src/behaviors/behavior_outputs.c | 2 +- app/src/behaviors/behavior_reset.c | 2 +- app/src/behaviors/behavior_rgb_underglow.c | 2 +- app/src/behaviors/behavior_sensor_rotate.c | 2 +- app/src/behaviors/behavior_sensor_rotate_var.c | 2 +- app/src/behaviors/behavior_sticky_key.c | 2 +- app/src/behaviors/behavior_tap_dance.c | 2 +- app/src/behaviors/behavior_to_layer.c | 2 +- app/src/behaviors/behavior_toggle_layer.c | 2 +- app/src/behaviors/behavior_transparent.c | 2 +- docs/docs/development/new-behavior.mdx | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/src/behaviors/behavior_backlight.c b/app/src/behaviors/behavior_backlight.c index 42967e398c3..3f836b73d76 100644 --- a/app/src/behaviors/behavior_backlight.c +++ b/app/src/behaviors/behavior_backlight.c @@ -91,7 +91,7 @@ static const struct behavior_driver_api behavior_backlight_driver_api = { .locality = BEHAVIOR_LOCALITY_GLOBAL, }; -BEHAVIOR_DT_INST_DEFINE(0, behavior_backlight_init, NULL, NULL, NULL, APPLICATION, +BEHAVIOR_DT_INST_DEFINE(0, behavior_backlight_init, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_backlight_driver_api); #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/behaviors/behavior_bt.c b/app/src/behaviors/behavior_bt.c index 13ea2495891..03bb7d8c898 100644 --- a/app/src/behaviors/behavior_bt.c +++ b/app/src/behaviors/behavior_bt.c @@ -56,7 +56,7 @@ static const struct behavior_driver_api behavior_bt_driver_api = { .binding_released = on_keymap_binding_released, }; -BEHAVIOR_DT_INST_DEFINE(0, behavior_bt_init, NULL, NULL, NULL, APPLICATION, +BEHAVIOR_DT_INST_DEFINE(0, behavior_bt_init, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_bt_driver_api); #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/behaviors/behavior_caps_word.c b/app/src/behaviors/behavior_caps_word.c index 53ea489f846..d9b3f24ec7d 100644 --- a/app/src/behaviors/behavior_caps_word.c +++ b/app/src/behaviors/behavior_caps_word.c @@ -182,7 +182,7 @@ static int behavior_caps_word_init(const struct device *dev) { .continuations_count = DT_INST_PROP_LEN(n, continue_list), \ }; \ BEHAVIOR_DT_INST_DEFINE(n, behavior_caps_word_init, NULL, &behavior_caps_word_data_##n, \ - &behavior_caps_word_config_##n, APPLICATION, \ + &behavior_caps_word_config_##n, POST_KERNEL, \ CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_caps_word_driver_api); DT_INST_FOREACH_STATUS_OKAY(KP_INST) diff --git a/app/src/behaviors/behavior_ext_power.c b/app/src/behaviors/behavior_ext_power.c index 0af30b0081b..a51a9f6dbd6 100644 --- a/app/src/behaviors/behavior_ext_power.c +++ b/app/src/behaviors/behavior_ext_power.c @@ -74,7 +74,7 @@ static const struct behavior_driver_api behavior_ext_power_driver_api = { .locality = BEHAVIOR_LOCALITY_GLOBAL, }; -BEHAVIOR_DT_INST_DEFINE(0, behavior_ext_power_init, NULL, NULL, NULL, APPLICATION, +BEHAVIOR_DT_INST_DEFINE(0, behavior_ext_power_init, NULL, NULL, NULL, POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY, &behavior_ext_power_driver_api); #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 146d5cc5156..8c28531cf42 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -748,7 +748,7 @@ static int behavior_hold_tap_init(const struct device *dev) { .hold_trigger_key_positions_len = DT_INST_PROP_LEN(n, hold_trigger_key_positions), \ }; \ BEHAVIOR_DT_INST_DEFINE(n, behavior_hold_tap_init, NULL, NULL, &behavior_hold_tap_config_##n, \ - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ &behavior_hold_tap_driver_api); DT_INST_FOREACH_STATUS_OKAY(KP_INST) diff --git a/app/src/behaviors/behavior_key_press.c b/app/src/behaviors/behavior_key_press.c index 5374e6dd158..566cfcfba77 100644 --- a/app/src/behaviors/behavior_key_press.c +++ b/app/src/behaviors/behavior_key_press.c @@ -34,7 +34,7 @@ static const struct behavior_driver_api behavior_key_press_driver_api = { .binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released}; #define KP_INST(n) \ - BEHAVIOR_DT_INST_DEFINE(n, behavior_key_press_init, NULL, NULL, NULL, APPLICATION, \ + BEHAVIOR_DT_INST_DEFINE(n, behavior_key_press_init, NULL, NULL, NULL, POST_KERNEL, \ CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_key_press_driver_api); DT_INST_FOREACH_STATUS_OKAY(KP_INST) diff --git a/app/src/behaviors/behavior_key_repeat.c b/app/src/behaviors/behavior_key_repeat.c index bf53c384d71..c93fa722734 100644 --- a/app/src/behaviors/behavior_key_repeat.c +++ b/app/src/behaviors/behavior_key_repeat.c @@ -117,7 +117,7 @@ static int behavior_key_repeat_init(const struct device *dev) { .usage_pages_count = DT_INST_PROP_LEN(n, usage_pages), \ }; \ BEHAVIOR_DT_INST_DEFINE(n, behavior_key_repeat_init, NULL, &behavior_key_repeat_data_##n, \ - &behavior_key_repeat_config_##n, APPLICATION, \ + &behavior_key_repeat_config_##n, POST_KERNEL, \ CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_key_repeat_driver_api); DT_INST_FOREACH_STATUS_OKAY(KR_INST) diff --git a/app/src/behaviors/behavior_key_toggle.c b/app/src/behaviors/behavior_key_toggle.c index db77f81412a..0dc0f5abfdc 100644 --- a/app/src/behaviors/behavior_key_toggle.c +++ b/app/src/behaviors/behavior_key_toggle.c @@ -37,7 +37,7 @@ static const struct behavior_driver_api behavior_key_toggle_driver_api = { }; #define KT_INST(n) \ - BEHAVIOR_DT_INST_DEFINE(n, behavior_key_toggle_init, NULL, NULL, NULL, APPLICATION, \ + BEHAVIOR_DT_INST_DEFINE(n, behavior_key_toggle_init, NULL, NULL, NULL, POST_KERNEL, \ CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_key_toggle_driver_api); DT_INST_FOREACH_STATUS_OKAY(KT_INST) diff --git a/app/src/behaviors/behavior_macro.c b/app/src/behaviors/behavior_macro.c index 1cb76dbd1bc..acffe3d8857 100644 --- a/app/src/behaviors/behavior_macro.c +++ b/app/src/behaviors/behavior_macro.c @@ -225,7 +225,7 @@ static const struct behavior_driver_api behavior_macro_driver_api = { .count = DT_PROP_LEN(inst, bindings), \ .bindings = TRANSFORMED_BEHAVIORS(inst)}; \ BEHAVIOR_DT_DEFINE(inst, behavior_macro_init, NULL, &behavior_macro_state_##inst, \ - &behavior_macro_config_##inst, APPLICATION, \ + &behavior_macro_config_##inst, POST_KERNEL, \ CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_macro_driver_api); DT_FOREACH_STATUS_OKAY(zmk_behavior_macro, MACRO_INST) diff --git a/app/src/behaviors/behavior_mod_morph.c b/app/src/behaviors/behavior_mod_morph.c index 176b0f696ec..3a8bf08c198 100644 --- a/app/src/behaviors/behavior_mod_morph.c +++ b/app/src/behaviors/behavior_mod_morph.c @@ -98,7 +98,7 @@ static int behavior_mod_morph_init(const struct device *dev) { return 0; } }; \ static struct behavior_mod_morph_data behavior_mod_morph_data_##n = {}; \ BEHAVIOR_DT_INST_DEFINE(n, behavior_mod_morph_init, NULL, &behavior_mod_morph_data_##n, \ - &behavior_mod_morph_config_##n, APPLICATION, \ + &behavior_mod_morph_config_##n, POST_KERNEL, \ CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mod_morph_driver_api); DT_INST_FOREACH_STATUS_OKAY(KP_INST) diff --git a/app/src/behaviors/behavior_momentary_layer.c b/app/src/behaviors/behavior_momentary_layer.c index 94da6441e76..0c86e605b55 100644 --- a/app/src/behaviors/behavior_momentary_layer.c +++ b/app/src/behaviors/behavior_momentary_layer.c @@ -40,4 +40,4 @@ static const struct behavior_mo_config behavior_mo_config = {}; static struct behavior_mo_data behavior_mo_data; BEHAVIOR_DT_INST_DEFINE(0, behavior_mo_init, NULL, &behavior_mo_data, &behavior_mo_config, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mo_driver_api); + POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mo_driver_api); diff --git a/app/src/behaviors/behavior_mouse_key_press.c b/app/src/behaviors/behavior_mouse_key_press.c index d4c392ac879..9064a1aa5c8 100644 --- a/app/src/behaviors/behavior_mouse_key_press.c +++ b/app/src/behaviors/behavior_mouse_key_press.c @@ -39,7 +39,7 @@ static const struct behavior_driver_api behavior_mouse_key_press_driver_api = { .binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released}; #define MKP_INST(n) \ - BEHAVIOR_DT_INST_DEFINE(n, behavior_mouse_key_press_init, NULL, NULL, NULL, APPLICATION, \ + BEHAVIOR_DT_INST_DEFINE(n, behavior_mouse_key_press_init, NULL, NULL, NULL, POST_KERNEL, \ CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ &behavior_mouse_key_press_driver_api); diff --git a/app/src/behaviors/behavior_none.c b/app/src/behaviors/behavior_none.c index 57208f36ae1..0137622aceb 100644 --- a/app/src/behaviors/behavior_none.c +++ b/app/src/behaviors/behavior_none.c @@ -33,7 +33,7 @@ static const struct behavior_driver_api behavior_none_driver_api = { .binding_released = on_keymap_binding_released, }; -BEHAVIOR_DT_INST_DEFINE(0, behavior_none_init, NULL, NULL, NULL, APPLICATION, +BEHAVIOR_DT_INST_DEFINE(0, behavior_none_init, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_none_driver_api); #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/behaviors/behavior_outputs.c b/app/src/behaviors/behavior_outputs.c index 1185aaabf2c..d172c3a11b8 100644 --- a/app/src/behaviors/behavior_outputs.c +++ b/app/src/behaviors/behavior_outputs.c @@ -42,7 +42,7 @@ static const struct behavior_driver_api behavior_outputs_driver_api = { .binding_pressed = on_keymap_binding_pressed, }; -BEHAVIOR_DT_INST_DEFINE(0, behavior_out_init, NULL, NULL, NULL, APPLICATION, +BEHAVIOR_DT_INST_DEFINE(0, behavior_out_init, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_outputs_driver_api); #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/behaviors/behavior_reset.c b/app/src/behaviors/behavior_reset.c index 6a2731ecad4..c559f17fd6f 100644 --- a/app/src/behaviors/behavior_reset.c +++ b/app/src/behaviors/behavior_reset.c @@ -44,7 +44,7 @@ static const struct behavior_driver_api behavior_reset_driver_api = { static const struct behavior_reset_config behavior_reset_config_##n = { \ .type = DT_INST_PROP(n, type)}; \ BEHAVIOR_DT_INST_DEFINE(n, behavior_reset_init, NULL, NULL, &behavior_reset_config_##n, \ - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ &behavior_reset_driver_api); DT_INST_FOREACH_STATUS_OKAY(RST_INST) diff --git a/app/src/behaviors/behavior_rgb_underglow.c b/app/src/behaviors/behavior_rgb_underglow.c index 7a478eb781f..a16ee591ed4 100644 --- a/app/src/behaviors/behavior_rgb_underglow.c +++ b/app/src/behaviors/behavior_rgb_underglow.c @@ -149,7 +149,7 @@ static const struct behavior_driver_api behavior_rgb_underglow_driver_api = { .locality = BEHAVIOR_LOCALITY_GLOBAL, }; -BEHAVIOR_DT_INST_DEFINE(0, behavior_rgb_underglow_init, NULL, NULL, NULL, APPLICATION, +BEHAVIOR_DT_INST_DEFINE(0, behavior_rgb_underglow_init, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_rgb_underglow_driver_api); #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/behaviors/behavior_sensor_rotate.c b/app/src/behaviors/behavior_sensor_rotate.c index f77beca188d..94bac506842 100644 --- a/app/src/behaviors/behavior_sensor_rotate.c +++ b/app/src/behaviors/behavior_sensor_rotate.c @@ -37,7 +37,7 @@ static int behavior_sensor_rotate_init(const struct device *dev) { return 0; }; static struct behavior_sensor_rotate_data behavior_sensor_rotate_data_##n = {}; \ BEHAVIOR_DT_INST_DEFINE(n, behavior_sensor_rotate_init, NULL, \ &behavior_sensor_rotate_data_##n, &behavior_sensor_rotate_config_##n, \ - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ &behavior_sensor_rotate_driver_api); DT_INST_FOREACH_STATUS_OKAY(SENSOR_ROTATE_INST) diff --git a/app/src/behaviors/behavior_sensor_rotate_var.c b/app/src/behaviors/behavior_sensor_rotate_var.c index 0d3d22b29e0..65a9ce347ce 100644 --- a/app/src/behaviors/behavior_sensor_rotate_var.c +++ b/app/src/behaviors/behavior_sensor_rotate_var.c @@ -28,7 +28,7 @@ static int behavior_sensor_rotate_var_init(const struct device *dev) { return 0; static struct behavior_sensor_rotate_data behavior_sensor_rotate_var_data_##n = {}; \ BEHAVIOR_DT_INST_DEFINE( \ n, behavior_sensor_rotate_var_init, NULL, &behavior_sensor_rotate_var_data_##n, \ - &behavior_sensor_rotate_var_config_##n, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + &behavior_sensor_rotate_var_config_##n, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ &behavior_sensor_rotate_var_driver_api); DT_INST_FOREACH_STATUS_OKAY(SENSOR_ROTATE_VAR_INST) diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index aabb017eaa1..f1131f66c5d 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -298,7 +298,7 @@ static struct behavior_sticky_key_data behavior_sticky_key_data; .quick_release = DT_INST_PROP(n, quick_release), \ }; \ BEHAVIOR_DT_INST_DEFINE(n, behavior_sticky_key_init, NULL, &behavior_sticky_key_data, \ - &behavior_sticky_key_config_##n, APPLICATION, \ + &behavior_sticky_key_config_##n, POST_KERNEL, \ CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_sticky_key_driver_api); DT_INST_FOREACH_STATUS_OKAY(KP_INST) diff --git a/app/src/behaviors/behavior_tap_dance.c b/app/src/behaviors/behavior_tap_dance.c index 306d5ca760b..40427ef8377 100644 --- a/app/src/behaviors/behavior_tap_dance.c +++ b/app/src/behaviors/behavior_tap_dance.c @@ -251,7 +251,7 @@ static int behavior_tap_dance_init(const struct device *dev) { .behaviors = behavior_tap_dance_config_##n##_bindings, \ .behavior_count = DT_INST_PROP_LEN(n, bindings)}; \ BEHAVIOR_DT_INST_DEFINE(n, behavior_tap_dance_init, NULL, NULL, \ - &behavior_tap_dance_config_##n, APPLICATION, \ + &behavior_tap_dance_config_##n, POST_KERNEL, \ CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_tap_dance_driver_api); DT_INST_FOREACH_STATUS_OKAY(KP_INST) diff --git a/app/src/behaviors/behavior_to_layer.c b/app/src/behaviors/behavior_to_layer.c index 9a58bf602c7..1c87a925905 100644 --- a/app/src/behaviors/behavior_to_layer.c +++ b/app/src/behaviors/behavior_to_layer.c @@ -37,7 +37,7 @@ static const struct behavior_driver_api behavior_to_driver_api = { .binding_released = to_keymap_binding_released, }; -BEHAVIOR_DT_INST_DEFINE(0, behavior_to_init, NULL, NULL, NULL, APPLICATION, +BEHAVIOR_DT_INST_DEFINE(0, behavior_to_init, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_to_driver_api); #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/behaviors/behavior_toggle_layer.c b/app/src/behaviors/behavior_toggle_layer.c index 154cf9cdf40..817462df5aa 100644 --- a/app/src/behaviors/behavior_toggle_layer.c +++ b/app/src/behaviors/behavior_toggle_layer.c @@ -44,6 +44,6 @@ static const struct behavior_tog_config behavior_tog_config = {}; static struct behavior_tog_data behavior_tog_data; BEHAVIOR_DT_INST_DEFINE(0, behavior_tog_init, NULL, &behavior_tog_data, &behavior_tog_config, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_tog_driver_api); + POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_tog_driver_api); #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/behaviors/behavior_transparent.c b/app/src/behaviors/behavior_transparent.c index ddf62ce0ae8..c7bf802b9fc 100644 --- a/app/src/behaviors/behavior_transparent.c +++ b/app/src/behaviors/behavior_transparent.c @@ -33,7 +33,7 @@ static const struct behavior_driver_api behavior_transparent_driver_api = { .binding_released = on_keymap_binding_released, }; -BEHAVIOR_DT_INST_DEFINE(0, behavior_transparent_init, NULL, NULL, NULL, APPLICATION, +BEHAVIOR_DT_INST_DEFINE(0, behavior_transparent_init, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_transparent_driver_api); #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/docs/docs/development/new-behavior.mdx b/docs/docs/development/new-behavior.mdx index aec9a5ae752..d76474fd6fb 100644 --- a/docs/docs/development/new-behavior.mdx +++ b/docs/docs/development/new-behavior.mdx @@ -175,7 +175,7 @@ BEHAVIOR_DT_INST_DEFINE(0, // // Equal to n for behaviors that do make use of multiple instances) _init, NULL, // Initialization Function, Power Management Device Pointer &_data, &_config, // Behavior Data Pointer, Behavior Configuration Pointer (Both Optional) - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, // Initialization Level, Device Priority + POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, // Initialization Level, Device Priority &_driver_api); // API Structure #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */