From 78cb6c8b2115b5eebeddc03d7d8ecff6ba2574a7 Mon Sep 17 00:00:00 2001 From: Nuxiom <61762260+nuxiom@users.noreply.github.com> Date: Sun, 11 Oct 2020 16:57:26 +1100 Subject: [PATCH 1/2] Fix kscan_gpio_irq_callback_handler_##n conditional macro --- app/drivers/zephyr/kscan_gpio_matrix.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index a0b22e4a..ea07ee88 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -181,19 +181,19 @@ static int kscan_gpio_config_interrupts(struct device **devices, struct kscan_gpio_data_##n *data = CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \ kscan_gpio_read_##n(data->dev); \ } \ - COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ - (static void kscan_gpio_irq_callback_handler_##n( \ - struct device *dev, struct gpio_callback *cb, gpio_port_pins_t pin) { \ - struct kscan_gpio_irq_callback_##n *data = \ - CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ - kscan_gpio_disable_interrupts_##n(data->dev); \ - COND_CODE_0(DT_INST_PROP(n, debounce_period), \ - ({ k_work_submit(data->work); }), ({ \ - k_delayed_work_cancel(data->work); \ - k_delayed_work_submit( \ - data->work, K_MSEC(DT_INST_PROP(n, debounce_period))); \ - })) \ - })) \ + static void kscan_gpio_irq_callback_handler_##n( \ + struct device *dev, struct gpio_callback *cb, gpio_port_pins_t pin) { \ + struct kscan_gpio_irq_callback_##n *data = \ + CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ + (kscan_gpio_disable_interrupts_##n(data->dev);)) \ + COND_CODE_0(DT_INST_PROP(n, debounce_period), \ + ({ k_work_submit(data->work); }), ({ \ + k_delayed_work_cancel(data->work); \ + k_delayed_work_submit( \ + data->work, K_MSEC(DT_INST_PROP(n, debounce_period))); \ + })) \ + } \ \ static struct kscan_gpio_data_##n kscan_gpio_data_##n = { \ .rows = {[INST_MATRIX_ROWS(n) - 1] = NULL}, .cols = {[INST_MATRIX_COLS(n) - 1] = NULL}}; \ From 1c0c02e09773413752e5f166a30178073c570349 Mon Sep 17 00:00:00 2001 From: Nuxiom <61762260+nuxiom@users.noreply.github.com> Date: Sun, 11 Oct 2020 17:51:06 +1100 Subject: [PATCH 2/2] Reformatted according to clang-format lint --- app/drivers/zephyr/kscan_gpio_matrix.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index ea07ee88..ec4fb39a 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -181,17 +181,16 @@ static int kscan_gpio_config_interrupts(struct device **devices, struct kscan_gpio_data_##n *data = CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \ kscan_gpio_read_##n(data->dev); \ } \ - static void kscan_gpio_irq_callback_handler_##n( \ - struct device *dev, struct gpio_callback *cb, gpio_port_pins_t pin) { \ + static void kscan_gpio_irq_callback_handler_##n(struct device *dev, struct gpio_callback *cb, \ + gpio_port_pins_t pin) { \ struct kscan_gpio_irq_callback_##n *data = \ CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ (kscan_gpio_disable_interrupts_##n(data->dev);)) \ - COND_CODE_0(DT_INST_PROP(n, debounce_period), \ - ({ k_work_submit(data->work); }), ({ \ + COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(data->work); }), ({ \ k_delayed_work_cancel(data->work); \ - k_delayed_work_submit( \ - data->work, K_MSEC(DT_INST_PROP(n, debounce_period))); \ + k_delayed_work_submit(data->work, \ + K_MSEC(DT_INST_PROP(n, debounce_period))); \ })) \ } \ \