Skip to content

Commit 3b7b6c8

Browse files
grayskygraysky2
authored andcommitted
dahdi-linux: forward-port to 6.18 kernel APIs, fix build flags, disable OSLEC
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] * Disable OSLEC echo canceller: - OpenWrt provides only oslec.h without echo.c implementation - Prevents undefined oslec_* symbol failures during modpost - Marks dahdi-echocan-oslec package as unavailable on >= 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. asterisk/dahdi-linux#93 2. asterisk/dahdi-linux#76 Signed-off-by: John Audia <[email protected]>
1 parent 40dcae6 commit 3b7b6c8

File tree

4 files changed

+257
-2
lines changed

4 files changed

+257
-2
lines changed

libs/dahdi-linux/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
1010

1111
PKG_NAME:=dahdi-linux
1212
PKG_VERSION:=3.4.0
13-
PKG_RELEASE:=2
13+
PKG_RELEASE:=3
1414

1515
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
1616
PKG_SOURCE_URL:=https://github.com/asterisk/$(PKG_NAME)/releases/download/v$(PKG_VERSION)
@@ -44,7 +44,7 @@ define KernelPackage/dahdi-echocan-oslec
4444
TITLE:=DAHDI OSLEC echo canceller support
4545
DEPENDS:=kmod-dahdi +kmod-echo
4646
URL:=http://www.asterisk.org/
47-
FILES:=$(PKG_BUILD_DIR)/drivers/dahdi/dahdi_echocan_oslec.$(LINUX_KMOD_SUFFIX)
47+
FILES:=$(PKG_BUILD_DIR)/drivers/dahdi/dahdi_echocan_oslec.$(LINUX_KMOD_SUFFIX)@lt6.18
4848
AUTOLOAD:=$(call AutoProbe,dahdi_echocan_oslec)
4949
endef
5050

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--- a/include/dahdi/kernel.h
2+
+++ b/include/dahdi/kernel.h
3+
@@ -58,6 +58,15 @@
4+
5+
#include <linux/poll.h>
6+
7+
+/* Added for DAHDI use of hrtimers (hrtimer_init, etc.) */
8+
+#include <linux/hrtimer.h>
9+
+
10+
+/* del_timer[_sync] was renamed to timer_delete[_sync] in newer kernels */
11+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
12+
+#define del_timer timer_delete
13+
+#define del_timer_sync timer_delete_sync
14+
+#endif
15+
+
16+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
17+
#define netif_napi_add netif_napi_add_weight
18+
#endif
19+
@@ -66,6 +75,25 @@
20+
#include <linux/pci.h>
21+
#include <linux/dma-mapping.h>
22+
23+
+/* DAHDI expects hrtimer_init(), but kernels >= 6.8 removed it.
24+
+ * Recreate it using the modern hrtimer_setup() API.
25+
+ */
26+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0)
27+
+static inline void hrtimer_init(struct hrtimer *timer,
28+
+ clockid_t clock_id,
29+
+ enum hrtimer_mode mode)
30+
+{
31+
+ /* No callback yet — DAHDI sets it later with hrtimer_update_function() */
32+
+ hrtimer_setup(timer, NULL, clock_id, mode);
33+
+}
34+
+#endif
35+
+
36+
+/* from_timer() helper was removed in newer kernels; restore it for DAHDI. */
37+
+#ifndef from_timer
38+
+#define from_timer(var, callback_timer, timer_fieldname) \
39+
+ container_of(callback_timer, typeof(*var), timer_fieldname)
40+
+#endif
41+
+
42+
static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle)
43+
{
44+
return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
From ec88adb782aed38c3445c20d20213c51dae7e092 Mon Sep 17 00:00:00 2001
2+
From: InterLinked1 <[email protected]>
3+
Date: Fri, 21 Feb 2025 21:42:19 -0500
4+
Subject: [PATCH] Kbuild: Use ccflags-y instead of EXTRA_CFLAGS.
5+
6+
ccflags-y was added to the kernel back in 2007, in commit
7+
f77bf01425b11947eeb3b5b54. Recent kernel commit
8+
dbd83ea09699390892e5efecddd74ae43a00f071 has now completely
9+
removed the deprecated EXTRA_CFLAGS.
10+
11+
Comments in Kbuild and the Makefile for the oct612x library were
12+
added back when it was created in 2013 in commit f65299e8b2e6ffb0b07089759f8c4ff33a695c09
13+
to use the newer ccflags-y based on the kernel version,
14+
but the change was never made to conditionally move away
15+
from the EXTRA_CFLAGS.
16+
17+
Now that the older way no longer exists, always use ccflags-y.
18+
19+
Resolves: #76
20+
---
21+
drivers/dahdi/Kbuild | 4 ++--
22+
drivers/dahdi/oct612x/Kbuild | 5 +----
23+
drivers/dahdi/oct612x/Makefile | 5 +----
24+
drivers/dahdi/opvxa1200/Kbuild | 6 +++---
25+
drivers/dahdi/voicebus/Kbuild | 4 ++--
26+
drivers/dahdi/wcb4xxp/Kbuild | 2 +-
27+
drivers/dahdi/wct4xxp/Kbuild | 6 +++---
28+
drivers/dahdi/wctc4xxp/Kbuild | 4 ++--
29+
drivers/dahdi/wctdm24xxp/Kbuild | 2 +-
30+
drivers/dahdi/wcte12xp/Kbuild | 2 +-
31+
drivers/dahdi/xpp/Kbuild | 4 ++--
32+
11 files changed, 19 insertions(+), 25 deletions(-)
33+
34+
--- a/drivers/dahdi/Kbuild
35+
+++ b/drivers/dahdi/Kbuild
36+
@@ -83,13 +83,13 @@ CFLAGS_MODULE += -I$(DAHDI_INCLUDE) -I$(
37+
BAD_KERNELS_VERS := 22 34 34.0.1 34.0.2
38+
BAD_KERNELS := $(foreach ver,$(BAD_KERNELS_VERS),2.6.9-$(ver).EL 2.6.9-$(ver).ELsmp)
39+
ifneq (,$(filter $(KVERS),$(BAD_KERNELS)))
40+
-EXTRA_CFLAGS+=-Drw_lock_t=rwlock_t
41+
+ccflags-y+=-Drw_lock_t=rwlock_t
42+
endif
43+
44+
# A number of Fedora 10 (9 also?) kernels backported hrtimer to 2.6.27
45+
# as part of an ALSA backport. TODO: Any better way to detect that?
46+
ifeq (1,$(shell fgrep -q ' hrtimer_set_expires' include/linux/hrtimer.h 2>/dev/null && echo 1))
47+
-EXTRA_CFLAGS+=-DHAVE_HRTIMER_ACCESSORS=1
48+
+ccflags-y+=-DHAVE_HRTIMER_ACCESSORS=1
49+
endif
50+
51+
ifeq (1,$(shell fgrep -q 'wait_for_completion_timeout' include/linux/completion.h 2>/dev/null && echo 1))
52+
--- a/drivers/dahdi/oct612x/Kbuild
53+
+++ b/drivers/dahdi/oct612x/Kbuild
54+
@@ -24,9 +24,6 @@ octapi_files = octdeviceapi/oct6100api/o
55+
apilib/llman/octapi_llman.o \
56+
oct612x-user.o
57+
58+
-# TODO: ccflags was added in 2.6.24 in commit f77bf01425b11947eeb3b5b54. This
59+
-# should be changed to a conditional compilation based on the Kernel Version.
60+
-# ccflags-y := -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
61+
-EXTRA_CFLAGS = -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
62+
+ccflags-y := -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
63+
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_OCT612X) := oct612x.o
64+
oct612x-objs := $(octapi_files)
65+
--- a/drivers/dahdi/oct612x/Makefile
66+
+++ b/drivers/dahdi/oct612x/Makefile
67+
@@ -23,8 +23,5 @@ octapi_files = octdeviceapi/oct6100api/o
68+
apilib/largmath/octapi_largmath.o \
69+
apilib/llman/octapi_llman.o
70+
71+
-# TODO: ccflags was added in 2.6.24 in commit f77bf01425b11947eeb3b5b54. This
72+
-# should be changed to a conditional compilation based on the Kernel Version.
73+
-# ccflags-y := -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
74+
-EXTRA_CFLAGS = -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
75+
+ccflags-y := -I$(src)/.. -Wno-undef -I$(src)/include -I$(src)/octdeviceapi -I$(src)/octdeviceapi/oct6100api
76+
lib-y := $(octapi_files)
77+
--- a/drivers/dahdi/opvxa1200/Kbuild
78+
+++ b/drivers/dahdi/opvxa1200/Kbuild
79+
@@ -1,6 +1,6 @@
80+
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_OPVXA1200) += opvxa1200.o
81+
82+
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef -Wno-error=unused-variable
83+
+ccflags-y += -I$(src)/.. -Wno-undef
84+
85+
opvxa1200-objs := base.o
86+
87+
@@ -10,10 +10,10 @@ ifneq ($(DAHDI_KERNEL_H_PATH),)
88+
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)
89+
DAHDI_SPAN_OPS:=$(shell if grep -q "struct dahdi_span_ops {" $(DAHDI_KERNEL_H_PATH); then echo "yes"; else echo "no"; fi)
90+
ifeq ($(DAHDI_SPAN_MODULE),yes)
91+
- EXTRA_CFLAGS+=-DDAHDI_SPAN_MODULE
92+
+ ccflags-y+=-DDAHDI_SPAN_MODULE
93+
else
94+
ifeq ($(DAHDI_SPAN_OPS),yes)
95+
- EXTRA_CFLAGS+=-DDAHDI_SPAN_OPS
96+
+ ccflags-y+=-DDAHDI_SPAN_OPS
97+
endif
98+
endif
99+
endif
100+
--- a/drivers/dahdi/voicebus/Kbuild
101+
+++ b/drivers/dahdi/voicebus/Kbuild
102+
@@ -8,10 +8,10 @@ ifneq ($(HOTPLUG_FIRMWARE),yes)
103+
dahdi_voicebus-objs += $(FIRM_DIR)/dahdi-fw-vpmoct032.o
104+
$(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.)
105+
else
106+
- EXTRA_CFLAGS+=-DHOTPLUG_FIRMWARE
107+
+ ccflags-y+=-DHOTPLUG_FIRMWARE
108+
endif
109+
110+
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef
111+
+ccflags-y += -I$(src)/.. -Wno-undef
112+
113+
$(obj)/$(FIRM_DIR)/dahdi-fw-vpmoct032.o: $(obj)/voicebus.o
114+
$(MAKE) -C $(obj)/$(FIRM_DIR) dahdi-fw-vpmoct032.o
115+
--- a/drivers/dahdi/wcb4xxp/Kbuild
116+
+++ b/drivers/dahdi/wcb4xxp/Kbuild
117+
@@ -1,6 +1,6 @@
118+
obj-m += wcb4xxp.o
119+
120+
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef
121+
+ccflags-y += -I$(src)/.. -Wno-undef
122+
123+
wcb4xxp-objs := base.o
124+
125+
--- a/drivers/dahdi/wct4xxp/Kbuild
126+
+++ b/drivers/dahdi/wct4xxp/Kbuild
127+
@@ -2,16 +2,16 @@ obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCT
128+
129+
FIRM_DIR := ../firmware
130+
131+
-EXTRA_CFLAGS += -I$(src)/.. -I$(src)/../oct612x/ $(shell $(src)/../oct612x/octasic-helper cflags $(src)/../oct612x) -Wno-undef
132+
+ccflags-y += -I$(src)/.. -I$(src)/../oct612x/ $(shell $(src)/../oct612x/octasic-helper cflags $(src)/../oct612x) -Wno-undef
133+
134+
# The OCT612X source files are from a vendor drop and we do not want to edit
135+
# them to make this warning go away. Therefore, turn off the
136+
# unused-but-set-variable warning for this driver.
137+
138+
-EXTRA_CFLAGS += $(call cc-option, -Wno-unused-but-set-variable)
139+
+ccflags-y += $(call cc-option, -Wno-unused-but-set-variable)
140+
141+
ifeq ($(HOTPLUG_FIRMWARE),yes)
142+
- EXTRA_CFLAGS+=-DHOTPLUG_FIRMWARE
143+
+ ccflags-y+=-DHOTPLUG_FIRMWARE
144+
endif
145+
146+
wct4xxp-objs := base.o vpm450m.o
147+
--- a/drivers/dahdi/wctc4xxp/Kbuild
148+
+++ b/drivers/dahdi/wctc4xxp/Kbuild
149+
@@ -2,10 +2,10 @@ obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCT
150+
151+
FIRM_DIR := ../firmware
152+
153+
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef
154+
+ccflags-y += -I$(src)/.. -Wno-undef
155+
156+
ifeq ($(HOTPLUG_FIRMWARE),yes)
157+
- EXTRA_CFLAGS+=-DHOTPLUG_FIRMWARE
158+
+ ccflags-y+=-DHOTPLUG_FIRMWARE
159+
endif
160+
161+
wctc4xxp-objs := base.o
162+
--- a/drivers/dahdi/wctdm24xxp/Kbuild
163+
+++ b/drivers/dahdi/wctdm24xxp/Kbuild
164+
@@ -1,5 +1,5 @@
165+
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTDM24XXP) += wctdm24xxp.o
166+
167+
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef
168+
+ccflags-y += -I$(src)/.. -Wno-undef
169+
170+
wctdm24xxp-objs := base.o xhfc.o
171+
--- a/drivers/dahdi/wcte12xp/Kbuild
172+
+++ b/drivers/dahdi/wcte12xp/Kbuild
173+
@@ -1,5 +1,5 @@
174+
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTE12XP) += wcte12xp.o
175+
176+
-EXTRA_CFLAGS += -I$(src)/.. -Wno-undef
177+
+ccflags-y += -I$(src)/.. -Wno-undef
178+
179+
wcte12xp-objs := base.o
180+
--- a/drivers/dahdi/xpp/Kbuild
181+
+++ b/drivers/dahdi/xpp/Kbuild
182+
@@ -1,4 +1,4 @@
183+
-EXTRA_CFLAGS = $(XPP_LOCAL_CFLAGS) \
184+
+ccflags-y = $(XPP_LOCAL_CFLAGS) \
185+
-DDEBUG \
186+
-DPOLL_DIGITAL_INPUTS \
187+
-DDEBUG_PCMTX \
188+
@@ -32,7 +32,7 @@ xpd_echo-objs += card_echo.o
189+
xpp_mmap-objs += mmapbus.o mmapdrv.o
190+
191+
ifeq (y,$(PARPORT_DEBUG))
192+
-EXTRA_CFLAGS += -DDEBUG_SYNC_PARPORT
193+
+ccflags-y += -DDEBUG_SYNC_PARPORT
194+
obj-m += parport_debug.o
195+
endif
196+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- a/drivers/dahdi/Kbuild
2+
+++ b/drivers/dahdi/Kbuild
3+
@@ -73,9 +73,9 @@ obj-m += $(DAHDI_MODULES_EXTRA)
4+
# If you want to build OSLEC, include the code in the standard location:
5+
# drivers/staging/echo . The DAHDI OSLEC echo canceller will be built as
6+
# well:
7+
-ifneq (,$(wildcard $(src)/../staging/echo/oslec.h))
8+
-obj-m += dahdi_echocan_oslec.o
9+
-endif
10+
+#ifneq (,$(wildcard $(src)/../staging/echo/oslec.h))
11+
+#obj-m += dahdi_echocan_oslec.o
12+
+#endif
13+
14+
CFLAGS_MODULE += -I$(DAHDI_INCLUDE) -I$(src) -Wno-format-truncation
15+

0 commit comments

Comments
 (0)