dahdi-linux: forward-port to 6.18 kernel APIs, fix build flags

This patchset updates DAHDI 3.4.0 to build cleanly on Linux 6.18 and
modern OpenWrt toolchains. Changes include:

* Add kernel API compatibility shims:
  - Provide hrtimer_init() wrapper using hrtimer_setup()
  - Restore from_timer() helper
  - Map del_timer*() to timer_delete*() on >= 6.15, aligning with
    upstream PR #93[1].

* Replace deprecated EXTRA_CFLAGS with ccflags-y across all Kbuilds
  to match upstream kernel changes and resolve build failures. Relating
  to oct612x include paths using ccflags-y, aligning with upstream
  PR #76.[2]

* Use out-of-tree OSLEC for Linux 6.18

* Minor Makefile adjustments for OpenWrt packaging consistency.

These changes collectively restore a complete, warning-free build of
DAHDI 3.4.0 on Linux 6.18 while preserving compatibility with existing
drivers and OpenWrt module packaging.

1. https://github.com/asterisk/dahdi-linux/issues/93
2. https://github.com/asterisk/dahdi-linux/issues/76

Signed-off-by: John Audia <therealgraysky@proton.me>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
graysky
2025-12-25 10:32:44 -05:00
committed by Daniel Golle
parent 38a89346b0
commit 4d8d33a023
3 changed files with 242 additions and 2 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=dahdi-linux
PKG_VERSION:=3.4.0
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/asterisk/$(PKG_NAME)/releases/download/v$(PKG_VERSION)
@@ -42,7 +42,7 @@ endef
define KernelPackage/dahdi-echocan-oslec
SUBMENU:=Voice over IP
TITLE:=DAHDI OSLEC echo canceller support
DEPENDS:=kmod-dahdi +kmod-echo
DEPENDS:=kmod-dahdi +LINUX_6_12:kmod-echo +!LINUX_6_12:kmod-oslec
URL:=http://www.asterisk.org/
FILES:=$(PKG_BUILD_DIR)/drivers/dahdi/dahdi_echocan_oslec.$(LINUX_KMOD_SUFFIX)
AUTOLOAD:=$(call AutoProbe,dahdi_echocan_oslec)
@@ -0,0 +1,44 @@
--- a/include/dahdi/kernel.h
+++ b/include/dahdi/kernel.h
@@ -58,6 +58,15 @@
#include <linux/poll.h>
+/* Added for DAHDI use of hrtimers (hrtimer_init, etc.) */
+#include <linux/hrtimer.h>
+
+/* del_timer[_sync] was renamed to timer_delete[_sync] in newer kernels */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
+#define del_timer timer_delete
+#define del_timer_sync timer_delete_sync
+#endif
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
#define netif_napi_add netif_napi_add_weight
#endif
@@ -66,6 +75,25 @@
#include <linux/pci.h>
#include <linux/dma-mapping.h>
+/* DAHDI expects hrtimer_init(), but kernels >= 6.8 removed it.
+ * Recreate it using the modern hrtimer_setup() API.
+ */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
+static inline void hrtimer_init(struct hrtimer *timer,
+ clockid_t clock_id,
+ enum hrtimer_mode mode)
+{
+ /* No callback yet — DAHDI sets it later with hrtimer_update_function() */
+ hrtimer_setup(timer, NULL, clock_id, mode);
+}
+#endif
+
+/* from_timer() helper was removed in newer kernels; restore it for DAHDI. */
+#ifndef from_timer
+#define from_timer(var, callback_timer, timer_fieldname) \
+ container_of(callback_timer, typeof(*var), timer_fieldname)
+#endif
+
static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle)
{
return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
@@ -0,0 +1,196 @@
From ec88adb782aed38c3445c20d20213c51dae7e092 Mon Sep 17 00:00:00 2001
From: InterLinked1 <24227567+InterLinked1@users.noreply.github.com>
Date: Fri, 21 Feb 2025 21:42:19 -0500
Subject: [PATCH] Kbuild: Use ccflags-y instead of EXTRA_CFLAGS.
ccflags-y was added to the kernel back in 2007, in commit
f77bf01425b11947eeb3b5b54. Recent kernel commit
dbd83ea09699390892e5efecddd74ae43a00f071 has now completely
removed the deprecated EXTRA_CFLAGS.
Comments in Kbuild and the Makefile for the oct612x library were
added back when it was created in 2013 in commit f65299e8b2e6ffb0b07089759f8c4ff33a695c09
to use the newer ccflags-y based on the kernel version,
but the change was never made to conditionally move away
from the EXTRA_CFLAGS.
Now that the older way no longer exists, always use ccflags-y.
Resolves: #76
---
drivers/dahdi/Kbuild | 4 ++--
drivers/dahdi/oct612x/Kbuild | 5 +----
drivers/dahdi/oct612x/Makefile | 5 +----
drivers/dahdi/opvxa1200/Kbuild | 6 +++---
drivers/dahdi/voicebus/Kbuild | 4 ++--
drivers/dahdi/wcb4xxp/Kbuild | 2 +-
drivers/dahdi/wct4xxp/Kbuild | 6 +++---
drivers/dahdi/wctc4xxp/Kbuild | 4 ++--
drivers/dahdi/wctdm24xxp/Kbuild | 2 +-
drivers/dahdi/wcte12xp/Kbuild | 2 +-
drivers/dahdi/xpp/Kbuild | 4 ++--
11 files changed, 19 insertions(+), 25 deletions(-)
--- a/drivers/dahdi/Kbuild
+++ b/drivers/dahdi/Kbuild
@@ -83,13 +83,13 @@ CFLAGS_MODULE += -I$(DAHDI_INCLUDE) -I$(
BAD_KERNELS_VERS := 22 34 34.0.1 34.0.2
BAD_KERNELS := $(foreach ver,$(BAD_KERNELS_VERS),2.6.9-$(ver).EL 2.6.9-$(ver).ELsmp)
ifneq (,$(filter $(KVERS),$(BAD_KERNELS)))
-EXTRA_CFLAGS+=-Drw_lock_t=rwlock_t
+ccflags-y+=-Drw_lock_t=rwlock_t
endif
# A number of Fedora 10 (9 also?) kernels backported hrtimer to 2.6.27
# as part of an ALSA backport. TODO: Any better way to detect that?
ifeq (1,$(shell fgrep -q ' hrtimer_set_expires' include/linux/hrtimer.h 2>/dev/null && echo 1))
-EXTRA_CFLAGS+=-DHAVE_HRTIMER_ACCESSORS=1
+ccflags-y+=-DHAVE_HRTIMER_ACCESSORS=1
endif
ifeq (1,$(shell fgrep -q 'wait_for_completion_timeout' include/linux/completion.h 2>/dev/null && echo 1))
--- a/drivers/dahdi/oct612x/Kbuild
+++ b/drivers/dahdi/oct612x/Kbuild
@@ -24,9 +24,6 @@ octapi_files = octdeviceapi/oct6100api/o
apilib/llman/octapi_llman.o \
oct612x-user.o
-# TODO: ccflags was added in 2.6.24 in commit f77bf01425b11947eeb3b5b54. This
-# should be changed to a conditional compilation based on the Kernel Version.
-# ccflags-y := -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
-EXTRA_CFLAGS = -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
+ccflags-y := -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_OCT612X) := oct612x.o
oct612x-objs := $(octapi_files)
--- a/drivers/dahdi/oct612x/Makefile
+++ b/drivers/dahdi/oct612x/Makefile
@@ -23,8 +23,5 @@ octapi_files = octdeviceapi/oct6100api/o
apilib/largmath/octapi_largmath.o \
apilib/llman/octapi_llman.o
-# TODO: ccflags was added in 2.6.24 in commit f77bf01425b11947eeb3b5b54. This
-# should be changed to a conditional compilation based on the Kernel Version.
-# ccflags-y := -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
-EXTRA_CFLAGS = -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
+ccflags-y := -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
lib-y := $(octapi_files)
--- a/drivers/dahdi/opvxa1200/Kbuild
+++ b/drivers/dahdi/opvxa1200/Kbuild
@@ -1,6 +1,6 @@
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_OPVXA1200) += opvxa1200.o
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef -Wno-error=unused-variable
+ccflags-y += -I$(src)/.. -Wno-undef -Wno-error=unused-variable
opvxa1200-objs := base.o
@@ -10,10 +10,10 @@ ifneq ($(DAHDI_KERNEL_H_PATH),)
DAHDI_SPAN_MODULE:=$(shell if grep -C 5 "struct dahdi_span {" $(DAHDI_KERNEL_H_PATH) | grep -q "struct module \*owner"; then echo "yes"; else echo "no"; fi)
DAHDI_SPAN_OPS:=$(shell if grep -q "struct dahdi_span_ops {" $(DAHDI_KERNEL_H_PATH); then echo "yes"; else echo "no"; fi)
ifeq ($(DAHDI_SPAN_MODULE),yes)
- EXTRA_CFLAGS+=-DDAHDI_SPAN_MODULE
+ ccflags-y+=-DDAHDI_SPAN_MODULE
else
ifeq ($(DAHDI_SPAN_OPS),yes)
- EXTRA_CFLAGS+=-DDAHDI_SPAN_OPS
+ ccflags-y+=-DDAHDI_SPAN_OPS
endif
endif
endif
--- a/drivers/dahdi/voicebus/Kbuild
+++ b/drivers/dahdi/voicebus/Kbuild
@@ -8,10 +8,10 @@ ifneq ($(HOTPLUG_FIRMWARE),yes)
dahdi_voicebus-objs += $(FIRM_DIR)/dahdi-fw-vpmoct032.o
$(warning WARNING: You are compiling firmware into voicebus.ko which is not available under the terms of the GPL. It may be a violation of the GPL to distribute the resulting image since it combines both GPL and non-GPL work. You should consult a lawyer of your own before distributing such an image.)
else
- EXTRA_CFLAGS+=-DHOTPLUG_FIRMWARE
+ ccflags-y+=-DHOTPLUG_FIRMWARE
endif
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef
+ccflags-y += -I$(src)/.. -Wno-undef
$(obj)/$(FIRM_DIR)/dahdi-fw-vpmoct032.o: $(obj)/voicebus.o
$(MAKE) -C $(obj)/$(FIRM_DIR) dahdi-fw-vpmoct032.o
--- a/drivers/dahdi/wcb4xxp/Kbuild
+++ b/drivers/dahdi/wcb4xxp/Kbuild
@@ -1,6 +1,6 @@
obj-m += wcb4xxp.o
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef
+ccflags-y += -I$(src)/.. -Wno-undef
wcb4xxp-objs := base.o
--- a/drivers/dahdi/wct4xxp/Kbuild
+++ b/drivers/dahdi/wct4xxp/Kbuild
@@ -2,16 +2,16 @@ obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCT
FIRM_DIR := ../firmware
-EXTRA_CFLAGS += -I$(src)/.. -I$(src)/../oct612x/ $(shell $(src)/../oct612x/octasic-helper cflags $(src)/../oct612x) -Wno-undef
+ccflags-y += -I$(src)/.. -I$(src)/../oct612x/ $(shell $(src)/../oct612x/octasic-helper cflags $(src)/../oct612x) -Wno-undef
# The OCT612X source files are from a vendor drop and we do not want to edit
# them to make this warning go away. Therefore, turn off the
# unused-but-set-variable warning for this driver.
-EXTRA_CFLAGS += $(call cc-option, -Wno-unused-but-set-variable)
+ccflags-y += $(call cc-option, -Wno-unused-but-set-variable)
ifeq ($(HOTPLUG_FIRMWARE),yes)
- EXTRA_CFLAGS+=-DHOTPLUG_FIRMWARE
+ ccflags-y+=-DHOTPLUG_FIRMWARE
endif
wct4xxp-objs := base.o vpm450m.o
--- a/drivers/dahdi/wctc4xxp/Kbuild
+++ b/drivers/dahdi/wctc4xxp/Kbuild
@@ -2,10 +2,10 @@ obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCT
FIRM_DIR := ../firmware
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef
+ccflags-y += -I$(src)/.. -Wno-undef
ifeq ($(HOTPLUG_FIRMWARE),yes)
- EXTRA_CFLAGS+=-DHOTPLUG_FIRMWARE
+ ccflags-y+=-DHOTPLUG_FIRMWARE
endif
wctc4xxp-objs := base.o
--- a/drivers/dahdi/wctdm24xxp/Kbuild
+++ b/drivers/dahdi/wctdm24xxp/Kbuild
@@ -1,5 +1,5 @@
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTDM24XXP) += wctdm24xxp.o
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef
+ccflags-y += -I$(src)/.. -Wno-undef
wctdm24xxp-objs := base.o xhfc.o
--- a/drivers/dahdi/wcte12xp/Kbuild
+++ b/drivers/dahdi/wcte12xp/Kbuild
@@ -1,5 +1,5 @@
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTE12XP) += wcte12xp.o
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef
+ccflags-y += -I$(src)/.. -Wno-undef
wcte12xp-objs := base.o
--- a/drivers/dahdi/xpp/Kbuild
+++ b/drivers/dahdi/xpp/Kbuild
@@ -1,4 +1,4 @@
-EXTRA_CFLAGS = $(XPP_LOCAL_CFLAGS) \
+ccflags-y = $(XPP_LOCAL_CFLAGS) \
-DDEBUG \
-DPOLL_DIGITAL_INPUTS \
-DDEBUG_PCMTX \
@@ -32,7 +32,7 @@ xpd_echo-objs += card_echo.o
xpp_mmap-objs += mmapbus.o mmapdrv.o
ifeq (y,$(PARPORT_DEBUG))
-EXTRA_CFLAGS += -DDEBUG_SYNC_PARPORT
+ccflags-y += -DDEBUG_SYNC_PARPORT
obj-m += parport_debug.o
endif