Skip to content

Commit

Permalink
fix(kscan): Allow composite driver to handle missing children.
Browse files Browse the repository at this point in the history
For split keyboards using an IO expander over TRRS/i2c, if the
right half isn't connected, we should be able to gracefully
fallback to the left side still working.
  • Loading branch information
petejohanson committed Sep 14, 2021
1 parent 97dbae8 commit c36021f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/drivers/kscan/kscan_composite.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ static int kscan_composite_enable_callback(const struct device *dev) {
for (int i = 0; i < ARRAY_SIZE(kscan_composite_children); i++) {
const struct kscan_composite_child_config *cfg = &kscan_composite_children[i];

kscan_enable_callback(device_get_binding(cfg->label));
const struct device *dev = device_get_binding(cfg->label);
if (!dev) {
LOG_WRN("Failed to load child kscan device %s", log_strdup(cfg->label));
continue;
}
kscan_enable_callback(dev);
}
return 0;
}
Expand All @@ -50,7 +55,12 @@ static int kscan_composite_disable_callback(const struct device *dev) {
for (int i = 0; i < ARRAY_SIZE(kscan_composite_children); i++) {
const struct kscan_composite_child_config *cfg = &kscan_composite_children[i];

kscan_disable_callback(device_get_binding(cfg->label));
const struct device *dev = device_get_binding(cfg->label);
if (!dev) {
LOG_WRN("Failed to load child kscan device %s", log_strdup(cfg->label));
continue;
}
kscan_disable_callback(dev);
}
return 0;
}
Expand Down

0 comments on commit c36021f

Please sign in to comment.