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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
|
From 3ecb30703a1ebe5f92785cbe5228707959067bd7 Mon Sep 17 00:00:00 2001
From: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Date: Mon, 1 Jan 2018 09:50:01 +0200
Subject: [PATCH] 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@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 | 13 ++++++++++---
include/dahdi/kernel.h | 10 ++++++++++
9 files changed, 73 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..f9aa754 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,10 @@ 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);
+#ifdef init_timer
+ xbus->command_timer.data = (unsigned long)xbus;
+#endif
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
|