From e922df7d3e946529981860d4bdd707a9cb59fc0d Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Tue, 3 Mar 2015 22:34:22 +0530 Subject: [PATCH] Staging: rtl8712: Eliminate use of _init_timer 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/mlme_linux.c | 48 +++++++++++----------- drivers/staging/rtl8712/os_intfs.c | 4 +- drivers/staging/rtl8712/osdep_service.h | 9 ---- drivers/staging/rtl8712/recv_linux.c | 11 +++-- drivers/staging/rtl8712/rtl8712_led.c | 3 +- drivers/staging/rtl8712/rtl871x_pwrctrl.c | 8 ++-- drivers/staging/rtl8712/rtl871x_security.c | 4 +- drivers/staging/rtl8712/rtl871x_security.h | 2 +- 8 files changed, 40 insertions(+), 49 deletions(-) diff --git a/drivers/staging/rtl8712/mlme_linux.c b/drivers/staging/rtl8712/mlme_linux.c index 53999e8aa1c1..8c5a475f05e7 100644 --- a/drivers/staging/rtl8712/mlme_linux.c +++ b/drivers/staging/rtl8712/mlme_linux.c @@ -32,39 +32,39 @@ #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], diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index 64cdceead13b..ebfb29ed779a 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -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); diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index 54c4c470cd8e..c6dc3629f4d2 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -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); diff --git a/drivers/staging/rtl8712/recv_linux.c b/drivers/staging/rtl8712/recv_linux.c index 3640dd48febe..799a0f9a5b2d 100644 --- a/drivers/staging/rtl8712/recv_linux.c +++ b/drivers/staging/rtl8712/recv_linux.c @@ -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); } diff --git a/drivers/staging/rtl8712/rtl8712_led.c b/drivers/staging/rtl8712/rtl8712_led.c index 0c7dfeebc62e..6085689f0976 100644 --- a/drivers/staging/rtl8712/rtl8712_led.c +++ b/drivers/staging/rtl8712/rtl8712_led.c @@ -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); } diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.c b/drivers/staging/rtl8712/rtl871x_pwrctrl.c index ed2844d2b02a..ea732ee99bbe 100644 --- a/drivers/staging/rtl8712/rtl871x_pwrctrl.c +++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.c @@ -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); } /* diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c index 743dd93688b5..4d5a2889b775 100644 --- a/drivers/staging/rtl8712/rtl871x_security.c +++ b/drivers/staging/rtl8712/rtl871x_security.c @@ -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; } diff --git a/drivers/staging/rtl8712/rtl871x_security.h b/drivers/staging/rtl8712/rtl871x_security.h index c732aeab8d2c..2295f0e64dc2 100644 --- a/drivers/staging/rtl8712/rtl871x_security.h +++ b/drivers/staging/rtl8712/rtl871x_security.h @@ -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_ */