Skip to content

Conversation

@graysky2
Copy link

@graysky2 graysky2 commented Dec 27, 2025

Add version checks to support both old and new timer APIs across different kernel versions:

  • Use timer_delete_sync() on kernels >= 6.1, fall back to del_timer_sync() on older kernels. The timer_delete_sync() function was introduced in kernel 6.1 as a replacement for del_timer_sync().
  • Use from_timer() for timer callbacks on kernels >= 4.15, fall back to container_of() on older kernels. The from_timer() macro was introduced in kernel 4.15 as part of the timer API modernization.
  • Use hrtimer_setup() on kernels >= 4.15, fall back to manual hrtimer_init() and function assignment on older kernels. The hrtimer_setup() helper was introduced alongside the timer callback changes in kernel 4.15.
  • Use timer_container_of() on kernels >= 6.16, and container_of() for older kernels. Since the minimum supported kernel is currently 6.12, there is no need to add container_of() for older kernels.

@namiltd
Copy link
Contributor

namiltd commented Dec 27, 2025

The timer_delete_sync() and container_of() functions will also work in kernel 6.12.
You should set the kernel version switch to either the minimum version on which it will work or the maximum version on which the function it replaces will work, not 6.18 everywhere.

@graysky2 graysky2 changed the title mt76: add kernel 6.18 timer API compatibility mt76: add kernel version compatibility for timer APIs Dec 27, 2025
@graysky2
Copy link
Author

How is the latest commit

@namiltd
Copy link
Contributor

namiltd commented Dec 28, 2025

There is also a function/macro timer_container_of() (since v6.16) Look at lwfinger/rtw88#373

@graysky2
Copy link
Author

Thanks for your review!

Add version checks to support both old and new timer APIs across
different kernel versions:

- Use timer_delete_sync() on kernels >= 6.1, fall back to
  del_timer_sync() on older kernels. The timer_delete_sync() function
  was introduced in kernel 6.1 as a replacement for del_timer_sync().

- Use from_timer() for timer callbacks on kernels >= 4.15, fall back
  to container_of() on older kernels. The from_timer() macro was
  introduced in kernel 4.15 as part of the timer API modernization.

- Use hrtimer_setup() on kernels >= 4.15, fall back to manual
  hrtimer_init() and function assignment on older kernels. The
  hrtimer_setup() helper was introduced alongside the timer callback
  changes in kernel 4.15.

- Use timer_container_of() on kernels >= 6.16 and container_of() for
  older kernels. Since the minimum supported kernel is currently 6.12,
  there is no need to add container_of() for older kernels.

Signed-off-by: John Audia <therealgraysky@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants