]> git.pld-linux.org Git - packages/dahdi-linux.git/blob - 0002-fix-building-with-4.15-init_timer-setup_timer.patch
Release 2 (by relup.sh)
[packages/dahdi-linux.git] / 0002-fix-building-with-4.15-init_timer-setup_timer.patch
1 From 19af3ae5af6857402e0e8a3e3b35c81320917454 Mon Sep 17 00:00:00 2001
2 From: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
3 Date: Mon, 1 Jan 2018 09:50:01 +0200
4 Subject: [PATCH 2/2] fix building with 4.15: init_timer / setup_timer
5
6 Kernel 4.15 revised the interface for callbacks to timers. For that the
7 initialization of timers has changed.
8
9 Changes are conditioned on the preprocesson define init_timer that was
10 removed.
11
12 DAHLIN-359 #close
13
14 Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
15 ---
16  drivers/dahdi/dahdi-base.c          | 11 ++++++++---
17  drivers/dahdi/dahdi_dynamic.c       | 13 ++++++++-----
18  drivers/dahdi/dahdi_dynamic_ethmf.c | 11 ++++++++---
19  drivers/dahdi/wctc4xxp/base.c       |  8 +++++++-
20  drivers/dahdi/wcte12xp/base.c       |  9 ++++++++-
21  drivers/dahdi/wcte13xp-base.c       |  8 +++++++-
22  drivers/dahdi/wcte43x-base.c        |  8 +++++++-
23  drivers/dahdi/xpp/xbus-core.c       | 10 +++++++---
24  include/dahdi/kernel.h              | 10 ++++++++++
25  9 files changed, 70 insertions(+), 18 deletions(-)
26
27 diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
28 index 618754d..c473474 100644
29 --- a/drivers/dahdi/dahdi-base.c
30 +++ b/drivers/dahdi/dahdi-base.c
31 @@ -10069,7 +10069,13 @@ static inline unsigned long msecs_processed(const struct core_timer *const ct)
32         return atomic_read(&ct->count) * DAHDI_MSECS_PER_CHUNK;
33  }
34  
35 -static void coretimer_func(unsigned long param)
36 +static void coretimer_func(
37 +#ifdef init_timer      /* Compatibility for pre 4.15 interface */
38 +               unsigned long param
39 +#else
40 +               struct timer_list *t
41 +#endif
42 +)
43  {
44         unsigned long flags;
45         unsigned long ms_since_start;
46 @@ -10150,8 +10156,7 @@ static void coretimer_func(unsigned long param)
47  
48  static void coretimer_init(void)
49  {
50 -       init_timer(&core_timer.timer);
51 -       core_timer.timer.function = coretimer_func;
52 +       timer_setup(&core_timer.timer, coretimer_func, 0);
53         ktime_get_ts(&core_timer.start_interval);
54         atomic_set(&core_timer.count, 0);
55         atomic_set(&core_timer.shutdown, 0);
56 diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c
57 index 0a37e2a..6727bd4 100644
58 --- a/drivers/dahdi/dahdi_dynamic.c
59 +++ b/drivers/dahdi/dahdi_dynamic.c
60 @@ -831,7 +831,13 @@ EXPORT_SYMBOL(dahdi_dynamic_unregister_driver);
61  
62  static struct timer_list alarmcheck;
63  
64 -static void check_for_red_alarm(unsigned long ignored)
65 +static void check_for_red_alarm(
66 +#ifdef init_timer      /* Compatibility for pre 4.15 interface */
67 +               unsigned long ignored
68 +#else
69 +               struct timer_list *ignored
70 +#endif
71 +)
72  {
73         int newalarm;
74         int alarmchanged = 0;
75 @@ -867,10 +873,7 @@ static const struct dahdi_dynamic_ops dahdi_dynamic_ops = {
76  static int dahdi_dynamic_init(void)
77  {
78         /* Start process to check for RED ALARM */
79 -       init_timer(&alarmcheck);
80 -       alarmcheck.expires = 0;
81 -       alarmcheck.data = 0;
82 -       alarmcheck.function = check_for_red_alarm;
83 +       timer_setup(&alarmcheck, check_for_red_alarm, 0);
84         /* Check once per second */
85         mod_timer(&alarmcheck, jiffies + 1 * HZ);
86  #ifdef ENABLE_TASKLETS
87 diff --git a/drivers/dahdi/dahdi_dynamic_ethmf.c b/drivers/dahdi/dahdi_dynamic_ethmf.c
88 index dec368b..4d7d2f1 100644
89 --- a/drivers/dahdi/dahdi_dynamic_ethmf.c
90 +++ b/drivers/dahdi/dahdi_dynamic_ethmf.c
91 @@ -681,7 +681,13 @@ static int ethmf_delay_dec(void)
92   * Timer callback function to allow all spans to be added, prior to any of
93   * them being used.
94   */
95 -static void timer_callback(unsigned long param)
96 +static void timer_callback(
97 +#ifdef init_timer      /* Compatibility for pre 4.15 interface */
98 +               unsigned long ignored
99 +#else
100 +               struct timer_list *ignored
101 +#endif
102 +)
103  {
104         if (ethmf_delay_dec()) {
105                 if (!atomic_read(&timer_deleted)) {
106 @@ -764,9 +770,8 @@ static const struct file_operations ztdethmf_proc_fops = {
107  
108  static int __init ztdethmf_init(void)
109  {
110 -       init_timer(&timer);
111 +       timer_setup(&timer, &timer_callback, 0);
112         timer.expires = jiffies + HZ;
113 -       timer.function = &timer_callback;
114         if (!timer_pending(&timer))
115                 add_timer(&timer);
116  
117 diff --git a/drivers/dahdi/wctc4xxp/base.c b/drivers/dahdi/wctc4xxp/base.c
118 index 0d76d6a..8e0b76b 100644
119 --- a/drivers/dahdi/wctc4xxp/base.c
120 +++ b/drivers/dahdi/wctc4xxp/base.c
121 @@ -3701,9 +3701,15 @@ wctc4xxp_send_commands(struct wcdte *wc, struct list_head *to_send)
122  }
123  
124  static void
125 +#ifndef init_timer
126 +wctc4xxp_watchdog(struct timer_list *t)
127 +{
128 +       struct wcdte *wc = from_timer(wc, t, watchdog);
129 +#else  /* Compatibility for pre 4.15 interface */
130  wctc4xxp_watchdog(unsigned long data)
131  {
132         struct wcdte *wc = (struct wcdte *)data;
133 +#endif
134         struct tcb *cmd, *temp;
135         LIST_HEAD(cmds_to_retry);
136         const int MAX_RETRIES = 5;
137 @@ -4095,7 +4101,7 @@ wctc4xxp_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
138         wc->watchdog.data = (unsigned long)wc;
139         init_timer(&wc->watchdog);
140  #      else
141 -       setup_timer(&wc->watchdog, wctc4xxp_watchdog, (unsigned long)wc);
142 +       timer_setup(&wc->watchdog, wctc4xxp_watchdog, 0);
143  #      endif
144  
145         /* ------------------------------------------------------------------
146 diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c
147 index c327c5f..77e2d2f 100644
148 --- a/drivers/dahdi/wcte12xp/base.c
149 +++ b/drivers/dahdi/wcte12xp/base.c
150 @@ -2765,10 +2765,17 @@ static void vpm_check_func(struct work_struct *work)
151         return;
152  }
153  
154 +#ifndef init_timer
155 +static void te12xp_timer(struct timer_list *t)
156 +{
157 +       unsigned long flags;
158 +       struct t1 *wc = from_timer(wc, t, timer);
159 +#else  /* Compatibility for pre 4.15 interface */
160  static void te12xp_timer(unsigned long data)
161  {
162         unsigned long flags;
163         struct t1 *wc = (struct t1 *)data;
164 +#endif
165  
166         if (unlikely(!test_bit(INITIALIZED, &wc->bit_flags)))
167                 return;
168 @@ -2943,7 +2950,7 @@ static int __devinit te12xp_init_one(struct pci_dev *pdev, const struct pci_devi
169         spin_lock_init(&wc->reglock);
170         INIT_LIST_HEAD(&wc->active_cmds);
171         INIT_LIST_HEAD(&wc->pending_cmds);
172 -       setup_timer(&wc->timer, te12xp_timer, (unsigned long)wc);
173 +       timer_setup(&wc->timer, te12xp_timer, 0);
174  
175  #      if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
176         INIT_WORK(&wc->timer_work, timer_work_func, wc);
177 diff --git a/drivers/dahdi/wcte13xp-base.c b/drivers/dahdi/wcte13xp-base.c
178 index c5ebe9d..57e6dac 100644
179 --- a/drivers/dahdi/wcte13xp-base.c
180 +++ b/drivers/dahdi/wcte13xp-base.c
181 @@ -2381,9 +2381,15 @@ static void te13x_handle_interrupt(struct wcxb *xb, u32 pending)
182         }
183  }
184  
185 +#ifndef init_timer
186 +static void te13xp_timer(struct timer_list *t)
187 +{
188 +       struct t13x *wc = from_timer(wc, t, timer);
189 +#else  /* Compatibility for pre 4.15 interface */
190  static void te13xp_timer(unsigned long data)
191  {
192         struct t13x *wc = (struct t13x *)data;
193 +#endif
194  
195         if (unlikely(!test_bit(INITIALIZED, &wc->bit_flags)))
196                 return;
197 @@ -2582,7 +2588,7 @@ static int __devinit te13xp_init_one(struct pci_dev *pdev,
198         wc->ledstate = -1;
199         spin_lock_init(&wc->reglock);
200         mutex_init(&wc->lock);
201 -       setup_timer(&wc->timer, te13xp_timer, (unsigned long)wc);
202 +       timer_setup(&wc->timer, te13xp_timer, 0);
203  
204  #      if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
205         INIT_WORK(&wc->timer_work, timer_work_func, wc);
206 diff --git a/drivers/dahdi/wcte43x-base.c b/drivers/dahdi/wcte43x-base.c
207 index 3e6159b..af39165 100644
208 --- a/drivers/dahdi/wcte43x-base.c
209 +++ b/drivers/dahdi/wcte43x-base.c
210 @@ -3203,9 +3203,15 @@ static void t43x_handle_interrupt(struct wcxb *xb, u32 pending)
211                 wc->intr_span = 0;
212  }
213  
214 +#ifndef init_timer
215 +static void t43x_timer(struct timer_list *t)
216 +{
217 +       struct t43x *wc = from_timer(wc, t, timer);
218 +#else  /* Compatibility for pre 4.15 interface */
219  static void t43x_timer(unsigned long data)
220  {
221         struct t43x *wc = (struct t43x *)data;
222 +#endif
223  
224         if (!is_initialized(wc))
225                 return;
226 @@ -3431,7 +3437,7 @@ static int __devinit t43x_init_one(struct pci_dev *pdev,
227                 goto fail_exit;
228  
229         mutex_init(&wc->lock);
230 -       setup_timer(&wc->timer, t43x_timer, (unsigned long)wc);
231 +       timer_setup(&wc->timer, t43x_timer, 0);
232  
233  #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
234         INIT_WORK(&wc->timer_work, timer_work_func, wc);
235 diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c
236 index ca129cd..5bd8853 100644
237 --- a/drivers/dahdi/xpp/xbus-core.c
238 +++ b/drivers/dahdi/xpp/xbus-core.c
239 @@ -1350,9 +1350,15 @@ err:
240         return 0;
241  }
242  
243 +#ifndef init_timer
244 +static void xbus_command_timer(struct timer_list *t)
245 +{
246 +       xbus_t *xbus = from_timer(xbus, t, command_timer);
247 +#else
248  static void xbus_command_timer(unsigned long param)
249  {
250         xbus_t *xbus = (xbus_t *)param;
251 +#endif
252         struct timeval now;
253  
254         BUG_ON(!xbus);
255 @@ -1368,8 +1374,6 @@ void xbus_set_command_timer(xbus_t *xbus, bool on)
256         if (on) {
257                 if (!timer_pending(&xbus->command_timer)) {
258                         XBUS_DBG(SYNC, xbus, "add_timer\n");
259 -                       xbus->command_timer.function = xbus_command_timer;
260 -                       xbus->command_timer.data = (unsigned long)xbus;
261                         xbus->command_timer.expires = jiffies + 1;
262                         add_timer(&xbus->command_timer);
263                 }
264 @@ -1642,7 +1646,7 @@ xbus_t *xbus_new(struct xbus_ops *ops, ushort max_send_size,
265         transport_init(xbus, ops, max_send_size, transport_device, priv);
266         spin_lock_init(&xbus->lock);
267         init_waitqueue_head(&xbus->command_queue_empty);
268 -       init_timer(&xbus->command_timer);
269 +       timer_setup(&xbus->command_timer, xbus_command_timer, 0);
270         atomic_set(&xbus->pcm_rx_counter, 0);
271         xbus->min_tx_sync = INT_MAX;
272         xbus->min_rx_sync = INT_MAX;
273 diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h
274 index c946fa3..bc07ef6 100644
275 --- a/include/dahdi/kernel.h
276 +++ b/include/dahdi/kernel.h
277 @@ -1630,6 +1630,16 @@ struct mutex {
278         printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
279  #endif
280  
281 +
282 +#ifdef init_timer      /* Compatibility for pre 4.15 interface */
283 +#define timer_setup(timer, func, flags)        \
284 +       do {                                    \
285 +               init_timer(timer);              \
286 +               (timer)->function = (func);     \
287 +       } while (0)
288 +#endif
289 +
290 +
291  /* If KBUILD_MODNAME is not defined in a compilation unit, then the dev_dbg
292   * macro will not work properly. */
293  #ifndef KBUILD_MODNAME
294 -- 
295 2.11.0
296
This page took 0.046145 seconds and 3 git commands to generate.