summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2021-03-02 11:10:21 -0500
committerPete Johanson <peter@peterjohanson.com>2021-09-14 20:48:28 -0400
commitc9a671d8d5f6144771e3835322ce421012c39375 (patch)
tree7918bd3f5762732d112b183a37cc043ffec21cad /app
parente42590a049f256953ba7edfa4d7cd7f8280731b9 (diff)
fix(kscan): Allow composite driver to handle missing children.
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.
Diffstat (limited to 'app')
-rw-r--r--app/drivers/kscan/kscan_composite.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/drivers/kscan/kscan_composite.c b/app/drivers/kscan/kscan_composite.c
index 2aeb047..0d40c6f 100644
--- a/app/drivers/kscan/kscan_composite.c
+++ b/app/drivers/kscan/kscan_composite.c
@@ -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;
}
@@ -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;
}