diff options
author | Peter Johanson <[email protected]> | 2023-11-15 00:40:36 +0000 |
---|---|---|
committer | Pete Johanson <[email protected]> | 2024-02-09 14:32:46 -0800 |
commit | f4e6d704652e0cfc46bd0018deb6cddeb8c1b9ca (patch) | |
tree | 65bc369df5d27868e910d92a7c0f50fc1eeeaff6 | |
parent | 94aa7d8d532f1e84e8e8b9fa96c522468dfc259d (diff) | |
download | zmk-f4e6d704652e0cfc46bd0018deb6cddeb8c1b9ca.tar.gz zmk-f4e6d704652e0cfc46bd0018deb6cddeb8c1b9ca.zip |
fix: Proper use of CONTAINER_OF with delayable work.
-rw-r--r-- | app/module/drivers/kscan/kscan_gpio_demux.c | 4 | ||||
-rw-r--r-- | app/module/drivers/kscan/kscan_gpio_matrix.c | 2 | ||||
-rw-r--r-- | app/module/drivers/kscan/kscan_mock.c | 3 | ||||
-rw-r--r-- | app/src/behaviors/behavior_hold_tap.c | 3 | ||||
-rw-r--r-- | app/src/behaviors/behavior_sticky_key.c | 3 | ||||
-rw-r--r-- | app/src/behaviors/behavior_tap_dance.c | 4 |
6 files changed, 13 insertions, 6 deletions
diff --git a/app/module/drivers/kscan/kscan_gpio_demux.c b/app/module/drivers/kscan/kscan_gpio_demux.c index 2cbe116d9f..10433c5a1d 100644 --- a/app/module/drivers/kscan/kscan_gpio_demux.c +++ b/app/module/drivers/kscan/kscan_gpio_demux.c @@ -9,6 +9,7 @@ #include <zephyr/device.h> #include <zephyr/drivers/kscan.h> #include <zephyr/drivers/gpio.h> +#include <zephyr/kernel.h> #include <zephyr/logging/log.h> LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -105,7 +106,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); } \ \ static void kscan_gpio_work_handler_##n(struct k_work *work) { \ - struct kscan_gpio_data_##n *data = CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \ + struct k_work_delayable *d_work = k_work_delayable_from_work(work); \ + struct kscan_gpio_data_##n *data = CONTAINER_OF(d_work, struct kscan_gpio_data_##n, work); \ kscan_gpio_read_##n(data->dev); \ } \ \ diff --git a/app/module/drivers/kscan/kscan_gpio_matrix.c b/app/module/drivers/kscan/kscan_gpio_matrix.c index 0d8a319065..6e91bf95fb 100644 --- a/app/module/drivers/kscan/kscan_gpio_matrix.c +++ b/app/module/drivers/kscan/kscan_gpio_matrix.c @@ -290,7 +290,7 @@ static int kscan_matrix_read(const struct device *dev) { } static void kscan_matrix_work_handler(struct k_work *work) { - struct k_work_delayable *dwork = CONTAINER_OF(work, struct k_work_delayable, work); + struct k_work_delayable *dwork = k_work_delayable_from_work(work); struct kscan_matrix_data *data = CONTAINER_OF(dwork, struct kscan_matrix_data, work); kscan_matrix_read(data->dev); } diff --git a/app/module/drivers/kscan/kscan_mock.c b/app/module/drivers/kscan/kscan_mock.c index 187a16867e..1ffb937e8c 100644 --- a/app/module/drivers/kscan/kscan_mock.c +++ b/app/module/drivers/kscan/kscan_mock.c @@ -62,7 +62,8 @@ static int kscan_mock_configure(const struct device *dev, kscan_callback_t callb } \ } \ static void kscan_mock_work_handler_##n(struct k_work *work) { \ - struct kscan_mock_data *data = CONTAINER_OF(work, struct kscan_mock_data, work); \ + struct k_work_delayable *d_work = k_work_delayable_from_work(work); \ + struct kscan_mock_data *data = CONTAINER_OF(d_work, struct kscan_mock_data, work); \ const struct kscan_mock_config_##n *cfg = data->dev->config; \ uint32_t ev = cfg->events[data->event_index]; \ LOG_DBG("ev %u row %d column %d state %d\n", ev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), \ diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 8c28531cf4..efc96c1a3f 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -710,7 +710,8 @@ ZMK_SUBSCRIPTION(behavior_hold_tap, zmk_position_state_changed); ZMK_SUBSCRIPTION(behavior_hold_tap, zmk_keycode_state_changed); void behavior_hold_tap_timer_work_handler(struct k_work *item) { - struct active_hold_tap *hold_tap = CONTAINER_OF(item, struct active_hold_tap, work); + struct k_work_delayable *d_work = k_work_delayable_from_work(item); + struct active_hold_tap *hold_tap = CONTAINER_OF(d_work, struct active_hold_tap, work); if (hold_tap->work_is_cancelled) { clear_hold_tap(hold_tap); diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index f1131f66c5..05f6846be1 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -262,8 +262,9 @@ static int sticky_key_keycode_state_changed_listener(const zmk_event_t *eh) { } void behavior_sticky_key_timer_handler(struct k_work *item) { + struct k_work_delayable *d_work = k_work_delayable_from_work(item); struct active_sticky_key *sticky_key = - CONTAINER_OF(item, struct active_sticky_key, release_timer); + CONTAINER_OF(d_work, struct active_sticky_key, release_timer); if (sticky_key->position == ZMK_BHV_STICKY_KEY_POSITION_FREE) { return; } diff --git a/app/src/behaviors/behavior_tap_dance.c b/app/src/behaviors/behavior_tap_dance.c index 40427ef837..4f6fa1a134 100644 --- a/app/src/behaviors/behavior_tap_dance.c +++ b/app/src/behaviors/behavior_tap_dance.c @@ -169,7 +169,9 @@ static int on_tap_dance_binding_released(struct zmk_behavior_binding *binding, } void behavior_tap_dance_timer_handler(struct k_work *item) { - struct active_tap_dance *tap_dance = CONTAINER_OF(item, struct active_tap_dance, release_timer); + struct k_work_delayable *d_work = k_work_delayable_from_work(item); + struct active_tap_dance *tap_dance = + CONTAINER_OF(d_work, struct active_tap_dance, release_timer); if (tap_dance->position == ZMK_BHV_TAP_DANCE_POSITION_FREE) { return; } |