diff --git a/app/Kconfig b/app/Kconfig index 5f634a0a2192..6ad93d015bc0 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -504,7 +504,7 @@ if ZMK_KSCAN_SIDEBAND_BEHAVIORS config ZMK_KSCAN_SIDEBAND_BEHAVIORS_INIT_PRIORITY int "Keyboard scan sideband behaviors driver init priority" - # The default kscan init priority is 90, so be sure we are lower. + # The default kscan init priority is 90, so be sure we are initialized later. default 95 endif # ZMK_KSCAN_SIDEBAND_BEHAVIORS diff --git a/app/src/kscan_sideband_behaviors.c b/app/src/kscan_sideband_behaviors.c index 5b8a30a85e3c..a0ebd49acd67 100644 --- a/app/src/kscan_sideband_behaviors.c +++ b/app/src/kscan_sideband_behaviors.c @@ -41,34 +41,31 @@ struct ksbb_data { // KSBBs to check when a kscan callback from the "wrapped" inner kscan fires. static const struct device *ksbbs[] = {DT_INST_FOREACH_STATUS_OKAY(GET_KSBB_DEV)}; -int find_ksbb_for_inner(const struct device *inner_dev, const struct device **ksbb_dev) { +const struct device *find_ksbb_for_inner(const struct device *inner_dev) { for (int i = 0; i < ARRAY_SIZE(ksbbs); i++) { const struct device *ksbb = ksbbs[i]; const struct ksbb_config *cfg = ksbb->config; if (cfg->kscan == inner_dev) { - *ksbb_dev = ksbb; - return 0; + return ksbb; } } - return -ENODEV; + return NULL; } -int find_sideband_behavior(const struct device *dev, uint32_t row, uint32_t column, - struct ksbb_entry **entry) { +struct ksbb_entry *find_sideband_behavior(const struct device *dev, uint32_t row, uint32_t column) { const struct ksbb_config *cfg = dev->config; for (int e = 0; e < cfg->entries_len; e++) { struct ksbb_entry *candidate = &cfg->entries[e]; if (candidate->row == row && candidate->column == column) { - *entry = candidate; - return 0; + return candidate; } } - return -ENODEV; + return NULL; } void ksbb_inner_kscan_callback(const struct device *dev, uint32_t row, uint32_t column, @@ -76,9 +73,9 @@ void ksbb_inner_kscan_callback(const struct device *dev, uint32_t row, uint32_t struct ksbb_entry *entry = NULL; const struct device *ksbb = NULL; - if (find_ksbb_for_inner(dev, &ksbb) >= 0) { + if ((ksbb = find_ksbb_for_inner(dev)) != NULL) { struct ksbb_data *data = ksbb->data; - if (find_sideband_behavior(ksbb, row, column, &entry) >= 0) { + if ((entry = find_sideband_behavior(ksbb, row, column)) != NULL) { struct zmk_behavior_binding_event event = {.position = INT32_MAX, .timestamp = k_uptime_get()};