[packages/dahdi-linux] - add fixes required to build with kernel 4.15 - rel 3

baggins baggins at pld-linux.org
Mon Jan 29 20:20:56 CET 2018


commit 4338db613ebeeb496346062baad066538127a2e2
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Mon Jan 29 20:20:26 2018 +0100

    - add fixes required to build with kernel 4.15
    - rel 3

 ...move-command_timer-functions-to-xbus-core.patch |  97 +++++++
 ...building-with-4.15-init_timer-setup_timer.patch | 296 +++++++++++++++++++++
 dahdi-linux.spec                                   |   6 +-
 3 files changed, 398 insertions(+), 1 deletion(-)
---
diff --git a/dahdi-linux.spec b/dahdi-linux.spec
index 8f5ad83..d1ca2cb 100644
--- a/dahdi-linux.spec
+++ b/dahdi-linux.spec
@@ -35,7 +35,7 @@ exit 1
 %define		_enable_debug_packages	0
 %endif
 
-%define		rel	2
+%define		rel	3
 %define		pname	dahdi-linux
 %define		FIRMWARE_URL http://downloads.digium.com/pub/telephony/firmware/releases
 Summary:	DAHDI telephony device support
@@ -59,6 +59,8 @@ Source7:	%{FIRMWARE_URL}/dahdi-fw-hx8-2.06.tar.gz
 # Source7-md5:	a7f3886942bb3e9fed349a41b3390c9f
 Patch0:		kernel-4.11.patch
 Patch1:		kernel-4.13.patch
+Patch2:		0001-xpp-move-command_timer-functions-to-xbus-core.patch
+Patch3:		0002-fix-building-with-4.15-init_timer-setup_timer.patch
 URL:		http://www.asterisk.org/
 %{?with_kernel:%{expand:%buildrequires_kernel kernel%%{_alt_kernel}-module-build >= 3:2.6.20.2}}
 BuildRequires:	perl-base
@@ -160,6 +162,8 @@ cd ../..\
 %setup -q -n %{pname}-%{version}
 %patch0 -p1
 %patch1 -p1
+%patch2 -p1
+%patch3 -p1
 
 for a in %{SOURCE3} %{SOURCE4} %{SOURCE5} %{SOURCE6} %{SOURCE7}; do
 	ln -s $a drivers/dahdi/firmware
diff --git a/0001-xpp-move-command_timer-functions-to-xbus-core.patch b/0001-xpp-move-command_timer-functions-to-xbus-core.patch
new file mode 100644
index 0000000..b3070b3
--- /dev/null
+++ b/0001-xpp-move-command_timer-functions-to-xbus-core.patch
@@ -0,0 +1,97 @@
+From 529b104aacaa6164d39e955003718bf15edcf08e Mon Sep 17 00:00:00 2001
+From: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+Date: Mon, 1 Jan 2018 16:06:25 +0200
+Subject: [PATCH 1/2] xpp: move command_timer functions to xbus-core
+
+Would allow to later fully initializing the command_timer in xbus-core.c
+rather than xbus-pcm.c .
+---
+ drivers/dahdi/xpp/xbus-core.c | 30 ++++++++++++++++++++++++++++++
+ drivers/dahdi/xpp/xbus-pcm.c  | 30 ------------------------------
+ 2 files changed, 30 insertions(+), 30 deletions(-)
+
+diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c
+index 4281f1c..ca129cd 100644
+--- a/drivers/dahdi/xpp/xbus-core.c
++++ b/drivers/dahdi/xpp/xbus-core.c
+@@ -1350,6 +1350,36 @@ err:
+ 	return 0;
+ }
+ 
++static void xbus_command_timer(unsigned long param)
++{
++	xbus_t *xbus = (xbus_t *)param;
++	struct timeval now;
++
++	BUG_ON(!xbus);
++	do_gettimeofday(&now);
++	xbus_command_queue_tick(xbus);
++	if (!xbus->self_ticking) /* Must be 1KHz rate */
++		mod_timer(&xbus->command_timer, jiffies + 1);
++}
++
++void xbus_set_command_timer(xbus_t *xbus, bool on)
++{
++	XBUS_DBG(SYNC, xbus, "%s\n", (on) ? "ON" : "OFF");
++	if (on) {
++		if (!timer_pending(&xbus->command_timer)) {
++			XBUS_DBG(SYNC, xbus, "add_timer\n");
++			xbus->command_timer.function = xbus_command_timer;
++			xbus->command_timer.data = (unsigned long)xbus;
++			xbus->command_timer.expires = jiffies + 1;
++			add_timer(&xbus->command_timer);
++		}
++	} else if (timer_pending(&xbus->command_timer)) {
++		XBUS_DBG(SYNC, xbus, "del_timer\n");
++		del_timer(&xbus->command_timer);
++	}
++	xbus->self_ticking = !on;
++}
++
+ bool xbus_setflags(xbus_t *xbus, int flagbit, bool on)
+ {
+ 	unsigned long flags;
+diff --git a/drivers/dahdi/xpp/xbus-pcm.c b/drivers/dahdi/xpp/xbus-pcm.c
+index 32f04fa..3f46780 100644
+--- a/drivers/dahdi/xpp/xbus-pcm.c
++++ b/drivers/dahdi/xpp/xbus-pcm.c
+@@ -353,36 +353,6 @@ static void xpp_set_syncer(xbus_t *xbus, bool on)
+ 			 (syncer) ? syncer->busname : "NO-SYNC");
+ }
+ 
+-static void xbus_command_timer(unsigned long param)
+-{
+-	xbus_t *xbus = (xbus_t *)param;
+-	struct timeval now;
+-
+-	BUG_ON(!xbus);
+-	do_gettimeofday(&now);
+-	xbus_command_queue_tick(xbus);
+-	if (!xbus->self_ticking) /* Must be 1KHz rate */
+-		mod_timer(&xbus->command_timer, jiffies + 1);
+-}
+-
+-void xbus_set_command_timer(xbus_t *xbus, bool on)
+-{
+-	XBUS_DBG(SYNC, xbus, "%s\n", (on) ? "ON" : "OFF");
+-	if (on) {
+-		if (!timer_pending(&xbus->command_timer)) {
+-			XBUS_DBG(SYNC, xbus, "add_timer\n");
+-			xbus->command_timer.function = xbus_command_timer;
+-			xbus->command_timer.data = (unsigned long)xbus;
+-			xbus->command_timer.expires = jiffies + 1;
+-			add_timer(&xbus->command_timer);
+-		}
+-	} else if (timer_pending(&xbus->command_timer)) {
+-		XBUS_DBG(SYNC, xbus, "del_timer\n");
+-		del_timer(&xbus->command_timer);
+-	}
+-	xbus->self_ticking = !on;
+-}
+-
+ /*
+  * Called when the Astribank replies to a sync change request
+  */
+-- 
+2.11.0
+
diff --git a/0002-fix-building-with-4.15-init_timer-setup_timer.patch b/0002-fix-building-with-4.15-init_timer-setup_timer.patch
new file mode 100644
index 0000000..a624e0d
--- /dev/null
+++ b/0002-fix-building-with-4.15-init_timer-setup_timer.patch
@@ -0,0 +1,296 @@
+From 19af3ae5af6857402e0e8a3e3b35c81320917454 Mon Sep 17 00:00:00 2001
+From: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+Date: Mon, 1 Jan 2018 09:50:01 +0200
+Subject: [PATCH 2/2] fix building with 4.15: init_timer / setup_timer
+
+Kernel 4.15 revised the interface for callbacks to timers. For that the
+initialization of timers has changed.
+
+Changes are conditioned on the preprocesson define init_timer that was
+removed.
+
+DAHLIN-359 #close
+
+Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+---
+ drivers/dahdi/dahdi-base.c          | 11 ++++++++---
+ drivers/dahdi/dahdi_dynamic.c       | 13 ++++++++-----
+ drivers/dahdi/dahdi_dynamic_ethmf.c | 11 ++++++++---
+ drivers/dahdi/wctc4xxp/base.c       |  8 +++++++-
+ drivers/dahdi/wcte12xp/base.c       |  9 ++++++++-
+ drivers/dahdi/wcte13xp-base.c       |  8 +++++++-
+ drivers/dahdi/wcte43x-base.c        |  8 +++++++-
+ drivers/dahdi/xpp/xbus-core.c       | 10 +++++++---
+ include/dahdi/kernel.h              | 10 ++++++++++
+ 9 files changed, 70 insertions(+), 18 deletions(-)
+
+diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
+index 618754d..c473474 100644
+--- a/drivers/dahdi/dahdi-base.c
++++ b/drivers/dahdi/dahdi-base.c
+@@ -10069,7 +10069,13 @@ static inline unsigned long msecs_processed(const struct core_timer *const ct)
+ 	return atomic_read(&ct->count) * DAHDI_MSECS_PER_CHUNK;
+ }
+ 
+-static void coretimer_func(unsigned long param)
++static void coretimer_func(
++#ifdef init_timer	/* Compatibility for pre 4.15 interface */
++		unsigned long param
++#else
++		struct timer_list *t
++#endif
++)
+ {
+ 	unsigned long flags;
+ 	unsigned long ms_since_start;
+@@ -10150,8 +10156,7 @@ static void coretimer_func(unsigned long param)
+ 
+ static void coretimer_init(void)
+ {
+-	init_timer(&core_timer.timer);
+-	core_timer.timer.function = coretimer_func;
++	timer_setup(&core_timer.timer, coretimer_func, 0);
+ 	ktime_get_ts(&core_timer.start_interval);
+ 	atomic_set(&core_timer.count, 0);
+ 	atomic_set(&core_timer.shutdown, 0);
+diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c
+index 0a37e2a..6727bd4 100644
+--- a/drivers/dahdi/dahdi_dynamic.c
++++ b/drivers/dahdi/dahdi_dynamic.c
+@@ -831,7 +831,13 @@ EXPORT_SYMBOL(dahdi_dynamic_unregister_driver);
+ 
+ static struct timer_list alarmcheck;
+ 
+-static void check_for_red_alarm(unsigned long ignored)
++static void check_for_red_alarm(
++#ifdef init_timer	/* Compatibility for pre 4.15 interface */
++		unsigned long ignored
++#else
++		struct timer_list *ignored
++#endif
++)
+ {
+ 	int newalarm;
+ 	int alarmchanged = 0;
+@@ -867,10 +873,7 @@ static const struct dahdi_dynamic_ops dahdi_dynamic_ops = {
+ static int dahdi_dynamic_init(void)
+ {
+ 	/* Start process to check for RED ALARM */
+-	init_timer(&alarmcheck);
+-	alarmcheck.expires = 0;
+-	alarmcheck.data = 0;
+-	alarmcheck.function = check_for_red_alarm;
++	timer_setup(&alarmcheck, check_for_red_alarm, 0);
+ 	/* Check once per second */
+ 	mod_timer(&alarmcheck, jiffies + 1 * HZ);
+ #ifdef ENABLE_TASKLETS
+diff --git a/drivers/dahdi/dahdi_dynamic_ethmf.c b/drivers/dahdi/dahdi_dynamic_ethmf.c
+index dec368b..4d7d2f1 100644
+--- a/drivers/dahdi/dahdi_dynamic_ethmf.c
++++ b/drivers/dahdi/dahdi_dynamic_ethmf.c
+@@ -681,7 +681,13 @@ static int ethmf_delay_dec(void)
+  * Timer callback function to allow all spans to be added, prior to any of
+  * them being used.
+  */
+-static void timer_callback(unsigned long param)
++static void timer_callback(
++#ifdef init_timer	/* Compatibility for pre 4.15 interface */
++		unsigned long ignored
++#else
++		struct timer_list *ignored
++#endif
++)
+ {
+ 	if (ethmf_delay_dec()) {
+ 		if (!atomic_read(&timer_deleted)) {
+@@ -764,9 +770,8 @@ static const struct file_operations ztdethmf_proc_fops = {
+ 
+ static int __init ztdethmf_init(void)
+ {
+-	init_timer(&timer);
++	timer_setup(&timer, &timer_callback, 0);
+ 	timer.expires = jiffies + HZ;
+-	timer.function = &timer_callback;
+ 	if (!timer_pending(&timer))
+ 		add_timer(&timer);
+ 
+diff --git a/drivers/dahdi/wctc4xxp/base.c b/drivers/dahdi/wctc4xxp/base.c
+index 0d76d6a..8e0b76b 100644
+--- a/drivers/dahdi/wctc4xxp/base.c
++++ b/drivers/dahdi/wctc4xxp/base.c
+@@ -3701,9 +3701,15 @@ wctc4xxp_send_commands(struct wcdte *wc, struct list_head *to_send)
+ }
+ 
+ static void
++#ifndef init_timer
++wctc4xxp_watchdog(struct timer_list *t)
++{
++	struct wcdte *wc = from_timer(wc, t, watchdog);
++#else	/* Compatibility for pre 4.15 interface */
+ wctc4xxp_watchdog(unsigned long data)
+ {
+ 	struct wcdte *wc = (struct wcdte *)data;
++#endif
+ 	struct tcb *cmd, *temp;
+ 	LIST_HEAD(cmds_to_retry);
+ 	const int MAX_RETRIES = 5;
+@@ -4095,7 +4101,7 @@ wctc4xxp_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
+ 	wc->watchdog.data = (unsigned long)wc;
+ 	init_timer(&wc->watchdog);
+ #	else
+-	setup_timer(&wc->watchdog, wctc4xxp_watchdog, (unsigned long)wc);
++	timer_setup(&wc->watchdog, wctc4xxp_watchdog, 0);
+ #	endif
+ 
+ 	/* ------------------------------------------------------------------
+diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c
+index c327c5f..77e2d2f 100644
+--- a/drivers/dahdi/wcte12xp/base.c
++++ b/drivers/dahdi/wcte12xp/base.c
+@@ -2765,10 +2765,17 @@ static void vpm_check_func(struct work_struct *work)
+ 	return;
+ }
+ 
++#ifndef init_timer
++static void te12xp_timer(struct timer_list *t)
++{
++	unsigned long flags;
++	struct t1 *wc = from_timer(wc, t, timer);
++#else	/* Compatibility for pre 4.15 interface */
+ static void te12xp_timer(unsigned long data)
+ {
+ 	unsigned long flags;
+ 	struct t1 *wc = (struct t1 *)data;
++#endif
+ 
+ 	if (unlikely(!test_bit(INITIALIZED, &wc->bit_flags)))
+ 		return;
+@@ -2943,7 +2950,7 @@ static int __devinit te12xp_init_one(struct pci_dev *pdev, const struct pci_devi
+ 	spin_lock_init(&wc->reglock);
+ 	INIT_LIST_HEAD(&wc->active_cmds);
+ 	INIT_LIST_HEAD(&wc->pending_cmds);
+-	setup_timer(&wc->timer, te12xp_timer, (unsigned long)wc);
++	timer_setup(&wc->timer, te12xp_timer, 0);
+ 
+ #	if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+ 	INIT_WORK(&wc->timer_work, timer_work_func, wc);
+diff --git a/drivers/dahdi/wcte13xp-base.c b/drivers/dahdi/wcte13xp-base.c
+index c5ebe9d..57e6dac 100644
+--- a/drivers/dahdi/wcte13xp-base.c
++++ b/drivers/dahdi/wcte13xp-base.c
+@@ -2381,9 +2381,15 @@ static void te13x_handle_interrupt(struct wcxb *xb, u32 pending)
+ 	}
+ }
+ 
++#ifndef init_timer
++static void te13xp_timer(struct timer_list *t)
++{
++	struct t13x *wc = from_timer(wc, t, timer);
++#else	/* Compatibility for pre 4.15 interface */
+ static void te13xp_timer(unsigned long data)
+ {
+ 	struct t13x *wc = (struct t13x *)data;
++#endif
+ 
+ 	if (unlikely(!test_bit(INITIALIZED, &wc->bit_flags)))
+ 		return;
+@@ -2582,7 +2588,7 @@ static int __devinit te13xp_init_one(struct pci_dev *pdev,
+ 	wc->ledstate = -1;
+ 	spin_lock_init(&wc->reglock);
+ 	mutex_init(&wc->lock);
+-	setup_timer(&wc->timer, te13xp_timer, (unsigned long)wc);
++	timer_setup(&wc->timer, te13xp_timer, 0);
+ 
+ #	if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+ 	INIT_WORK(&wc->timer_work, timer_work_func, wc);
+diff --git a/drivers/dahdi/wcte43x-base.c b/drivers/dahdi/wcte43x-base.c
+index 3e6159b..af39165 100644
+--- a/drivers/dahdi/wcte43x-base.c
++++ b/drivers/dahdi/wcte43x-base.c
+@@ -3203,9 +3203,15 @@ static void t43x_handle_interrupt(struct wcxb *xb, u32 pending)
+ 		wc->intr_span = 0;
+ }
+ 
++#ifndef init_timer
++static void t43x_timer(struct timer_list *t)
++{
++	struct t43x *wc = from_timer(wc, t, timer);
++#else	/* Compatibility for pre 4.15 interface */
+ static void t43x_timer(unsigned long data)
+ {
+ 	struct t43x *wc = (struct t43x *)data;
++#endif
+ 
+ 	if (!is_initialized(wc))
+ 		return;
+@@ -3431,7 +3437,7 @@ static int __devinit t43x_init_one(struct pci_dev *pdev,
+ 		goto fail_exit;
+ 
+ 	mutex_init(&wc->lock);
+-	setup_timer(&wc->timer, t43x_timer, (unsigned long)wc);
++	timer_setup(&wc->timer, t43x_timer, 0);
+ 
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+ 	INIT_WORK(&wc->timer_work, timer_work_func, wc);
+diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c
+index ca129cd..5bd8853 100644
+--- a/drivers/dahdi/xpp/xbus-core.c
++++ b/drivers/dahdi/xpp/xbus-core.c
+@@ -1350,9 +1350,15 @@ err:
+ 	return 0;
+ }
+ 
++#ifndef init_timer
++static void xbus_command_timer(struct timer_list *t)
++{
++	xbus_t *xbus = from_timer(xbus, t, command_timer);
++#else
+ static void xbus_command_timer(unsigned long param)
+ {
+ 	xbus_t *xbus = (xbus_t *)param;
++#endif
+ 	struct timeval now;
+ 
+ 	BUG_ON(!xbus);
+@@ -1368,8 +1374,6 @@ void xbus_set_command_timer(xbus_t *xbus, bool on)
+ 	if (on) {
+ 		if (!timer_pending(&xbus->command_timer)) {
+ 			XBUS_DBG(SYNC, xbus, "add_timer\n");
+-			xbus->command_timer.function = xbus_command_timer;
+-			xbus->command_timer.data = (unsigned long)xbus;
+ 			xbus->command_timer.expires = jiffies + 1;
+ 			add_timer(&xbus->command_timer);
+ 		}
+@@ -1642,7 +1646,7 @@ xbus_t *xbus_new(struct xbus_ops *ops, ushort max_send_size,
+ 	transport_init(xbus, ops, max_send_size, transport_device, priv);
+ 	spin_lock_init(&xbus->lock);
+ 	init_waitqueue_head(&xbus->command_queue_empty);
+-	init_timer(&xbus->command_timer);
++	timer_setup(&xbus->command_timer, xbus_command_timer, 0);
+ 	atomic_set(&xbus->pcm_rx_counter, 0);
+ 	xbus->min_tx_sync = INT_MAX;
+ 	xbus->min_rx_sync = INT_MAX;
+diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h
+index c946fa3..bc07ef6 100644
+--- a/include/dahdi/kernel.h
++++ b/include/dahdi/kernel.h
+@@ -1630,6 +1630,16 @@ struct mutex {
+ 	printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+ #endif
+ 
++
++#ifdef init_timer	/* Compatibility for pre 4.15 interface */
++#define timer_setup(timer, func, flags) 	\
++	do { 					\
++		init_timer(timer); 		\
++		(timer)->function = (func);	\
++	} while (0)
++#endif
++
++
+ /* If KBUILD_MODNAME is not defined in a compilation unit, then the dev_dbg
+  * macro will not work properly. */
+ #ifndef KBUILD_MODNAME
+-- 
+2.11.0
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/dahdi-linux.git/commitdiff/4338db613ebeeb496346062baad066538127a2e2



More information about the pld-cvs-commit mailing list