In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. This performs some refactoring to remove needless wrapper functions, and adds a pointer back to the desired adapter. Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Shreeya Patel <shreeya.patel23498@xxxxxxxxx> Cc: Hans de Goede <hdegoede@xxxxxxxxxx> Cc: Larry Finger <Larry.Finger@xxxxxxxxxxxx> Cc: Himanshu Jha <himanshujha199640@xxxxxxxxx> Cc: Joe Perches <joe@xxxxxxxxxxx> Cc: Derek Robson <robsonde@xxxxxxxxx> Cc: Harsha Sharma <harshasharmaiitr@xxxxxxxxx> Cc: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx> Cc: Stephen Hemminger <stephen@xxxxxxxxxxxxxxxxxx> Cc: yuan linyu <Linyu.Yuan@xxxxxxxxxxxxxxxxxxxx> Cc: Johannes Berg <johannes.berg@xxxxxxxxx> Cc: devel@xxxxxxxxxxxxxxxxxxxx Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx> --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 10 +++++-- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 15 +++++++--- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 23 +++++++-------- drivers/staging/rtl8723bs/core/rtw_recv.c | 15 ++++++---- drivers/staging/rtl8723bs/include/osdep_service.h | 2 -- .../rtl8723bs/include/osdep_service_linux.h | 11 ------- drivers/staging/rtl8723bs/include/rtw_mlme.h | 10 +++---- drivers/staging/rtl8723bs/include/rtw_mlme_ext.h | 8 ++--- drivers/staging/rtl8723bs/include/rtw_pwrctrl.h | 1 + drivers/staging/rtl8723bs/include/rtw_recv.h | 2 +- drivers/staging/rtl8723bs/os_dep/mlme_linux.c | 34 ++++++++++++---------- drivers/staging/rtl8723bs/os_dep/osdep_service.c | 7 ----- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 5 ++-- 13 files changed, 69 insertions(+), 74 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index f9247a0a1539..fe739eb2cf7d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -1814,8 +1814,10 @@ void rtw_wmm_event_callback(struct adapter *padapter, u8 *pbuf) * _rtw_join_timeout_handler - Timeout/failure handler for CMD JoinBss * @adapter: pointer to struct adapter structure */ -void _rtw_join_timeout_handler (struct adapter *adapter) +void _rtw_join_timeout_handler(struct timer_list *t) { + struct adapter *adapter = from_timer(adapter, t, + mlmepriv.assoc_timer); struct mlme_priv *pmlmepriv = &adapter->mlmepriv; DBG_871X("%s, fw_state =%x\n", __func__, get_fwstate(pmlmepriv)); @@ -1867,8 +1869,10 @@ void _rtw_join_timeout_handler (struct adapter *adapter) * rtw_scan_timeout_handler - Timeout/Failure handler for CMD SiteSurvey * @adapter: pointer to struct adapter structure */ -void rtw_scan_timeout_handler (struct adapter *adapter) +void rtw_scan_timeout_handler(struct timer_list *t) { + struct adapter *adapter = from_timer(adapter, t, + mlmepriv.scan_to_timer); struct mlme_priv *pmlmepriv = &adapter->mlmepriv; DBG_871X(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv)); @@ -1931,7 +1935,7 @@ static void rtw_auto_scan_handler(struct adapter *padapter) return; } -void rtw_dynamic_check_timer_handlder(struct adapter *adapter) +void rtw_dynamic_check_timer_handler(struct adapter *adapter) { if (!adapter) return; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 480511524437..7d7756e40bcb 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -5830,8 +5830,10 @@ void linked_status_chk(struct adapter *padapter) } -void survey_timer_hdl(struct adapter *padapter) +void survey_timer_hdl(struct timer_list *t) { + struct adapter *padapter = + from_timer(padapter, t, mlmeextpriv.survey_timer); struct cmd_obj *ph2c; struct sitesurvey_parm *psurveyPara; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; @@ -5877,8 +5879,10 @@ void survey_timer_hdl(struct adapter *padapter) return; } -void link_timer_hdl(struct adapter *padapter) +void link_timer_hdl(struct timer_list *t) { + struct 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); */ @@ -5927,8 +5931,9 @@ void link_timer_hdl(struct adapter *padapter) return; } -void addba_timer_hdl(struct sta_info *psta) +void addba_timer_hdl(struct timer_list *t) { + struct sta_info *psta = from_timer(psta, t, addba_retry_timer); struct ht_priv *phtpriv; if (!psta) @@ -5943,8 +5948,10 @@ void addba_timer_hdl(struct sta_info *psta) } } -void sa_query_timer_hdl(struct adapter *padapter) +void sa_query_timer_hdl(struct timer_list *t) { + struct adapter *padapter = + from_timer(padapter, t, mlmeextpriv.sa_query_timer); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; /* disconnect */ spin_lock_bh(&pmlmepriv->lock); diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index a3ba5518ecc6..4a6af72013fa 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -201,10 +201,12 @@ void rtw_ps_processor(struct adapter *padapter) return; } -void pwr_state_check_handler(RTW_TIMER_HDL_ARGS); -void pwr_state_check_handler(RTW_TIMER_HDL_ARGS) +static void pwr_state_check_handler(struct timer_list *t) { - struct adapter *padapter = (struct adapter *)FunctionContext; + struct pwrctrl_priv *pwrctrlpriv = + from_timer(pwrctrlpriv, t, pwr_state_check_timer); + struct adapter *padapter = pwrctrlpriv->adapter; + rtw_ps_cmd(padapter); } @@ -823,14 +825,10 @@ 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) { - struct adapter *padapter; - struct pwrctrl_priv *pwrpriv; + struct pwrctrl_priv *pwrpriv = from_timer(pwrpriv, t, pwr_rpwm_timer); - - padapter = FunctionContext; - pwrpriv = adapter_to_pwrctl(padapter); DBG_871X("+%s: rpwm = 0x%02X cpwm = 0x%02X\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) { @@ -1173,10 +1171,11 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) _init_workitem(&pwrctrlpriv->cpwm_event, cpwm_event_callback, NULL); pwrctrlpriv->brpwmtimeout = false; + pwrctrlpriv->adapter = padapter; _init_workitem(&pwrctrlpriv->rpwmtimeoutwi, rpwmtimeout_workitem_callback, NULL); - _init_timer(&pwrctrlpriv->pwr_rpwm_timer, padapter->pnetdev, pwr_rpwm_timeout_handler, padapter); - - rtw_init_timer(&pwrctrlpriv->pwr_state_check_timer, padapter, pwr_state_check_handler); + timer_setup(&pwrctrlpriv->pwr_rpwm_timer, pwr_rpwm_timeout_handler, 0); + timer_setup(&pwrctrlpriv->pwr_state_check_timer, + pwr_state_check_handler, 0); pwrctrlpriv->wowlan_mode = false; pwrctrlpriv->wowlan_ap_mode = false; diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 8817902b02c7..9c7c3be0553a 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -26,7 +26,7 @@ u8 rtw_rfc1042_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ u8 rtw_bridge_tunnel_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; -void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS); +static void rtw_signal_stat_timer_hdl(struct timer_list *t); void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) { @@ -86,7 +86,8 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) res = rtw_hal_init_recv_priv(padapter); - rtw_init_timer(&precvpriv->signal_stat_timer, padapter, rtw_signal_stat_timer_hdl); + timer_setup(&precvpriv->signal_stat_timer, rtw_signal_stat_timer_hdl, + 0); precvpriv->signal_stat_sampling_interval = 2000; /* ms */ @@ -2354,9 +2355,10 @@ int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe } -void rtw_reordering_ctrl_timeout_handler(void *pcontext) +void rtw_reordering_ctrl_timeout_handler(struct timer_list *t) { - struct recv_reorder_ctrl *preorder_ctrl = pcontext; + struct recv_reorder_ctrl *preorder_ctrl = + from_timer(preorder_ctrl, t, reordering_ctrl_timer); struct adapter *padapter = preorder_ctrl->padapter; struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; @@ -2597,9 +2599,10 @@ s32 rtw_recv_entry(union recv_frame *precvframe) return ret; } -void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS) +static void rtw_signal_stat_timer_hdl(struct timer_list *t) { - struct adapter *adapter = (struct adapter *)FunctionContext; + struct adapter *adapter = + from_timer(adapter, t, recvpriv.signal_stat_timer); struct recv_priv *recvpriv = &adapter->recvpriv; u32 tmp_s, tmp_q; diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h index 57523baa4517..e62ed71e1d80 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service.h +++ b/drivers/staging/rtl8723bs/include/osdep_service.h @@ -118,8 +118,6 @@ int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb); extern void _rtw_init_queue(struct __queue *pqueue); -extern void rtw_init_timer(_timer *ptimer, void *padapter, void *pfunc); - static __inline void thread_enter(char *name) { allow_signal(SIGTERM); diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h b/drivers/staging/rtl8723bs/include/osdep_service_linux.h index 09b1e3103244..711863d74a01 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h +++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h @@ -88,16 +88,6 @@ __inline static struct list_head *get_list_head(struct __queue *queue) #define LIST_CONTAINOR(ptr, type, member) \ container_of(ptr, type, member) -#define RTW_TIMER_HDL_ARGS void *FunctionContext - -__inline static void _init_timer(_timer *ptimer, _nic_hdl nic_hdl, void *pfunc, void* cntx) -{ - /* setup_timer(ptimer, pfunc, (u32)cntx); */ - ptimer->function = pfunc; - ptimer->data = (unsigned long)cntx; - init_timer(ptimer); -} - __inline static void _set_timer(_timer *ptimer, u32 delay_time) { mod_timer(ptimer , (jiffies+(delay_time*HZ/1000))); @@ -109,7 +99,6 @@ __inline static void _cancel_timer(_timer *ptimer, u8 *bcancelled) *bcancelled = true;/* true == 1; false == 0 */ } - __inline static void _init_workitem(_workitem *pwork, void *pfunc, void *cntx) { INIT_WORK(pwork, pfunc); diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h b/drivers/staging/rtl8723bs/include/rtw_mlme.h index d88ef67ce8d6..00b3d92c9f51 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h @@ -518,8 +518,8 @@ extern void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf); extern void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf); extern void rtw_wmm_event_callback(struct adapter *padapter, u8 *pbuf); -extern void rtw_join_timeout_handler(RTW_TIMER_HDL_ARGS); -extern void _rtw_scan_timeout_handler(RTW_TIMER_HDL_ARGS); +extern void rtw_join_timeout_handler(struct timer_list *t); +extern void _rtw_scan_timeout_handler(struct timer_list *t); int event_thread(void *context); @@ -618,10 +618,10 @@ extern void rtw_update_registrypriv_dev_network(struct adapter *adapter); extern void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter); -extern void _rtw_join_timeout_handler(struct adapter *adapter); -extern void rtw_scan_timeout_handler(struct adapter *adapter); +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(struct adapter *adapter); +extern void rtw_dynamic_check_timer_handler(struct adapter *adapter); bool rtw_is_scan_deny(struct adapter *adapter); void rtw_clear_scan_deny(struct adapter *adapter); void rtw_set_scan_deny_timer_hdl(struct adapter *adapter); diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h index 0d22aaf4865a..6613dea2b283 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h @@ -719,10 +719,10 @@ void linked_status_chk(struct adapter *padapter); void _linked_info_dump(struct adapter *padapter); -void survey_timer_hdl (struct adapter *padapter); -void link_timer_hdl (struct adapter *padapter); -void addba_timer_hdl(struct sta_info *psta); -void sa_query_timer_hdl(struct adapter *padapter); +void survey_timer_hdl (struct timer_list *t); +void link_timer_hdl (struct timer_list *t); +void addba_timer_hdl(struct timer_list *t); +void sa_query_timer_hdl(struct timer_list *t); /* void reauth_timer_hdl(struct adapter *padapter); */ /* void reassoc_timer_hdl(struct adapter *padapter); */ diff --git a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h index 79a2db692d27..faf91022f54a 100644 --- a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h @@ -300,6 +300,7 @@ struct pwrctrl_priv u64 wowlan_fw_iv; #endif /* CONFIG_WOWLAN */ _timer pwr_state_check_timer; + struct adapter *adapter; int pwr_state_check_interval; u8 pwr_state_check_cnts; diff --git a/drivers/staging/rtl8723bs/include/rtw_recv.h b/drivers/staging/rtl8723bs/include/rtw_recv.h index 570a3c333aa0..71039ca79e4b 100644 --- a/drivers/staging/rtl8723bs/include/rtw_recv.h +++ b/drivers/staging/rtl8723bs/include/rtw_recv.h @@ -411,7 +411,7 @@ sint rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queu sint rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue); struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue); -void rtw_reordering_ctrl_timeout_handler(void *pcontext); +void rtw_reordering_ctrl_timeout_handler(struct timer_list *t); __inline static u8 *get_rxmem(union recv_frame *precvframe) { diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c index 49cb701fa6ce..a4ef5789d794 100644 --- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c @@ -19,18 +19,21 @@ #include <drv_types.h> #include <rtw_debug.h> -static void _dynamic_check_timer_handlder(void *FunctionContext) +static void _dynamic_check_timer_handler(struct timer_list *t) { - struct adapter *adapter = FunctionContext; + struct adapter *adapter = + from_timer(adapter, t, mlmepriv.dynamic_chk_timer); - rtw_dynamic_check_timer_handlder(adapter); + rtw_dynamic_check_timer_handler(adapter); _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000); } -static void _rtw_set_scan_deny_timer_hdl(void *FunctionContext) +static void _rtw_set_scan_deny_timer_hdl(struct timer_list *t) { - struct adapter *adapter = FunctionContext; + struct adapter *adapter = + from_timer(adapter, t, mlmepriv.set_scan_deny_timer); + rtw_set_scan_deny_timer_hdl(adapter); } @@ -38,13 +41,12 @@ void rtw_init_mlme_timer(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev, _rtw_join_timeout_handler, padapter); - /* _init_timer(&(pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer), padapter->pnetdev, sitesurvey_ctrl_handler, padapter); */ - _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev, rtw_scan_timeout_handler, padapter); - - _init_timer(&(pmlmepriv->dynamic_chk_timer), padapter->pnetdev, _dynamic_check_timer_handlder, padapter); - - _init_timer(&(pmlmepriv->set_scan_deny_timer), padapter->pnetdev, _rtw_set_scan_deny_timer_hdl, padapter); + timer_setup(&pmlmepriv->assoc_timer, _rtw_join_timeout_handler, 0); + timer_setup(&pmlmepriv->scan_to_timer, rtw_scan_timeout_handler, 0); + timer_setup(&pmlmepriv->dynamic_chk_timer, + _dynamic_check_timer_handler, 0); + timer_setup(&pmlmepriv->set_scan_deny_timer, + _rtw_set_scan_deny_timer_hdl, 0); } void rtw_os_indicate_connect(struct adapter *adapter) @@ -191,14 +193,14 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta) { - _init_timer(&psta->addba_retry_timer, padapter->pnetdev, addba_timer_hdl, psta); + timer_setup(&psta->addba_retry_timer, addba_timer_hdl, 0); } void init_mlme_ext_timer(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - _init_timer(&pmlmeext->survey_timer, padapter->pnetdev, survey_timer_hdl, padapter); - _init_timer(&pmlmeext->link_timer, padapter->pnetdev, link_timer_hdl, padapter); - _init_timer(&pmlmeext->sa_query_timer, padapter->pnetdev, sa_query_timer_hdl, padapter); + timer_setup(&pmlmeext->survey_timer, survey_timer_hdl, 0); + timer_setup(&pmlmeext->link_timer, link_timer_hdl, 0); + timer_setup(&pmlmeext->sa_query_timer, sa_query_timer_hdl, 0); } diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index 9255cf73bdad..f4221952dd1b 100644 --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c @@ -66,13 +66,6 @@ inline int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb) return netif_rx(skb); } -void rtw_init_timer(_timer *ptimer, void *padapter, void *pfunc) -{ - struct adapter *adapter = padapter; - - _init_timer(ptimer, adapter->pnetdev, pfunc, adapter); -} - void _rtw_init_queue(struct __queue *pqueue) { INIT_LIST_HEAD(&(pqueue->queue)); diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c index f42e00081e0e..e804b430931c 100644 --- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c @@ -356,8 +356,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, union recv_frame *precv_frame void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) { - struct adapter *padapter = preorder_ctrl->padapter; - - _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, rtw_reordering_ctrl_timeout_handler, preorder_ctrl); + timer_setup(&preorder_ctrl->reordering_ctrl_timer, + rtw_reordering_ctrl_timeout_handler, 0); } -- 2.7.4 -- Kees Cook Pixel Security _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel