Skip to content

Commit 154a999

Browse files
author
Matheus Marchini
committed
Fix build for Kernel 4.10 or higher
Build wasn't working on Kernel 4.10 or higher because of some changes on their headers, this patch fixes it without breaking build on previous kernel versions.
1 parent 6254f0a commit 154a999

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

driver/cyclic_linux.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ static void cyclic_tasklet_func(unsigned long arg)
190190
break;
191191

192192
ptr = &cp->c_htp;
193-
kt.tv64 = cp->c_time.cyt_interval;
193+
#if(LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0))
194+
kt.tv64 = cp->c_time.cyt_interval;
195+
#else
196+
kt = cp->c_time.cyt_interval;
197+
#endif
194198
/***********************************************/
195199
/* Invoke the callback. */
196200
/***********************************************/
@@ -326,11 +330,15 @@ cyclic_add(cyc_handler_t *hdrl, cyc_time_t *t)
326330
}
327331

328332
cnt_timer_add++;
329-
kt.tv64 = t->cyt_interval;
333+
#if(LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0))
334+
kt.tv64 = t->cyt_interval;
335+
#else
336+
kt = t->cyt_interval;
337+
#endif
330338
cp->c_hdlr = *hdrl;
331339
cp->c_time = *t;
332-
cp->c_sec = kt.tv64 / (1000 * 1000 * 1000);
333-
cp->c_nsec = kt.tv64 % (1000 * 1000 * 1000);
340+
cp->c_sec = ktime_to_ns(kt) / (1000 * 1000 * 1000);
341+
cp->c_nsec = ktime_to_ns(kt) % (1000 * 1000 * 1000);
334342
cp->c_state = TMR_ALIVE;
335343

336344
fn_hrtimer_init(&cp->c_htp, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
@@ -471,4 +479,3 @@ cyclic_remove(cyclic_id_t id)
471479
}
472480
}
473481
# endif
474-

driver/dtrace_linux.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ dtrace_linux_init(void)
762762
}
763763
# if defined(__arm__)
764764
ktime_get_ptr = (ktime_t (*)(void)) get_proc_addr("ktime_get");
765-
# define rdtscll(t) t = ktime_get_ptr().tv64
765+
# define rdtscll(t) t = ktime_to_ns(ktime_get_ptr())
766766
# define __flush_tlb_all() local_flush_tlb_all()
767767
# define _PAGE_NX 0
768768
# define _PAGE_RW 0
@@ -3246,4 +3246,3 @@ static void __exit dtracedrv_exit(void)
32463246
}
32473247
module_init(dtracedrv_init);
32483248
module_exit(dtracedrv_exit);
3249-

0 commit comments

Comments
 (0)