fix: Proper use of CONTAINER_OF with delayable work.

This commit is contained in:
Peter Johanson
2023-11-15 00:40:36 +00:00
committed by Pete Johanson
parent 94aa7d8d53
commit f4e6d70465
6 changed files with 13 additions and 6 deletions

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;
}