From 6eaefc4bf9ba53622dca3fff3bd0bdb89763ac1c Mon Sep 17 00:00:00 2001 From: Mahesh Kumar Kalikot Veetil Date: Thu, 25 May 2017 10:41:50 -0700 Subject: [PATCH] qcacmn: Fix qdf_timer_init/free implementation With DEBUG_OBJECTS_TIMERS enabled, cds_mc_thread prints warning "ODEBUG: object is on stack, but not annotated". Since the wd_timer is on the stack, we should rightly use set_timer API's. Change-Id: I38061ff6c1b706484cd5d4532954cfa24c7ac0d6 CRs-Fixed: 2052484 --- qdf/linux/src/i_qdf_timer.h | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/qdf/linux/src/i_qdf_timer.h b/qdf/linux/src/i_qdf_timer.h index 7909015627d1..92695c7fdc3f 100644 --- a/qdf/linux/src/i_qdf_timer.h +++ b/qdf/linux/src/i_qdf_timer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -39,6 +39,11 @@ #include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) +#define setup_deferrable_timer(timer, fn, data) \ + __setup_timer((timer), (fn), (data), TIMER_DEFERRABLE) +#endif + /* timer data type */ typedef struct timer_list __qdf_timer_t; @@ -64,12 +69,24 @@ static inline QDF_STATUS __qdf_timer_init(qdf_handle_t hdl, qdf_timer_func_t func, void *arg, QDF_TIMER_TYPE type) { - if (QDF_TIMER_TYPE_SW == type) - init_timer_deferrable(timer); - else - init_timer(timer); - timer->function = (qdf_dummy_timer_func_t) func; - timer->data = (unsigned long)arg; + if (type == QDF_TIMER_TYPE_SW) { + if (object_is_on_stack(timer)) + setup_deferrable_timer_on_stack( + timer, (qdf_dummy_timer_func_t)func, + (unsigned long)arg); + else + setup_deferrable_timer(timer, + (qdf_dummy_timer_func_t)func, + (unsigned long)arg); + } else { + if (object_is_on_stack(timer)) + setup_timer_on_stack(timer, + (qdf_dummy_timer_func_t)func, + (unsigned long)arg); + else + setup_timer(timer, (qdf_dummy_timer_func_t)func, + (unsigned long)arg); + } return QDF_STATUS_SUCCESS; } @@ -124,12 +141,14 @@ static inline bool __qdf_timer_stop(struct timer_list *timer) * __qdf_timer_free() - free a qdf timer * @timer: Pointer to timer object * - * Return: true if timer was cancelled and deactived, - * false if timer was cancelled but already got fired. + * Return: None */ static inline void __qdf_timer_free(struct timer_list *timer) { del_timer_sync(timer); + + if (object_is_on_stack(timer)) + destroy_timer_on_stack(timer); } /**