diff mbox series

[bionic,02/10] UBUNTU: SAUCE: ubuntu/rtl8821c: Adapt to timer API changes

Message ID 20180323164707.6027-3-jesse.sung@canonical.com
State New
Headers show
Series Add drivers for RTL8821C WiFi and BT | expand

Commit Message

Wen-chien Jesse Sung March 23, 2018, 4:46 p.m. UTC
BugLink: https://launchpad.net/bugs/1740231

Signed-off-by: Wen-chien Jesse Sung <jesse.sung@canonical.com>
---
 ubuntu/rtl8821c/core/rtw_ap.c                 |  4 ++--
 ubuntu/rtl8821c/core/rtw_mlme.c               | 16 +++++++-------
 ubuntu/rtl8821c/core/rtw_mlme_ext.c           | 24 ++++++++++----------
 ubuntu/rtl8821c/core/rtw_p2p.c                | 32 +++++++++++++--------------
 ubuntu/rtl8821c/core/rtw_pwrctrl.c            | 15 ++++++-------
 ubuntu/rtl8821c/core/rtw_recv.c               | 10 ++++-----
 ubuntu/rtl8821c/core/rtw_sreset.c             |  2 +-
 ubuntu/rtl8821c/core/rtw_tdls.c               | 28 +++++++++++------------
 ubuntu/rtl8821c/core/rtw_xmit.c               | 20 ++++++++++-------
 ubuntu/rtl8821c/hal/hal_btcoex.c              |  2 +-
 ubuntu/rtl8821c/hal/led/hal_pci_led.c         |  4 ++--
 ubuntu/rtl8821c/include/hal_com_led.h         |  2 +-
 ubuntu/rtl8821c/include/osdep_service_linux.h |  7 ++----
 ubuntu/rtl8821c/include/rtw_ap.h              |  2 +-
 ubuntu/rtl8821c/include/rtw_mlme.h            |  8 +++----
 ubuntu/rtl8821c/include/rtw_mlme_ext.h        |  8 +++----
 ubuntu/rtl8821c/include/rtw_pwrctrl.h         |  1 +
 ubuntu/rtl8821c/include/rtw_recv.h            |  2 +-
 18 files changed, 94 insertions(+), 93 deletions(-)
diff mbox series

Patch

diff --git a/ubuntu/rtl8821c/core/rtw_ap.c b/ubuntu/rtl8821c/core/rtw_ap.c
index 80678e53f576..b9c88e1ab4b1 100644
--- a/ubuntu/rtl8821c/core/rtw_ap.c
+++ b/ubuntu/rtl8821c/core/rtw_ap.c
@@ -4164,9 +4164,9 @@  void tx_beacon_handlder(struct dvobj_priv *pdvobj)
 
 }
 
-void tx_beacon_timer_handlder(void *ctx)
+void tx_beacon_timer_handlder(struct timer_list *t)
 {
-	struct dvobj_priv *pdvobj = (struct dvobj_priv *)ctx;
+	struct dvobj_priv *pdvobj = from_timer(pdvobj, t, txbcn_timer);
 	_adapter *padapter = pdvobj->padapters[0];
 
 	if (padapter)
diff --git a/ubuntu/rtl8821c/core/rtw_mlme.c b/ubuntu/rtl8821c/core/rtw_mlme.c
index 407c259ceba4..dc8c2f156c37 100644
--- a/ubuntu/rtl8821c/core/rtw_mlme.c
+++ b/ubuntu/rtl8821c/core/rtw_mlme.c
@@ -2701,9 +2701,9 @@  void rtw_wmm_event_callback(PADAPTER padapter, u8 *pbuf)
 /*
 * rtw_join_timeout_handler - Timeout/failure handler for CMD JoinBss
 */
-void rtw_join_timeout_handler(void *ctx)
+void rtw_join_timeout_handler(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)ctx;
+	_adapter *adapter = from_timer(adapter, t, mlmepriv.assoc_timer);
 	_irqL irqL;
 	struct	mlme_priv *pmlmepriv = &adapter->mlmepriv;
 
@@ -2783,9 +2783,9 @@  void rtw_join_timeout_handler(void *ctx)
 * rtw_scan_timeout_handler - Timeout/Faliure handler for CMD SiteSurvey
 * @adapter: pointer to _adapter structure
 */
-void rtw_scan_timeout_handler(void *ctx)
+void rtw_scan_timeout_handler(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)ctx;
+	_adapter *adapter = from_timer(adapter, t, mlmepriv.scan_to_timer);
 	_irqL irqL;
 	struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
 	RTW_INFO(FUNC_ADPT_FMT" fw_state=%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv));
@@ -3050,9 +3050,9 @@  static void collect_traffic_statistics(_adapter *padapter)
 	#endif
 }
 
-void rtw_dynamic_check_timer_handlder(void *ctx)
+void rtw_dynamic_check_timer_handlder(struct timer_list *t)
 {
-	struct dvobj_priv *pdvobj = (struct dvobj_priv *)ctx;
+	struct dvobj_priv *pdvobj = from_timer(pdvobj, t, dynamic_chk_timer);
 	_adapter *adapter = dvobj_get_primary_adapter(pdvobj);
 
 #if (MP_DRIVER == 1)
@@ -3098,9 +3098,9 @@  inline void rtw_clear_scan_deny(_adapter *adapter)
 		RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter));
 }
 
-void rtw_set_scan_deny_timer_hdl(void *ctx)
+void rtw_set_scan_deny_timer_hdl(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)ctx;
+	_adapter *adapter = from_timer(adapter, t, mlmepriv.set_scan_deny_timer);
 
 	rtw_clear_scan_deny(adapter);
 }
diff --git a/ubuntu/rtl8821c/core/rtw_mlme_ext.c b/ubuntu/rtl8821c/core/rtw_mlme_ext.c
index a91e7b98d906..31afc2a7611e 100644
--- a/ubuntu/rtl8821c/core/rtw_mlme_ext.c
+++ b/ubuntu/rtl8821c/core/rtw_mlme_ext.c
@@ -12760,9 +12760,9 @@  void linked_status_chk(_adapter *padapter, u8 from_timer)
 
 }
 
-void survey_timer_hdl(void *ctx)
+void survey_timer_hdl(struct timer_list *t)
 {
-	_adapter *padapter = (_adapter *)ctx;
+	_adapter *padapter = from_timer(padapter, t, mlmeextpriv.survey_timer);
 	struct cmd_obj *cmd;
 	struct sitesurvey_parm *psurveyPara;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
@@ -12793,9 +12793,9 @@  void survey_timer_hdl(void *ctx)
 	return;
 }
 
-void link_timer_hdl(void *ctx)
+void link_timer_hdl(struct timer_list *t)
 {
-	_adapter *padapter = (_adapter *)ctx;
+	_adapter *padapter = from_timer(padapter, t, mlmeextpriv.link_timer);
 	/* static unsigned int		rx_pkt = 0; */
 	/* static u64				tx_cnt = 0; */
 	/* struct xmit_priv		*pxmitpriv = &(padapter->xmitpriv); */
@@ -12867,9 +12867,9 @@  void link_timer_hdl(void *ctx)
 	return;
 }
 
-void addba_timer_hdl(void *ctx)
+void addba_timer_hdl(struct timer_list *t)
 {
-	struct sta_info *psta = (struct sta_info *)ctx;
+	struct sta_info *psta = from_timer(psta, t, addba_retry_timer);
 
 #ifdef CONFIG_80211N_HT
 	struct ht_priv	*phtpriv;
@@ -12955,9 +12955,9 @@  void clnt_sa_query_timeout(_adapter *padapter)
 	RTW_INFO("SA query timeout client disconnect\n");
 }
 
-void sa_query_timer_hdl(void *ctx)
+void sa_query_timer_hdl(struct timer_list *t)
 {
-	struct sta_info *psta = (struct sta_info *)ctx;
+	struct sta_info *psta = from_timer(psta, t, dot11w_expire_timer);
 	_adapter *padapter = psta->padapter;
 	_irqL irqL;
 	struct sta_priv *pstapriv = &padapter->stapriv;
@@ -12983,9 +12983,9 @@  void start_clnt_ft_action(_adapter *padapter, u8 *pTargetAddr)
 	_set_timer(&pmlmeext->ft_link_timer, REASSOC_TO);
 }
 
-void ft_link_timer_hdl(void *ctx)
+void ft_link_timer_hdl(struct timer_list *t)
 {
-	_adapter *padapter = (_adapter *)ctx;
+	_adapter *padapter = from_timer(padapter, t, mlmeextpriv.ft_link_timer);
 	struct mlme_ext_priv	*pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info	*pmlmeinfo = &(pmlmeext->mlmext_info);
 	struct	mlme_priv	*pmlmepriv = &(padapter->mlmepriv);
@@ -13007,9 +13007,9 @@  void ft_link_timer_hdl(void *ctx)
 	}
 }
 
-void ft_roam_timer_hdl(void *ctx)
+void ft_roam_timer_hdl(struct timer_list *t)
 {
-	_adapter *padapter = (_adapter *)ctx;
+	_adapter *padapter = from_timer(padapter, t, mlmeextpriv.ft_roam_timer);
 	struct mlme_priv	*pmlmepriv = &(padapter->mlmepriv);
 
 	receive_disconnect(padapter, pmlmepriv->cur_network.network.MacAddress
diff --git a/ubuntu/rtl8821c/core/rtw_p2p.c b/ubuntu/rtl8821c/core/rtw_p2p.c
index ee1da7b7ba2a..eed1285432e9 100644
--- a/ubuntu/rtl8821c/core/rtw_p2p.c
+++ b/ubuntu/rtl8821c/core/rtw_p2p.c
@@ -3355,9 +3355,9 @@  static int cancel_ro_ch_handler(_adapter *padapter, u8 *buf)
 	return ret;
 }
 
-static void ro_ch_timer_process(void *FunctionContext)
+static void ro_ch_timer_process(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)FunctionContext;
+	_adapter *adapter = from_timer(adapter, t, cfg80211_wdinfo.remain_on_ch_timer);
 
 	p2p_cancel_roch_cmd(adapter, 0, NULL, 0);
 }
@@ -4519,9 +4519,9 @@  u8 p2p_ps_wk_cmd(_adapter *padapter, u8 p2p_ps_state, u8 enqueue)
 }
 #endif /* CONFIG_P2P_PS */
 
-static void reset_ch_sitesurvey_timer_process(void *FunctionContext)
+static void reset_ch_sitesurvey_timer_process(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)FunctionContext;
+	_adapter *adapter = from_timer(adapter, t, wdinfo.reset_ch_sitesurvey);
 	struct	wifidirect_info		*pwdinfo = &adapter->wdinfo;
 
 	if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
@@ -4538,9 +4538,9 @@  static void reset_ch_sitesurvey_timer_process(void *FunctionContext)
 	pwdinfo->rx_invitereq_info.scan_op_ch_only = 0;
 }
 
-static void reset_ch_sitesurvey_timer_process2(void *FunctionContext)
+static void reset_ch_sitesurvey_timer_process2(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)FunctionContext;
+	_adapter *adapter = from_timer(adapter, t, wdinfo.reset_ch_sitesurvey2);
 	struct	wifidirect_info		*pwdinfo = &adapter->wdinfo;
 
 	if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
@@ -4557,9 +4557,9 @@  static void reset_ch_sitesurvey_timer_process2(void *FunctionContext)
 	pwdinfo->p2p_info.scan_op_ch_only = 0;
 }
 
-static void restore_p2p_state_timer_process(void *FunctionContext)
+static void restore_p2p_state_timer_process(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)FunctionContext;
+	_adapter *adapter = from_timer(adapter, t, wdinfo.restore_p2p_state_timer);
 	struct	wifidirect_info		*pwdinfo = &adapter->wdinfo;
 
 	if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
@@ -4568,9 +4568,9 @@  static void restore_p2p_state_timer_process(void *FunctionContext)
 	p2p_protocol_wk_cmd(adapter, P2P_RESTORE_STATE_WK);
 }
 
-static void pre_tx_scan_timer_process(void *FunctionContext)
+static void pre_tx_scan_timer_process(struct timer_list *t)
 {
-	_adapter							*adapter = (_adapter *) FunctionContext;
+	_adapter *adapter = from_timer(adapter, t, wdinfo.pre_tx_scan_timer);
 	struct	wifidirect_info				*pwdinfo = &adapter->wdinfo;
 	_irqL							irqL;
 	struct mlme_priv					*pmlmepriv = &adapter->mlmepriv;
@@ -4600,9 +4600,9 @@  static void pre_tx_scan_timer_process(void *FunctionContext)
 	_exit_critical_bh(&pmlmepriv->lock, &irqL);
 }
 
-static void find_phase_timer_process(void *FunctionContext)
+static void find_phase_timer_process(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)FunctionContext;
+	_adapter *adapter = from_timer(adapter, t, wdinfo.find_phase_timer);
 	struct	wifidirect_info		*pwdinfo = &adapter->wdinfo;
 
 	if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
@@ -4614,9 +4614,9 @@  static void find_phase_timer_process(void *FunctionContext)
 }
 
 #ifdef CONFIG_CONCURRENT_MODE
-void ap_p2p_switch_timer_process(void *FunctionContext)
+void ap_p2p_switch_timer_process(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)FunctionContext;
+	_adapter *adapter = from_timer(adapter, t, wdinfo.ap_p2p_switch_timer);
 	struct	wifidirect_info		*pwdinfo = &adapter->wdinfo;
 #ifdef CONFIG_IOCTL_CFG80211
 	struct rtw_wdev_priv *pwdev_priv = adapter_wdev_data(adapter);
@@ -5248,8 +5248,8 @@  int rtw_p2p_enable(_adapter *padapter, enum P2P_ROLE role)
 			_cancel_timer_ex(&pwdinfo->pre_tx_scan_timer);
 			_cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey);
 			_cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey2);
-			reset_ch_sitesurvey_timer_process(padapter);
-			reset_ch_sitesurvey_timer_process2(padapter);
+			reset_ch_sitesurvey_timer_process(&pwdinfo->reset_ch_sitesurvey);
+			reset_ch_sitesurvey_timer_process2(&pwdinfo->reset_ch_sitesurvey2);
 #ifdef CONFIG_CONCURRENT_MODE
 			_cancel_timer_ex(&pwdinfo->ap_p2p_switch_timer);
 #endif
diff --git a/ubuntu/rtl8821c/core/rtw_pwrctrl.c b/ubuntu/rtl8821c/core/rtw_pwrctrl.c
index 182ef5018e07..b3c42eeeb112 100644
--- a/ubuntu/rtl8821c/core/rtw_pwrctrl.c
+++ b/ubuntu/rtl8821c/core/rtw_pwrctrl.c
@@ -393,9 +393,10 @@  void rtw_ps_processor(_adapter *padapter)
 	return;
 }
 
-void pwr_state_check_handler(void *ctx)
+void pwr_state_check_handler(struct timer_list *t)
 {
-	_adapter *padapter = (_adapter *)ctx;
+	struct pwrctrl_priv *pwrpriv = from_timer(pwrpriv, t, pwr_state_check_timer);
+	_adapter *padapter = pwrpriv->adapter;
 	rtw_ps_cmd(padapter);
 }
 
@@ -1506,14 +1507,11 @@  static void rpwmtimeout_workitem_callback(struct work_struct *work)
 /*
  * This function is a timer handler, can't do any IO in it.
  */
-static void pwr_rpwm_timeout_handler(void *FunctionContext)
+static void pwr_rpwm_timeout_handler(struct timer_list *t)
 {
-	PADAPTER padapter;
-	struct pwrctrl_priv *pwrpriv;
+	struct pwrctrl_priv *pwrpriv = from_timer(pwrpriv, t, pwr_rpwm_timer);
+	PADAPTER padapter = pwrpriv->adapter;
 
-
-	padapter = (PADAPTER)FunctionContext;
-	pwrpriv = adapter_to_pwrctl(padapter);
 	if (!padapter)
 		return;
 
@@ -1963,6 +1961,7 @@  void rtw_init_pwrctrl_priv(PADAPTER padapter)
 		return;
 #endif
 
+	pwrctrlpriv->adapter = padapter;
 
 #ifdef PLATFORM_WINDOWS
 	pwrctrlpriv->pnp_current_pwr_state = NdisDeviceStateD0;
diff --git a/ubuntu/rtl8821c/core/rtw_recv.c b/ubuntu/rtl8821c/core/rtw_recv.c
index 0daac800d9d1..f014ef72bc56 100644
--- a/ubuntu/rtl8821c/core/rtw_recv.c
+++ b/ubuntu/rtl8821c/core/rtw_recv.c
@@ -30,7 +30,7 @@ 
 
 
 #ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
-static void rtw_signal_stat_timer_hdl(void *ctx);
+static void rtw_signal_stat_timer_hdl(struct timer_list *t);
 
 enum {
 	SIGNAL_STAT_CALC_PROFILE_0 = 0,
@@ -3318,10 +3318,10 @@  int recv_indicatepkt_reorder(_adapter *padapter, union recv_frame *prframe)
 }
 
 
-void rtw_reordering_ctrl_timeout_handler(void *pcontext)
+void rtw_reordering_ctrl_timeout_handler(struct timer_list *t)
 {
 	_irqL irql;
-	struct recv_reorder_ctrl *preorder_ctrl = (struct recv_reorder_ctrl *)pcontext;
+	struct recv_reorder_ctrl *preorder_ctrl = from_timer(preorder_ctrl, t, reordering_ctrl_timer);
 	_adapter *padapter = preorder_ctrl->padapter;
 	_queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
 
@@ -4325,9 +4325,9 @@  s32 rtw_recv_entry(union recv_frame *precvframe)
 }
 
 #ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
-static void rtw_signal_stat_timer_hdl(void *ctx)
+static void rtw_signal_stat_timer_hdl(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)ctx;
+	_adapter *adapter = from_timer(adapter, t, recvpriv.signal_stat_timer);
 	struct recv_priv *recvpriv = &adapter->recvpriv;
 
 	u32 tmp_s, tmp_q;
diff --git a/ubuntu/rtl8821c/core/rtw_sreset.c b/ubuntu/rtl8821c/core/rtw_sreset.c
index a93daa68a8c0..9c75131a569a 100644
--- a/ubuntu/rtl8821c/core/rtw_sreset.c
+++ b/ubuntu/rtl8821c/core/rtw_sreset.c
@@ -273,7 +273,7 @@  void sreset_stop_adapter(_adapter *padapter)
 
 	if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
 		rtw_set_to_roam(padapter, 0);
-		rtw_join_timeout_handler(padapter);
+		rtw_join_timeout_handler(&(pmlmepriv->assoc_timer));
 	}
 
 }
diff --git a/ubuntu/rtl8821c/core/rtw_tdls.c b/ubuntu/rtl8821c/core/rtw_tdls.c
index 3bb0e232bbb4..2e7e3032c3fd 100644
--- a/ubuntu/rtl8821c/core/rtw_tdls.c
+++ b/ubuntu/rtl8821c/core/rtw_tdls.c
@@ -3133,9 +3133,9 @@  void rtw_build_tunneled_probe_rsp_ies(_adapter *padapter, struct xmit_frame *pxm
 }
 #endif /* CONFIG_WFD */
 
-void _tdls_tpk_timer_hdl(void *FunctionContext)
+void _tdls_tpk_timer_hdl(struct timer_list *t)
 {
-	struct sta_info *ptdls_sta = (struct sta_info *)FunctionContext;
+	struct sta_info *ptdls_sta = from_timer(ptdls_sta, t, TPK_timer);
 	struct tdls_txmgmt txmgmt;
 
 	_rtw_memset(&txmgmt, 0x00, sizeof(struct tdls_txmgmt));
@@ -3153,9 +3153,9 @@  void _tdls_tpk_timer_hdl(void *FunctionContext)
 }
 
 #ifdef CONFIG_TDLS_CH_SW
-void _tdls_ch_switch_timer_hdl(void *FunctionContext)
+void _tdls_ch_switch_timer_hdl(struct timer_list *t)
 {
-	struct sta_info *ptdls_sta = (struct sta_info *)FunctionContext;
+	struct sta_info *ptdls_sta = from_timer(ptdls_sta, t, ch_sw_timer);
 	_adapter *padapter = ptdls_sta->padapter;
 	struct tdls_ch_switch *pchsw_info = &padapter->tdlsinfo.chsw_info;
 
@@ -3163,9 +3163,9 @@  void _tdls_ch_switch_timer_hdl(void *FunctionContext)
 	RTW_INFO("[TDLS] %s, can't get traffic from op_ch:%d\n", __func__, rtw_get_oper_ch(padapter));
 }
 
-void _tdls_delay_timer_hdl(void *FunctionContext)
+void _tdls_delay_timer_hdl(struct timer_list *t)
 {
-	struct sta_info *ptdls_sta = (struct sta_info *)FunctionContext;
+	struct sta_info *ptdls_sta = from_timer(ptdls_sta, t, delay_timer);
 	_adapter *padapter = ptdls_sta->padapter;
 	struct tdls_ch_switch *pchsw_info = &padapter->tdlsinfo.chsw_info;
 
@@ -3173,9 +3173,9 @@  void _tdls_delay_timer_hdl(void *FunctionContext)
 	pchsw_info->delay_switch_back = _TRUE;
 }
 
-void _tdls_stay_on_base_chnl_timer_hdl(void *FunctionContext)
+void _tdls_stay_on_base_chnl_timer_hdl(struct timer_list *t)
 {
-	struct sta_info *ptdls_sta = (struct sta_info *)FunctionContext;
+	struct sta_info *ptdls_sta = from_timer(ptdls_sta, t, stay_on_base_chnl_timer);
 	_adapter *padapter = ptdls_sta->padapter;
 	struct tdls_ch_switch *pchsw_info = &padapter->tdlsinfo.chsw_info;
 
@@ -3185,9 +3185,9 @@  void _tdls_stay_on_base_chnl_timer_hdl(void *FunctionContext)
 	}
 }
 
-void _tdls_ch_switch_monitor_timer_hdl(void *FunctionContext)
+void _tdls_ch_switch_monitor_timer_hdl(struct timer_list *t)
 {
-	struct sta_info *ptdls_sta = (struct sta_info *)FunctionContext;
+	struct sta_info *ptdls_sta = from_timer(ptdls_sta, t, ch_sw_monitor_timer);
 	_adapter *padapter = ptdls_sta->padapter;
 	struct tdls_ch_switch *pchsw_info = &padapter->tdlsinfo.chsw_info;
 
@@ -3197,9 +3197,9 @@  void _tdls_ch_switch_monitor_timer_hdl(void *FunctionContext)
 
 #endif
 
-void _tdls_handshake_timer_hdl(void *FunctionContext)
+void _tdls_handshake_timer_hdl(struct timer_list *t)
 {
-	struct sta_info *ptdls_sta = (struct sta_info *)FunctionContext;
+	struct sta_info *ptdls_sta = from_timer(ptdls_sta, t, handshake_timer);
 	_adapter *padapter = ptdls_sta->padapter;
 	struct tdls_txmgmt txmgmt;
 
@@ -3216,9 +3216,9 @@  void _tdls_handshake_timer_hdl(void *FunctionContext)
 	}
 }
 
-void _tdls_pti_timer_hdl(void *FunctionContext)
+void _tdls_pti_timer_hdl(struct timer_list *t)
 {
-	struct sta_info *ptdls_sta = (struct sta_info *)FunctionContext;
+	struct sta_info *ptdls_sta = from_timer(ptdls_sta, t, pti_timer);
 	_adapter *padapter = ptdls_sta->padapter;
 	struct tdls_txmgmt txmgmt;
 
diff --git a/ubuntu/rtl8821c/core/rtw_xmit.c b/ubuntu/rtl8821c/core/rtw_xmit.c
index 9a72c7beeb54..9a6d9810f8fc 100644
--- a/ubuntu/rtl8821c/core/rtw_xmit.c
+++ b/ubuntu/rtl8821c/core/rtw_xmit.c
@@ -5384,27 +5384,30 @@  bool rtw_xmit_ac_blocked(_adapter *adapter)
 }
 
 #ifdef CONFIG_TX_AMSDU
-void rtw_amsdu_vo_timeout_handler(void *FunctionContext)
+void rtw_amsdu_vo_timeout_handler(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)FunctionContext;
+	struct xmit_priv *pxmitpriv = from_timer(pxmitpriv, t, amsdu_vo_timer);
+	_adapter *adapter = pxmitpriv->adapter;
 
 	adapter->xmitpriv.amsdu_vo_timeout = RTW_AMSDU_TIMER_TIMEOUT;
 
 	tasklet_hi_schedule(&adapter->xmitpriv.xmit_tasklet);
 }
 
-void rtw_amsdu_vi_timeout_handler(void *FunctionContext)
+void rtw_amsdu_vi_timeout_handler(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)FunctionContext;
+	struct xmit_priv *pxmitpriv = from_timer(pxmitpriv, t, amsdu_vi_timer);
+	_adapter *adapter = pxmitpriv->adapter;
 
 	adapter->xmitpriv.amsdu_vi_timeout = RTW_AMSDU_TIMER_TIMEOUT;
 
 	tasklet_hi_schedule(&adapter->xmitpriv.xmit_tasklet);
 }
 
-void rtw_amsdu_be_timeout_handler(void *FunctionContext)
+void rtw_amsdu_be_timeout_handler(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)FunctionContext;
+	struct xmit_priv *pxmitpriv = from_timer(pxmitpriv, t, amsdu_be_timer);
+	_adapter *adapter = pxmitpriv->adapter;
 
 	adapter->xmitpriv.amsdu_be_timeout = RTW_AMSDU_TIMER_TIMEOUT;
 
@@ -5414,9 +5417,10 @@  void rtw_amsdu_be_timeout_handler(void *FunctionContext)
 	tasklet_hi_schedule(&adapter->xmitpriv.xmit_tasklet);
 }
 
-void rtw_amsdu_bk_timeout_handler(void *FunctionContext)
+void rtw_amsdu_bk_timeout_handler(struct timer_list *t)
 {
-	_adapter *adapter = (_adapter *)FunctionContext;
+	struct xmit_priv *pxmitpriv = from_timer(pxmitpriv, t, amsdu_bk_timer);
+	_adapter *adapter = pxmitpriv->adapter;
 
 	adapter->xmitpriv.amsdu_bk_timeout = RTW_AMSDU_TIMER_TIMEOUT;
 
diff --git a/ubuntu/rtl8821c/hal/hal_btcoex.c b/ubuntu/rtl8821c/hal/hal_btcoex.c
index 2a4f4e31d978..54d2a03e4eae 100644
--- a/ubuntu/rtl8821c/hal/hal_btcoex.c
+++ b/ubuntu/rtl8821c/hal/hal_btcoex.c
@@ -578,7 +578,7 @@  u32 halbtcoutsrc_GetWifiLinkStatus(PBTC_COEXIST pBtCoexist)
 	return retVal;
 }
 
-static void _btmpoper_timer_hdl(void *p)
+static void _btmpoper_timer_hdl(struct timer_list *t)
 {
 	if (GLBtcBtMpRptWait) {
 		GLBtcBtMpRptWait = 0;
diff --git a/ubuntu/rtl8821c/hal/led/hal_pci_led.c b/ubuntu/rtl8821c/hal/led/hal_pci_led.c
index bdfeef787d27..370e97386f80 100644
--- a/ubuntu/rtl8821c/hal/led/hal_pci_led.c
+++ b/ubuntu/rtl8821c/hal/led/hal_pci_led.c
@@ -785,9 +785,9 @@  void BlinkHandler(PLED_PCIE pLed)
  *		Callback function of LED BlinkTimer,
  *		it just schedules to corresponding BlinkWorkItem/led_blink_hdl
  *   */
-void BlinkTimerCallback(void *data)
+void BlinkTimerCallback(struct timer_list *t)
 {
-	PLED_PCIE	 pLed = (PLED_PCIE)data;
+	PLED_PCIE	 pLed = from_timer(pLed, t, BlinkTimer);
 	_adapter		*padapter = pLed->padapter;
 
 	/* RTW_INFO("%s\n", __FUNCTION__); */
diff --git a/ubuntu/rtl8821c/include/hal_com_led.h b/ubuntu/rtl8821c/include/hal_com_led.h
index 01dbb9c54138..e3c2cd97ebf4 100644
--- a/ubuntu/rtl8821c/include/hal_com_led.h
+++ b/ubuntu/rtl8821c/include/hal_com_led.h
@@ -373,7 +373,7 @@  struct led_priv {
 			(adapter)->ledpriv.SwLedOff((adapter), (pLed)); \
 	} while (0)
 
-void BlinkTimerCallback(void *data);
+void BlinkTimerCallback(struct timer_list *t);
 void BlinkWorkItemCallback(_workitem *work);
 
 void ResetLedStatus(PLED_DATA pLed);
diff --git a/ubuntu/rtl8821c/include/osdep_service_linux.h b/ubuntu/rtl8821c/include/osdep_service_linux.h
index 5ec1b71cbdca..e73bed72b3e3 100644
--- a/ubuntu/rtl8821c/include/osdep_service_linux.h
+++ b/ubuntu/rtl8821c/include/osdep_service_linux.h
@@ -288,12 +288,9 @@  __inline static void rtw_list_delete(_list *plist)
 	list_del_init(plist);
 }
 
-__inline static void _init_timer(_timer *ptimer, _nic_hdl nic_hdl, void *pfunc, void *cntx)
+__inline static void _init_timer(_timer *ptimer, _nic_hdl nic_hdl, void (*pfunc)(struct timer_list *), void *cntx)
 {
-	/* setup_timer(ptimer, pfunc,(u32)cntx);	 */
-	ptimer->function = pfunc;
-	ptimer->data = (unsigned long)cntx;
-	init_timer(ptimer);
+	timer_setup(ptimer, pfunc, 0);
 }
 
 __inline static void _set_timer(_timer *ptimer, u32 delay_time)
diff --git a/ubuntu/rtl8821c/include/rtw_ap.h b/ubuntu/rtl8821c/include/rtw_ap.h
index 6245f589e760..3a8589f95cb9 100644
--- a/ubuntu/rtl8821c/include/rtw_ap.h
+++ b/ubuntu/rtl8821c/include/rtw_ap.h
@@ -84,5 +84,5 @@  int rtw_ht_operation_update(_adapter *padapter);
 
 #ifdef CONFIG_SWTIMER_BASED_TXBCN
 void tx_beacon_handlder(struct dvobj_priv *pdvobj);
-void tx_beacon_timer_handlder(void *ctx);
+void tx_beacon_timer_handlder(struct timer_list *t);
 #endif
diff --git a/ubuntu/rtl8821c/include/rtw_mlme.h b/ubuntu/rtl8821c/include/rtw_mlme.h
index c9ebaff8c5c8..a309789719b4 100644
--- a/ubuntu/rtl8821c/include/rtw_mlme.h
+++ b/ubuntu/rtl8821c/include/rtw_mlme.h
@@ -1040,16 +1040,16 @@  extern void rtw_update_registrypriv_dev_network(_adapter *adapter);
 
 extern void rtw_get_encrypt_decrypt_from_registrypriv(_adapter *adapter);
 
-extern void rtw_join_timeout_handler(void *ctx);
-extern void rtw_scan_timeout_handler(void *ctx);
+extern void rtw_join_timeout_handler(struct timer_list *t);
+extern void rtw_scan_timeout_handler(struct timer_list *t);
 
-extern void rtw_dynamic_check_timer_handlder(void *ctx);
+extern void rtw_dynamic_check_timer_handlder(struct timer_list *t);
 extern void rtw_iface_dynamic_check_timer_handlder(_adapter *adapter);
 
 #ifdef CONFIG_SET_SCAN_DENY_TIMER
 bool rtw_is_scan_deny(_adapter *adapter);
 void rtw_clear_scan_deny(_adapter *adapter);
-void rtw_set_scan_deny_timer_hdl(void *ctx);
+void rtw_set_scan_deny_timer_hdl(struct timer_list *t);
 void rtw_set_scan_deny(_adapter *adapter, u32 ms);
 #else
 #define rtw_is_scan_deny(adapter) _FALSE
diff --git a/ubuntu/rtl8821c/include/rtw_mlme_ext.h b/ubuntu/rtl8821c/include/rtw_mlme_ext.h
index 27435732e8ca..5128ba0fbe2f 100644
--- a/ubuntu/rtl8821c/include/rtw_mlme_ext.h
+++ b/ubuntu/rtl8821c/include/rtw_mlme_ext.h
@@ -1047,11 +1047,11 @@  void linked_status_chk(_adapter *padapter, u8 from_timer);
 
 void _linked_info_dump(_adapter *padapter);
 
-void survey_timer_hdl(void *ctx);
-void link_timer_hdl(void *ctx);
-void addba_timer_hdl(void *ctx);
+void survey_timer_hdl(struct timer_list *t);
+void link_timer_hdl(struct timer_list *t);
+void addba_timer_hdl(struct timer_list *t);
 #ifdef CONFIG_IEEE80211W
-void sa_query_timer_hdl(void *ctx);
+void sa_query_timer_hdl(struct timer_list *t);
 #endif /* CONFIG_IEEE80211W */
 #if 0
 void reauth_timer_hdl(_adapter *padapter);
diff --git a/ubuntu/rtl8821c/include/rtw_pwrctrl.h b/ubuntu/rtl8821c/include/rtw_pwrctrl.h
index 2dbb83901a9b..f6c900018a5c 100644
--- a/ubuntu/rtl8821c/include/rtw_pwrctrl.h
+++ b/ubuntu/rtl8821c/include/rtw_pwrctrl.h
@@ -455,6 +455,7 @@  struct pwrctrl_priv {
 	u8 blpspg_info_up;
 #endif
 	u8 current_lps_hw_port_id;
+	_adapter *adapter;
 };
 
 #define rtw_get_ips_mode_req(pwrctl) \
diff --git a/ubuntu/rtl8821c/include/rtw_recv.h b/ubuntu/rtl8821c/include/rtw_recv.h
index 97a90b4d7b4d..7b5d65a36716 100644
--- a/ubuntu/rtl8821c/include/rtw_recv.h
+++ b/ubuntu/rtl8821c/include/rtw_recv.h
@@ -668,7 +668,7 @@  sint rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, _queue *queue);
 sint rtw_enqueue_recvbuf(struct recv_buf *precvbuf, _queue *queue);
 struct recv_buf *rtw_dequeue_recvbuf(_queue *queue);
 
-void rtw_reordering_ctrl_timeout_handler(void *pcontext);
+void rtw_reordering_ctrl_timeout_handler(struct timer_list *t);
 
 void rx_query_phy_status(union recv_frame *rframe, u8 *phy_stat);
 int rtw_inc_and_chk_continual_no_rx_packet(struct sta_info *sta, int tid_index);