Staging: rtl8712: Eliminate use of _init_timer
authorVaishali Thakkar <vthakkar1994@gmail.com>
Tue, 3 Mar 2015 17:04:22 +0000 (22:34 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Mar 2015 17:54:34 +0000 (09:54 -0800)
This patch introduces the use of API function setup_timer
instead of driver specific function _init_timer as it is
the preferred and standard way to setup and set the timer.
To be compatible with the change, argument types of
referenced functions are changed. Also, definition of
function _init_timer is removed as it is no longer needed
after this change.

This is done using Coccinelle and semantic patch used for
this is as follows:

@@ expression x, y; identifier a, b;@@

- _init_timer (&x, y, a, b);
+ setup_timer (&x, a, (unsigned long)b);

Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8712/mlme_linux.c
drivers/staging/rtl8712/os_intfs.c
drivers/staging/rtl8712/osdep_service.h
drivers/staging/rtl8712/recv_linux.c
drivers/staging/rtl8712/rtl8712_led.c
drivers/staging/rtl8712/rtl871x_pwrctrl.c
drivers/staging/rtl8712/rtl871x_security.c
drivers/staging/rtl8712/rtl871x_security.h

index 53999e8aa1c1d07a17cdd06dc7e2fc6cb77b83a4..8c5a475f05e7a546598071a84be324182af273c2 100644 (file)
 #include "drv_types.h"
 #include "mlme_osdep.h"
 
-static void sitesurvey_ctrl_handler(void *FunctionContext)
+static void sitesurvey_ctrl_handler(unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        _r8712_sitesurvey_ctrl_handler(adapter);
        mod_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
                  jiffies + msecs_to_jiffies(3000));
 }
 
-static void join_timeout_handler (void *FunctionContext)
+static void join_timeout_handler (unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        _r8712_join_timeout_handler(adapter);
 }
 
-static void _scan_timeout_handler (void *FunctionContext)
+static void _scan_timeout_handler (unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        r8712_scan_timeout_handler(adapter);
 }
 
-static void dhcp_timeout_handler (void *FunctionContext)
+static void dhcp_timeout_handler (unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        _r8712_dhcp_timeout_handler(adapter);
 }
 
-static void wdg_timeout_handler (void *FunctionContext)
+static void wdg_timeout_handler (unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        _r8712_wdg_timeout_handler(adapter);
 
@@ -76,17 +76,17 @@ void r8712_init_mlme_timer(struct _adapter *padapter)
 {
        struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
-       _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev,
-                   join_timeout_handler, (pmlmepriv->nic_hdl));
-       _init_timer(&(pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer),
-                   padapter->pnetdev, sitesurvey_ctrl_handler,
-                   (u8 *)(pmlmepriv->nic_hdl));
-       _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev,
-                   _scan_timeout_handler, (pmlmepriv->nic_hdl));
-       _init_timer(&(pmlmepriv->dhcp_timer), padapter->pnetdev,
-                   dhcp_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
-       _init_timer(&(pmlmepriv->wdg_timer), padapter->pnetdev,
-                   wdg_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
+       setup_timer(&pmlmepriv->assoc_timer, join_timeout_handler,
+                   (unsigned long)padapter);
+       setup_timer(&pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer,
+                   sitesurvey_ctrl_handler,
+                   (unsigned long)padapter);
+       setup_timer(&pmlmepriv->scan_to_timer, _scan_timeout_handler,
+                   (unsigned long)padapter);
+       setup_timer(&pmlmepriv->dhcp_timer, dhcp_timeout_handler,
+                   (unsigned long)padapter);
+       setup_timer(&pmlmepriv->wdg_timer, wdg_timeout_handler,
+                   (unsigned long)padapter);
 }
 
 void r8712_os_indicate_connect(struct _adapter *adapter)
@@ -118,9 +118,9 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter)
                                           btkip_countermeasure;
                memset((unsigned char *)&adapter->securitypriv, 0,
                         sizeof(struct security_priv));
-               _init_timer(&(adapter->securitypriv.tkip_timer),
-                           adapter->pnetdev, r8712_use_tkipkey_handler,
-                           adapter);
+               setup_timer(&adapter->securitypriv.tkip_timer,
+                           r8712_use_tkipkey_handler,
+                           (unsigned long)adapter);
                /* Restore the PMK information to securitypriv structure
                 * for the following connection. */
                memcpy(&adapter->securitypriv.PMKIDList[0],
index 64cdceead13b8ef537e85fb2e0bf8d41ce3a13ed..ebfb29ed779ae8b57e9dc5332e91a0c7824da046 100644 (file)
@@ -323,8 +323,8 @@ u8 r8712_init_drv_sw(struct _adapter *padapter)
        _r8712_init_recv_priv(&padapter->recvpriv, padapter);
        memset((unsigned char *)&padapter->securitypriv, 0,
               sizeof(struct security_priv));
-       _init_timer(&(padapter->securitypriv.tkip_timer), padapter->pnetdev,
-                   r8712_use_tkipkey_handler, padapter);
+       setup_timer(&padapter->securitypriv.tkip_timer,
+                   r8712_use_tkipkey_handler, (unsigned long)padapter);
        _r8712_init_sta_priv(&padapter->stapriv);
        padapter->stapriv.padapter = padapter;
        r8712_init_bcmc_stainfo(padapter);
index 54c4c470cd8efbf7a774efa27260f6ad14820fd0..c6dc3629f4d2fdafd0bf08f668ac7a26fd967f23 100644 (file)
@@ -60,15 +60,6 @@ struct       __queue {
 #define LIST_CONTAINOR(ptr, type, member) \
        ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
 
-static inline void _init_timer(struct timer_list *ptimer,
-                              struct  net_device *padapter,
-                              void *pfunc, void *cntx)
-{
-       ptimer->function = pfunc;
-       ptimer->data = (addr_t)cntx;
-       init_timer(ptimer);
-}
-
 static inline void _cancel_timer(struct timer_list *ptimer, u8 *bcancelled)
 {
        del_timer(ptimer);
index 3640dd48febec3c49eda78dd9e8191aa9cfb6b6b..799a0f9a5b2d27a089bfc5a87f3d0bbb99229ddd 100644 (file)
@@ -137,18 +137,17 @@ _recv_indicatepkt_drop:
         precvpriv->rx_drop++;
 }
 
-static void _r8712_reordering_ctrl_timeout_handler (void *FunctionContext)
+static void _r8712_reordering_ctrl_timeout_handler (unsigned long data)
 {
        struct recv_reorder_ctrl *preorder_ctrl =
-                        (struct recv_reorder_ctrl *)FunctionContext;
+                        (struct recv_reorder_ctrl *)data;
 
        r8712_reordering_ctrl_timeout_handler(preorder_ctrl);
 }
 
 void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
 {
-       struct _adapter *padapter = preorder_ctrl->padapter;
-
-       _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev,
-                   _r8712_reordering_ctrl_timeout_handler, preorder_ctrl);
+       setup_timer(&preorder_ctrl->reordering_ctrl_timer,
+                    _r8712_reordering_ctrl_timeout_handler,
+                    (unsigned long)preorder_ctrl);
 }
index 0c7dfeebc62e4c9e41ee2a03664147db52e4a84b..6085689f09764abd60f028a310a1618f19dee97c 100644 (file)
@@ -97,7 +97,8 @@ static void InitLed871x(struct _adapter *padapter, struct LED_871x *pLed,
        pLed->bLedBlinkInProgress = false;
        pLed->BlinkTimes = 0;
        pLed->BlinkingLedState = LED_UNKNOWN;
-       _init_timer(&(pLed->BlinkTimer), nic, BlinkTimerCallback, pLed);
+       setup_timer(&pLed->BlinkTimer, BlinkTimerCallback,
+                   (unsigned long)pLed);
        INIT_WORK(&pLed->BlinkWorkItem, BlinkWorkItemCallback);
 }
 
index ed2844d2b02abcf3345bfba74e72dc98865d1410..ea732ee99bbec7af28c427ffb0aa0b3570a34fdb 100644 (file)
@@ -165,9 +165,9 @@ static void rpwm_workitem_callback(struct work_struct *work)
        }
 }
 
-static void rpwm_check_handler (void *FunctionContext)
+static void rpwm_check_handler (unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        _rpwm_check_handler(adapter);
 }
@@ -186,8 +186,8 @@ void r8712_init_pwrctrl_priv(struct _adapter *padapter)
        r8712_write8(padapter, 0x1025FE58, 0);
        INIT_WORK(&pwrctrlpriv->SetPSModeWorkItem, SetPSModeWorkItemCallback);
        INIT_WORK(&pwrctrlpriv->rpwm_workitem, rpwm_workitem_callback);
-       _init_timer(&(pwrctrlpriv->rpwm_check_timer),
-                   padapter->pnetdev, rpwm_check_handler, (u8 *)padapter);
+       setup_timer(&pwrctrlpriv->rpwm_check_timer, rpwm_check_handler,
+                   (unsigned long)padapter);
 }
 
 /*
index 743dd93688b5f3a145c269844486b5dcd44ffd67..4d5a2889b7757e469adf1fadd199c3cbd3c56634 100644 (file)
@@ -1392,9 +1392,9 @@ u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe)
        return _SUCCESS;
 }
 
-void r8712_use_tkipkey_handler(void *FunctionContext)
+void r8712_use_tkipkey_handler(unsigned long data)
 {
-       struct _adapter *padapter = (struct _adapter *)FunctionContext;
+       struct _adapter *padapter = (struct _adapter *)data;
 
        padapter->securitypriv.busetkipkey = true;
 }
index c732aeab8d2c67049900abce4fb48c150bb5605a..2295f0e64dc2c7d0ef867903324caf6cf379db65 100644 (file)
@@ -216,7 +216,7 @@ void r8712_wep_encrypt(struct _adapter *padapter, u8  *pxmitframe);
 u32 r8712_aes_decrypt(struct _adapter *padapter, u8  *precvframe);
 u32 r8712_tkip_decrypt(struct _adapter *padapter, u8  *precvframe);
 void r8712_wep_decrypt(struct _adapter *padapter, u8  *precvframe);
-void r8712_use_tkipkey_handler(void *FunctionContext);
+void r8712_use_tkipkey_handler(unsigned long data);
 
 #endif /*__RTL871X_SECURITY_H_ */