qcacmn: Fix kernel 4.15 timer list dependencies

With the changes made in Ibe0f8adc4df7bb98aceb509d438e241fac507393 and
Ic4cef0d6301230197443d4d5247188f2af643674 there are compilation issues
with converged code.

Resolve the issues by creating ifdefs for the timer_list definitions
according to kernel version.

Change-Id: Id9c29413ca0d21533a0afae245595051fa3a400f
CRs-Fixed: 2390884
This commit is contained in:
Sourav Mohapatra
2019-01-31 08:59:34 +05:30
committed by nshrivas
parent 8acb74ae9a
commit 6066636527
2 changed files with 71 additions and 37 deletions

View File

@@ -27,7 +27,11 @@
#include <qdf_types.h> #include <qdf_types.h>
#include <i_qdf_timer.h> #include <i_qdf_timer.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
typedef struct __qdf_timer_t qdf_timer_t; typedef struct __qdf_timer_t qdf_timer_t;
#else
typedef __qdf_timer_t qdf_timer_t;
#endif
/** /**
* qdf_timer_init() - initialize a timer * qdf_timer_init() - initialize a timer

View File

@@ -33,15 +33,18 @@
#include <linux/sched/task_stack.h> #include <linux/sched/task_stack.h>
#endif #endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
struct __qdf_timer_t { struct __qdf_timer_t {
struct timer_list os_timer; struct timer_list os_timer;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
qdf_timer_func_t callback; qdf_timer_func_t callback;
void *context; void *context;
#endif
}; };
#else
typedef struct timer_list __qdf_timer_t;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
static inline void __os_timer_shim(struct timer_list *os_timer) static inline void __os_timer_shim(struct timer_list *os_timer)
{ {
struct __qdf_timer_t *timer = from_timer(timer, os_timer, os_timer); struct __qdf_timer_t *timer = from_timer(timer, os_timer, os_timer);
@@ -70,41 +73,6 @@ static inline QDF_STATUS __qdf_timer_init(struct __qdf_timer_t *timer,
return QDF_STATUS_SUCCESS; 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,
qdf_timer_func_t func, void *arg,
QDF_TIMER_TYPE type)
{
struct timer_list *os_timer = &timer->os_timer;
bool is_on_stack = object_is_on_stack(os_timer);
__legacy_timer_callback_t callback = (__legacy_timer_callback_t)func;
unsigned long ctx = (unsigned long)arg;
if (type == QDF_TIMER_TYPE_SW) {
if (is_on_stack)
setup_deferrable_timer_on_stack(os_timer, callback,
ctx);
else
setup_deferrable_timer(os_timer, callback, ctx);
} else {
if (is_on_stack)
setup_timer_on_stack(os_timer, callback, ctx);
else
setup_timer(os_timer, callback, ctx);
}
return QDF_STATUS_SUCCESS;
}
#endif /* KERNEL_VERSION(4, 15, 0)*/
static inline void __qdf_timer_start(struct __qdf_timer_t *timer, uint32_t msec) static inline void __qdf_timer_start(struct __qdf_timer_t *timer, uint32_t msec)
{ {
struct timer_list *os_timer = &timer->os_timer; struct timer_list *os_timer = &timer->os_timer;
@@ -137,5 +105,67 @@ static inline bool __qdf_timer_sync_cancel(struct __qdf_timer_t *timer)
{ {
return del_timer_sync(&timer->os_timer); return del_timer_sync(&timer->os_timer);
} }
#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(__qdf_timer_t *os_timer,
qdf_timer_func_t func, void *arg,
QDF_TIMER_TYPE type)
{
bool is_on_stack = object_is_on_stack(os_timer);
__legacy_timer_callback_t callback = (__legacy_timer_callback_t)func;
unsigned long ctx = (unsigned long)arg;
if (type == QDF_TIMER_TYPE_SW) {
if (is_on_stack)
setup_deferrable_timer_on_stack(os_timer, callback,
ctx);
else
setup_deferrable_timer(os_timer, callback, ctx);
} else {
if (is_on_stack)
setup_timer_on_stack(os_timer, callback, ctx);
else
setup_timer(os_timer, callback, ctx);
}
return QDF_STATUS_SUCCESS;
}
static inline void __qdf_timer_start(__qdf_timer_t *timer, uint32_t msec)
{
timer->expires = jiffies + msecs_to_jiffies(msec);
add_timer(timer);
}
static inline void __qdf_timer_mod(__qdf_timer_t *timer, uint32_t msec)
{
mod_timer(timer, jiffies + msecs_to_jiffies(msec));
}
static inline bool __qdf_timer_stop(__qdf_timer_t *timer)
{
return !!del_timer(timer);
}
static inline void __qdf_timer_free(__qdf_timer_t *timer)
{
del_timer_sync(timer);
if (object_is_on_stack(timer))
destroy_timer_on_stack(timer);
}
static inline bool __qdf_timer_sync_cancel(__qdf_timer_t *timer)
{
return del_timer_sync(timer);
}
#endif /* KERNEL_VERSION(4, 15, 0)*/
#endif /* _I_QDF_TIMER_H */ #endif /* _I_QDF_TIMER_H */