File: ac50b368aae91d93f28c8a532a32fb213b62055d.patch

package info (click to toggle)
dahdi-linux 1%3A2.11.1.0.20170917~dfsg-7.4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 10,336 kB
  • sloc: ansic: 125,072; perl: 2,395; sh: 1,140; makefile: 427; xml: 24
file content (93 lines) | stat: -rw-r--r-- 3,094 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From ac50b368aae91d93f28c8a532a32fb213b62055d Mon Sep 17 00:00:00 2001
From: Shaun Ruffell <sruffell@sruffell.net>
Date: Thu, 10 Jan 2019 03:23:40 +0000
Subject: [PATCH] dahdi: Update coretimer to use ktime instead of 'struct
 timespec'

Since this is only used internally, and ktime is the basis for
timekeeping in the kernel, this allows this interface to be validated,
before converting the other internal timekeeping to it.

This is part of the changes necessary to remove the use of 'struct
timeval' from the driver suite for compatibility with Linux 5.0, which
is updating the internal timekeeping interfaces to fix the 2038 problem.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
---
 drivers/dahdi/dahdi-base.c | 30 ++++++------------------------
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index 78923660..90166d57 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -198,7 +198,7 @@ static int maxlinks;
 
 static struct core_timer {
 	struct timer_list timer;
-	struct timespec start_interval;
+	ktime_t start_interval;
 	unsigned long interval;
 	int dahdi_receive_used;
 	atomic_t count;
@@ -10025,24 +10025,6 @@ static void coretimer_cleanup(void)
 
 #else
 
-static unsigned long core_diff_ms(struct timespec *t0, struct timespec *t1)
-{
-	long nanosec, sec;
-	unsigned long ms;
-	sec = (t1->tv_sec - t0->tv_sec);
-	nanosec = (t1->tv_nsec - t0->tv_nsec);
-	while (nanosec >= NSEC_PER_SEC) {
-		nanosec -= NSEC_PER_SEC;
-		++sec;
-	}
-	while (nanosec < 0) {
-		nanosec += NSEC_PER_SEC;
-		--sec;
-	}
-	ms = (sec * 1000) + (nanosec / 1000000L);
-	return ms;
-}
-
 static inline unsigned long msecs_processed(const struct core_timer *const ct)
 {
 	return atomic_read(&ct->count) * DAHDI_MSECS_PER_CHUNK;
@@ -10051,14 +10033,14 @@ static inline unsigned long msecs_processed(const struct core_timer *const ct)
 static void coretimer_func(TIMER_DATA_TYPE unused)
 {
 	unsigned long flags;
-	unsigned long ms_since_start;
-	struct timespec now;
+	long ms_since_start;
+	ktime_t now;
 	const unsigned long MAX_INTERVAL = 100000L;
 	const unsigned long ONESEC_INTERVAL = HZ;
 	const long MS_LIMIT = 3000;
 	long difference;
 
-	ktime_get_ts(&now);
+	now = ktime_get();
 
 	if (atomic_read(&core_timer.count) ==
 	    atomic_read(&core_timer.last_count)) {
@@ -10076,7 +10058,7 @@ static void coretimer_func(TIMER_DATA_TYPE unused)
 				  core_timer.interval);
 		}
 
-		ms_since_start = core_diff_ms(&core_timer.start_interval, &now);
+		ms_since_start = ktime_ms_delta(now, core_timer.start_interval);
 
 		/*
 		 * If the system time has changed, it is possible for us to be
@@ -10130,7 +10112,7 @@ static void coretimer_func(TIMER_DATA_TYPE unused)
 static void coretimer_init(void)
 {
 	timer_setup(&core_timer.timer, coretimer_func, 0);
-	ktime_get_ts(&core_timer.start_interval);
+	core_timer.start_interval = ktime_get();
 	atomic_set(&core_timer.count, 0);
 	atomic_set(&core_timer.shutdown, 0);
 	core_timer.interval = max(msecs_to_jiffies(DAHDI_MSECS_PER_CHUNK), 1UL);