[packages/dahdi-linux] - fix building kernel modules on x86 - rel 2

baggins baggins at pld-linux.org
Sun Dec 1 16:37:59 CET 2019


commit e40e547877a7593105a663927813e9a0ee76713c
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Dec 1 16:37:36 2019 +0100

    - fix building kernel modules on x86
    - rel 2

 dahdi-linux.spec |   6 ++-
 math64.patch     | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+), 1 deletion(-)
---
diff --git a/dahdi-linux.spec b/dahdi-linux.spec
index 370c7b9..c6699c0 100644
--- a/dahdi-linux.spec
+++ b/dahdi-linux.spec
@@ -35,7 +35,7 @@ exit 1
 %define		_enable_debug_packages	0
 %endif
 
-%define		rel	1
+%define		rel	2
 %define		pname	dahdi-linux
 %define		FIRMWARE_URL http://downloads.digium.com/pub/telephony/firmware/releases
 Summary:	DAHDI telephony device support
@@ -59,6 +59,7 @@ Source7:	%{FIRMWARE_URL}/dahdi-fw-hx8-2.06.tar.gz
 # Source7-md5:	a7f3886942bb3e9fed349a41b3390c9f
 Patch0:		kernel-4.14.patch
 Patch1:		kernel-5.4.patch
+Patch2:		math64.patch
 URL:		http://www.asterisk.org/
 %{?with_kernel:%{expand:%buildrequires_kernel kernel%%{_alt_kernel}-module-build >= 3:2.6.20.2}}
 BuildRequires:	perl-base
@@ -158,6 +159,9 @@ cd ../..\
 %setup -q -n %{pname}-%{version}
 %patch0 -p1
 %patch1 -p1
+%ifarch %{ix86}
+%patch2 -p1
+%endif
 
 for a in %{SOURCE3} %{SOURCE4} %{SOURCE5} %{SOURCE6} %{SOURCE7}; do
 	ln -s $a drivers/dahdi/firmware
diff --git a/math64.patch b/math64.patch
new file mode 100644
index 0000000..4abfb24
--- /dev/null
+++ b/math64.patch
@@ -0,0 +1,143 @@
+diff -ur dahdi-linux-3.1.0/drivers/dahdi/xpp/xbus-core.c dahdi-linux-3.1.0-math64/drivers/dahdi/xpp/xbus-core.c
+--- dahdi-linux-3.1.0/drivers/dahdi/xpp/xbus-core.c	2019-10-03 16:48:09.000000000 +0200
++++ dahdi-linux-3.1.0-math64/drivers/dahdi/xpp/xbus-core.c	2019-12-01 15:42:12.261848789 +0100
+@@ -25,6 +25,7 @@
+ #include <linux/errno.h>
+ #include <linux/sched.h>
+ #include <linux/mutex.h>
++#include <linux/math64.h>
+ #include <linux/proc_fs.h>
+ #include <linux/seq_file.h>
+ #include <linux/slab.h>
+@@ -1754,11 +1755,13 @@
+ 
+ static void xbus_fill_proc_queue(struct seq_file *sfile, struct xframe_queue *q)
+ {
++	s32 rem;
++	s64 lag_sec = div_s64_rem(q->worst_lag_usec, 1000, &rem);
+ 	seq_printf(sfile,
+-		"%-15s: counts %3d, %3d, %3d worst %3d, overflows %3d worst_lag %02lld.%lld ms\n",
++		"%-15s: counts %3d, %3d, %3d worst %3d, overflows %3d worst_lag %02lld.%ld ms\n",
+ 		q->name, q->steady_state_count, q->count, q->max_count,
+-		q->worst_count, q->overflows, q->worst_lag_usec / 1000,
+-		q->worst_lag_usec % 1000);
++		q->worst_count, q->overflows, lag_sec,
++		rem);
+ 	xframe_queue_clearstats(q);
+ }
+ 
+diff -ur dahdi-linux-3.1.0/drivers/dahdi/xpp/xbus-pcm.c dahdi-linux-3.1.0-math64/drivers/dahdi/xpp/xbus-pcm.c
+--- dahdi-linux-3.1.0/drivers/dahdi/xpp/xbus-pcm.c	2019-10-03 16:48:09.000000000 +0200
++++ dahdi-linux-3.1.0-math64/drivers/dahdi/xpp/xbus-pcm.c	2019-12-01 16:32:23.696492708 +0100
+@@ -22,6 +22,7 @@
+ #include <linux/version.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
++#include <linux/math64.h>
+ #include "xbus-pcm.h"
+ #include "xbus-core.h"
+ #include "xpp_dahdi.h"
+@@ -129,7 +130,7 @@
+ 		usec = ktime_us_delta(ticker->last_sample,
+ 					ticker->first_sample);
+ 		ticker->first_sample = ticker->last_sample;
+-		ticker->tick_period = usec / ticker->cycle;
++		ticker->tick_period = div_s64(usec, ticker->cycle);
+ 		cycled = 1;
+ 	}
+ 	ticker->count++;
+@@ -497,7 +498,7 @@
+ 	XBUS_DBG(SYNC, xbus,
+ 		 "%sDRIFT adjust %s (%d) (last update %lld seconds ago)\n",
+ 		 (disable_pll_sync) ? "Fake " : "", msg, drift,
+-		 msec_delta / MSEC_PER_SEC);
++		 div_s64(msec_delta, MSEC_PER_SEC));
+ 	if (!disable_pll_sync)
+ 		CALL_PROTO(GLOBAL, SYNC_SOURCE, xbus, NULL, SYNC_MODE_PLL,
+ 			   drift);
+diff -ur dahdi-linux-3.1.0/drivers/dahdi/xpp/xbus-sysfs.c dahdi-linux-3.1.0-math64/drivers/dahdi/xpp/xbus-sysfs.c
+--- dahdi-linux-3.1.0/drivers/dahdi/xpp/xbus-sysfs.c	2019-10-03 16:48:09.000000000 +0200
++++ dahdi-linux-3.1.0-math64/drivers/dahdi/xpp/xbus-sysfs.c	2019-12-01 16:29:26.289062748 +0100
+@@ -23,6 +23,7 @@
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/errno.h>
++#include <linux/math64.h>
+ #include <linux/proc_fs.h>
+ #ifdef	PROTOCOL_DEBUG
+ #include <linux/ctype.h>
+@@ -249,11 +250,9 @@
+ 	/*
+ 	 * Calculate lost ticks time
+ 	 */
+-	seconds = ktime_ms_delta(now, di->last_lost_tick) / 1000;
+-	minutes = seconds / 60;
+-	seconds = seconds % 60;
+-	hours = minutes / 60;
+-	minutes = minutes % 60;
++	seconds = div_s64(ktime_ms_delta(now, di->last_lost_tick), 1000);
++	minutes = div_s64_rem(seconds, 60, &seconds);
++	hours = div_s64_rem(minutes, 60, &minutes);
+ 	len += snprintf(buf + len, PAGE_SIZE - len,
+ 		"%-15s: %8d (was %d:%02d:%02d ago)\n", "lost_ticks",
+ 		di->lost_ticks, hours, minutes, seconds);
+diff -ur dahdi-linux-3.1.0/drivers/dahdi/xpp/xframe_queue.c dahdi-linux-3.1.0-math64/drivers/dahdi/xpp/xframe_queue.c
+--- dahdi-linux-3.1.0/drivers/dahdi/xpp/xframe_queue.c	2019-10-03 16:48:09.000000000 +0200
++++ dahdi-linux-3.1.0-math64/drivers/dahdi/xpp/xframe_queue.c	2019-12-01 15:46:21.663845498 +0100
+@@ -1,3 +1,4 @@
++#include <linux/math64.h>
+ #include "xframe_queue.h"
+ #include "xbus-core.h"
+ #include "dahdi_debug.h"
+@@ -40,10 +41,11 @@
+ 	       THIS_MODULE->name, q->name);
+ 	list_for_each_entry_reverse(xframe, &q->head, frame_list) {
+ 		xpacket_t *pack = (xpacket_t *)&xframe->packets[0];
+-		s64 usec = ktime_us_delta(now, xframe->kt_queued);
++		s32 rem;
++		s64 sec = div_s64_rem(ktime_us_delta(now, xframe->kt_queued), 1000, &rem);
+ 
+-		snprintf(prefix, ARRAY_SIZE(prefix), "  %3d> %5lld.%03lld msec",
+-			 i++, usec / 1000, usec % 1000);
++		snprintf(prefix, ARRAY_SIZE(prefix), "  %3d> %5lld.%03ld msec",
++			 i++, sec, rem);
+ 		dump_packet(prefix, pack, 1);
+ 	}
+ }
+@@ -60,11 +62,13 @@
+ 	if (q->count >= q->max_count) {
+ 		q->overflows++;
+ 		if ((overflow_cnt++ % 1000) < 5) {
+-			NOTICE("Overflow of %-15s: counts %3d, %3d, %3d worst %3d, overflows %3d worst_lag %02lld.%lld ms\n",
++			s32 rem;
++			s64 lag_sec = div_s64_rem(q->worst_lag_usec, 1000, &rem);
++			NOTICE("Overflow of %-15s: counts %3d, %3d, %3d worst %3d, overflows %3d worst_lag %02lld.%ld ms\n",
+ 			     q->name, q->steady_state_count, q->count,
+ 			     q->max_count, q->worst_count, q->overflows,
+-			     q->worst_lag_usec / 1000,
+-			     q->worst_lag_usec % 1000);
++			     lag_sec,
++			     rem);
+ 			__xframe_dump_queue(q);
+ 		}
+ 		ret = 0;
+diff -ur dahdi-linux-3.1.0/drivers/dahdi/xpp/xpp_usb.c dahdi-linux-3.1.0-math64/drivers/dahdi/xpp/xpp_usb.c
+--- dahdi-linux-3.1.0/drivers/dahdi/xpp/xpp_usb.c	2019-10-03 16:48:09.000000000 +0200
++++ dahdi-linux-3.1.0-math64/drivers/dahdi/xpp/xpp_usb.c	2019-12-01 16:34:50.324899402 +0100
+@@ -27,6 +27,7 @@
+ #include <linux/interrupt.h>
+ #include <linux/delay.h>	/* for udelay */
+ #include <linux/seq_file.h>
++#include <linux/math64.h>
+ #include <asm/uaccess.h>
+ #include <asm/atomic.h>
+ #include <asm/timex.h>
+@@ -882,7 +883,7 @@
+ 		usec = 0; /* System clock jumped */
+ 	if (usec > xusb->max_tx_delay)
+ 		xusb->max_tx_delay = usec;
+-	i = usec / USEC_BUCKET;
++	i = div_s64(usec, USEC_BUCKET);
+ 	if (i >= NUM_BUCKETS)
+ 		i = NUM_BUCKETS - 1;
+ 	xusb->usb_tx_delay[i]++;
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list