staging: rtl8723bs: Convert timers to use timer_setup()
authorKees Cook <keescook@chromium.org>
Tue, 24 Oct 2017 08:27:23 +0000 (01:27 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Nov 2017 13:49:08 +0000 (14:49 +0100)
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@linuxfoundation.org>
Cc: Shreeya Patel <shreeya.patel23498@gmail.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Himanshu Jha <himanshujha199640@gmail.com>
Cc: Joe Perches <joe@perches.com>
Cc: Derek Robson <robsonde@gmail.com>
Cc: Harsha Sharma <harshasharmaiitr@gmail.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
Cc: Johannes Berg <johannes.berg@intel.com>
Cc: devel@driverdev.osuosl.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
13 files changed:
drivers/staging/rtl8723bs/core/rtw_mlme.c
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
drivers/staging/rtl8723bs/core/rtw_recv.c
drivers/staging/rtl8723bs/include/osdep_service.h
drivers/staging/rtl8723bs/include/osdep_service_linux.h
drivers/staging/rtl8723bs/include/rtw_mlme.h
drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
drivers/staging/rtl8723bs/include/rtw_recv.h
drivers/staging/rtl8723bs/os_dep/mlme_linux.c
drivers/staging/rtl8723bs/os_dep/osdep_service.c
drivers/staging/rtl8723bs/os_dep/recv_linux.c

index f9247a0a15390b642ce3fd4faca6d749d19d6e4f..fe739eb2cf7d0e5baebb58b1f58c75c787c258c8 100644 (file)
@@ -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 @@ exit:
        return;
 }
 
-void rtw_dynamic_check_timer_handlder(struct adapter *adapter)
+void rtw_dynamic_check_timer_handler(struct adapter *adapter)
 {
        if (!adapter)
                return;
index 4805115244371930a1b1824dd290744977290a4b..7d7756e40bcb676f1a5c54524097057574360f5d 100644 (file)
@@ -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 @@ exit_survey_timer_hdl:
        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);
index a3ba5518ecc6b14d951abf75147afc50b38306fc..4a6af72013faad5c6fa3a1f99b88e300af8444f9 100644 (file)
@@ -201,10 +201,12 @@ exit:
        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 @@ exit:
 /*
  * 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;
index 8817902b02c76cc12174a1027c6fba53fd27ed3d..9c7c3be0553a1e209b3043cbfc60a42ef5d19c98 100644 (file)
@@ -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 @@ _err_exit:
 }
 
 
-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 @@ _recv_entry_drop:
        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;
index 57523baa4517c704fba3283e92d7992ed9311b41..e62ed71e1d80c523d71179f58f8f32f6833a3a72 100644 (file)
@@ -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);
index 09b1e310324457b429ae22b61df9efc83930bfe4..711863d74a010ef27f0706f0474ac3cc4c2a5ce0 100644 (file)
@@ -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);
index d88ef67ce8d65c4f78cd2cc1595d263ee7a21494..00b3d92c9f513203ad74f98d8862a143a589aa83 100644 (file)
@@ -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);
index 0d22aaf4865a1126b5ce0115f3e5c80b163b2cf8..6613dea2b283c5ea2e9cd4be6a9349bf0b6d04d1 100644 (file)
@@ -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); */
 
index 79a2db692d27cf50a35a1ba9de51121d87b1b1dc..faf91022f54a32adef42d7495dc346158751c368 100644 (file)
@@ -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;
 
index 570a3c333aa09302f2c812acdde04d51dbaa6e89..71039ca79e4bfd14f674c8521fdd4b79950d3cb4 100644 (file)
@@ -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)
 {
index 49cb701fa6ce2cb89e516452b92941eb0db112f0..a4ef5789d794a31214a1a9d469972f93778d68cb 100644 (file)
 #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);
 }
index 9255cf73bdadf0b9089eb1083022f09d553fcaff..f4221952dd1b7e12bc812a2e9041aab8ec99ccfe 100644 (file)
@@ -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));
index f42e00081e0e9724937f6db9eae947479b9d7d25..e804b430931ce364c3728ea84f59fc17e86d85af 100644 (file)
@@ -356,8 +356,7 @@ _recv_indicatepkt_drop:
 
 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);
 
 }