From 8acb74ae9a3491d61d53296aa737036d48e7625b Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Tue, 15 Jan 2019 14:06:59 -0800 Subject: [PATCH] qcacmn: Add >=4.15 kernel support to qdf_timer The various setup_*_timer() APIs were removed from the linux kernel in 4.15, and replaced with similar timer_setup_*() APIs. Add conditional compilation to qdf_timer to use the correct APIs depending on the version of the kernel being compiled against. Change-Id: Ibe0f8adc4df7bb98aceb509d438e241fac507393 CRs-Fixed: 2388570 --- qdf/linux/src/i_qdf_timer.h | 46 +++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/qdf/linux/src/i_qdf_timer.h b/qdf/linux/src/i_qdf_timer.h index 062f4cc7cfc4..53254b068590 100644 --- a/qdf/linux/src/i_qdf_timer.h +++ b/qdf/linux/src/i_qdf_timer.h @@ -33,15 +33,50 @@ #include #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) -#define setup_deferrable_timer(timer, fn, data) \ - __setup_timer((timer), (fn), (data), TIMER_DEFERRABLE) -#endif - struct __qdf_timer_t { struct timer_list os_timer; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + qdf_timer_func_t callback; + void *context; +#endif }; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +static inline void __os_timer_shim(struct timer_list *os_timer) +{ + struct __qdf_timer_t *timer = from_timer(timer, os_timer, os_timer); + + timer->callback(timer->context); +} + +static inline QDF_STATUS __qdf_timer_init(struct __qdf_timer_t *timer, + qdf_timer_func_t func, void *arg, + QDF_TIMER_TYPE type) +{ + struct timer_list *os_timer = &timer->os_timer; + uint32_t flags = 0; + + timer->callback = func; + timer->context = arg; + + if (type == QDF_TIMER_TYPE_SW) + flags |= TIMER_DEFERRABLE; + + if (object_is_on_stack(os_timer)) + timer_setup_on_stack(os_timer, __os_timer_shim, flags); + else + timer_setup(os_timer, __os_timer_shim, flags); + + return QDF_STATUS_SUCCESS; +} + +#else + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) +#define setup_deferrable_timer(timer, fn, data) \ + __setup_timer((timer), (fn), (data), TIMER_DEFERRABLE) +#endif + typedef void (*__legacy_timer_callback_t)(unsigned long arg); static inline QDF_STATUS __qdf_timer_init(struct __qdf_timer_t *timer, @@ -68,6 +103,7 @@ static inline QDF_STATUS __qdf_timer_init(struct __qdf_timer_t *timer, return QDF_STATUS_SUCCESS; } +#endif /* KERNEL_VERSION(4, 15, 0)*/ static inline void __qdf_timer_start(struct __qdf_timer_t *timer, uint32_t msec) {