Skip to content

Compile error on kernel releases >6.15: solved #93

Description

@ewaldc

When compiling the latest version 9.016.01-1 for kernel 6.18.21, I received following error:

r8125_ptp.c:1216:17: error: implicit declaration of function ‘hrtimer_init’; did you mean ‘hrtimers_init’? [-Wimplicit-function-declaration]
 1216 |                 hrtimer_init(&tp->pps_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
      |                 ^~~~~~~~~~~~
      |                 hrtimers_init

The issue: as of 6.15, hrtimer_init was retired in favor of hrtimer_setup which combines the initialization and the registration of the callback function.

Patch:

--- r8125_ptp.c.orig	2026-04-12 20:27:41.832081881 +0200
+++ r8125_ptp.c	2026-04-12 19:32:00.718049905 +0200
@@ -1213,7 +1213,12 @@
         switch (tp->HwSuppPtpVer) {
         case 3:
                 tp->pps_enable = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
 	            hrtimer_setup(&tp->pps_timer, rtl8125_phy_hrtimer_for_pps, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+#else
+                hrtimer_init(&tp->pps_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+                tp->pps_timer.function = rtl8125_phy_hrtimer_for_pps;
+#endif
                 break;
         default:
                 break;

Will test and report back.
Thanks for your great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions