Skip to content

Commit

Permalink
refactor(drivers): Use proper init stage/priority.
Browse files Browse the repository at this point in the history
* Avoid APPLICATION stage and use the proper earlier stage for
  kscan drivers.
  • Loading branch information
petejohanson committed Sep 14, 2023
1 parent bf8e03c commit af5f5a6
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 12 deletions.
6 changes: 0 additions & 6 deletions app/module/drivers/kscan/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,4 @@ config ZMK_KSCAN_DEBOUNCE_RELEASE_MS

endif

# config ZMK_KSCAN_INIT_PRIORITY
# int "Keyboard scan driver init priority"
# default 40
# help
# Keyboard scan device driver initialization priority.

endif # KSCAN
2 changes: 1 addition & 1 deletion app/module/drivers/kscan/kscan_composite.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ static const struct kscan_composite_config kscan_composite_config = {};
static struct kscan_composite_data kscan_composite_data;

DEVICE_DT_INST_DEFINE(0, kscan_composite_init, NULL, &kscan_composite_data, &kscan_composite_config,
APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &mock_driver_api);
POST_KERNEL, CONFIG_KSCAN_INIT_PRIORITY, &mock_driver_api);
2 changes: 1 addition & 1 deletion app/module/drivers/kscan/kscan_gpio_demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
}; \
\
DEVICE_DT_INST_DEFINE(n, kscan_gpio_init_##n, NULL, &kscan_gpio_data_##n, \
&kscan_gpio_config_##n, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY, \
&kscan_gpio_config_##n, POST_KERNEL, CONFIG_KSCAN_INIT_PRIORITY, \
&gpio_driver_api_##n);

DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT)
2 changes: 1 addition & 1 deletion app/module/drivers/kscan/kscan_gpio_direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static const struct kscan_driver_api kscan_direct_api = {
}; \
\
DEVICE_DT_INST_DEFINE(n, &kscan_direct_init, NULL, &kscan_direct_data_##n, \
&kscan_direct_config_##n, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY, \
&kscan_direct_config_##n, POST_KERNEL, CONFIG_KSCAN_INIT_PRIORITY, \
&kscan_direct_api);

DT_INST_FOREACH_STATUS_OKAY(KSCAN_DIRECT_INIT);
2 changes: 1 addition & 1 deletion app/module/drivers/kscan/kscan_gpio_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ static const struct kscan_driver_api kscan_matrix_api = {
}; \
\
DEVICE_DT_INST_DEFINE(n, &kscan_matrix_init, NULL, &kscan_matrix_data_##n, \
&kscan_matrix_config_##n, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY, \
&kscan_matrix_config_##n, POST_KERNEL, CONFIG_KSCAN_INIT_PRIORITY, \
&kscan_matrix_api);

DT_INST_FOREACH_STATUS_OKAY(KSCAN_MATRIX_INIT);
4 changes: 2 additions & 2 deletions app/module/drivers/kscan/kscan_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static int kscan_mock_configure(const struct device *dev, kscan_callback_t callb
static const struct kscan_mock_config_##n kscan_mock_config_##n = { \
.events = DT_INST_PROP(n, events), .exit_after = DT_INST_PROP(n, exit_after)}; \
DEVICE_DT_INST_DEFINE(n, kscan_mock_init_##n, NULL, &kscan_mock_data_##n, \
&kscan_mock_config_##n, APPLICATION, \
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &mock_driver_api_##n);
&kscan_mock_config_##n, POST_KERNEL, CONFIG_KSCAN_INIT_PRIORITY, \
&mock_driver_api_##n);

DT_INST_FOREACH_STATUS_OKAY(MOCK_INST_INIT)

0 comments on commit af5f5a6

Please sign in to comment.