Commit c703c750 authored by Vaishali Thakkar's avatar Vaishali Thakkar Committed by Greg Kroah-Hartman

Staging: rtl8712: Eliminate use of _set_timer

This patch introduces the use of API function mod_timer
instead of driver specific function _set_timer as it is
a more efficient and standard way to update the expire
field of an active timer. Also, definition of function
_set_timer is removed as it is no longer needed after
this change.

Here, these cases are handled using Coccinelle and
semantic patch used for this is as follows:

@@ expression x; expression y;@@

- _set_timer (&x, y);
+ mod_timer (&x, jiffies + msecs_to_jiffies (y));
Signed-off-by: default avatarVaishali Thakkar <vthakkar1994@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1862eec4
...@@ -37,8 +37,8 @@ static void sitesurvey_ctrl_handler(void *FunctionContext) ...@@ -37,8 +37,8 @@ static void sitesurvey_ctrl_handler(void *FunctionContext)
struct _adapter *adapter = (struct _adapter *)FunctionContext; struct _adapter *adapter = (struct _adapter *)FunctionContext;
_r8712_sitesurvey_ctrl_handler(adapter); _r8712_sitesurvey_ctrl_handler(adapter);
_set_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer, mod_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
3000); jiffies + msecs_to_jiffies(3000));
} }
static void join_timeout_handler (void *FunctionContext) static void join_timeout_handler (void *FunctionContext)
...@@ -68,7 +68,8 @@ static void wdg_timeout_handler (void *FunctionContext) ...@@ -68,7 +68,8 @@ static void wdg_timeout_handler (void *FunctionContext)
_r8712_wdg_timeout_handler(adapter); _r8712_wdg_timeout_handler(adapter);
_set_timer(&adapter->mlmepriv.wdg_timer, 2000); mod_timer(&adapter->mlmepriv.wdg_timer,
jiffies + msecs_to_jiffies(2000));
} }
void r8712_init_mlme_timer(struct _adapter *padapter) void r8712_init_mlme_timer(struct _adapter *padapter)
......
...@@ -255,9 +255,10 @@ void r8712_stop_drv_threads(struct _adapter *padapter) ...@@ -255,9 +255,10 @@ void r8712_stop_drv_threads(struct _adapter *padapter)
static void start_drv_timers(struct _adapter *padapter) static void start_drv_timers(struct _adapter *padapter)
{ {
_set_timer(&padapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer, mod_timer(&padapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
5000); jiffies + msecs_to_jiffies(5000));
_set_timer(&padapter->mlmepriv.wdg_timer, 2000); mod_timer(&padapter->mlmepriv.wdg_timer,
jiffies + msecs_to_jiffies(2000));
} }
void r8712_stop_drv_timers(struct _adapter *padapter) void r8712_stop_drv_timers(struct _adapter *padapter)
......
...@@ -69,11 +69,6 @@ static inline void _init_timer(struct timer_list *ptimer, ...@@ -69,11 +69,6 @@ static inline void _init_timer(struct timer_list *ptimer,
init_timer(ptimer); init_timer(ptimer);
} }
static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
{
mod_timer(ptimer, (jiffies+msecs_to_jiffies(delay_time)));
}
static inline void _cancel_timer(struct timer_list *ptimer, u8 *bcancelled) static inline void _cancel_timer(struct timer_list *ptimer, u8 *bcancelled)
{ {
del_timer(ptimer); del_timer(ptimer);
......
This diff is collapsed.
...@@ -604,8 +604,8 @@ static int recv_indicatepkt_reorder(struct _adapter *padapter, ...@@ -604,8 +604,8 @@ static int recv_indicatepkt_reorder(struct _adapter *padapter,
*/ */
if (r8712_recv_indicatepkts_in_order(padapter, preorder_ctrl, false) == if (r8712_recv_indicatepkts_in_order(padapter, preorder_ctrl, false) ==
true) { true) {
_set_timer(&preorder_ctrl->reordering_ctrl_timer, mod_timer(&preorder_ctrl->reordering_ctrl_timer,
REORDER_WAIT_TIME); jiffies + msecs_to_jiffies(REORDER_WAIT_TIME));
spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
} else { } else {
spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
......
...@@ -247,7 +247,8 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter, ...@@ -247,7 +247,8 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
} }
set_fwstate(pmlmepriv, _FW_UNDER_SURVEY); set_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
r8712_enqueue_cmd(pcmdpriv, ph2c); r8712_enqueue_cmd(pcmdpriv, ph2c);
_set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT); mod_timer(&pmlmepriv->scan_to_timer,
jiffies + msecs_to_jiffies(SCANNING_TIMEOUT));
padapter->ledpriv.LedControlHandler(padapter, LED_CTL_SITE_SURVEY); padapter->ledpriv.LedControlHandler(padapter, LED_CTL_SITE_SURVEY);
padapter->blnEnableRxFF0Filter = 0; padapter->blnEnableRxFF0Filter = 0;
return _SUCCESS; return _SUCCESS;
...@@ -890,7 +891,8 @@ void r8712_joinbss_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd) ...@@ -890,7 +891,8 @@ void r8712_joinbss_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd)
struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
if (pcmd->res != H2C_SUCCESS) if (pcmd->res != H2C_SUCCESS)
_set_timer(&pmlmepriv->assoc_timer, 1); mod_timer(&pmlmepriv->assoc_timer,
jiffies + msecs_to_jiffies(1));
r8712_free_cmd_obj(pcmd); r8712_free_cmd_obj(pcmd);
} }
...@@ -907,7 +909,8 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter, ...@@ -907,7 +909,8 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter,
struct wlan_network *tgt_network = &(pmlmepriv->cur_network); struct wlan_network *tgt_network = &(pmlmepriv->cur_network);
if (pcmd->res != H2C_SUCCESS) if (pcmd->res != H2C_SUCCESS)
_set_timer(&pmlmepriv->assoc_timer, 1); mod_timer(&pmlmepriv->assoc_timer,
jiffies + msecs_to_jiffies(1));
_cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled);
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
/* endian_convert */ /* endian_convert */
......
...@@ -85,7 +85,8 @@ static u8 do_join(struct _adapter *padapter) ...@@ -85,7 +85,8 @@ static u8 do_join(struct _adapter *padapter)
ret = r8712_select_and_join_from_scan(pmlmepriv); ret = r8712_select_and_join_from_scan(pmlmepriv);
if (ret == _SUCCESS) if (ret == _SUCCESS)
_set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); mod_timer(&pmlmepriv->assoc_timer,
jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
else { else {
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
/* submit r8712_createbss_cmd to change to an /* submit r8712_createbss_cmd to change to an
......
...@@ -596,8 +596,8 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf) ...@@ -596,8 +596,8 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf)
if (r8712_select_and_join_from_scan(pmlmepriv) if (r8712_select_and_join_from_scan(pmlmepriv)
== _SUCCESS) == _SUCCESS)
_set_timer(&pmlmepriv->assoc_timer, mod_timer(&pmlmepriv->assoc_timer, jiffies +
MAX_JOIN_TIMEOUT); msecs_to_jiffies(MAX_JOIN_TIMEOUT));
else { else {
struct wlan_bssid_ex *pdev_network = struct wlan_bssid_ex *pdev_network =
&(adapter->registrypriv.dev_network); &(adapter->registrypriv.dev_network);
...@@ -622,8 +622,8 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf) ...@@ -622,8 +622,8 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf)
set_fwstate(pmlmepriv, _FW_UNDER_LINKING); set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
if (r8712_select_and_join_from_scan(pmlmepriv) == if (r8712_select_and_join_from_scan(pmlmepriv) ==
_SUCCESS) _SUCCESS)
_set_timer(&pmlmepriv->assoc_timer, mod_timer(&pmlmepriv->assoc_timer, jiffies +
MAX_JOIN_TIMEOUT); msecs_to_jiffies(MAX_JOIN_TIMEOUT));
else else
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
} }
...@@ -679,7 +679,8 @@ void r8712_indicate_connect(struct _adapter *padapter) ...@@ -679,7 +679,8 @@ void r8712_indicate_connect(struct _adapter *padapter)
padapter->ledpriv.LedControlHandler(padapter, LED_CTL_LINK); padapter->ledpriv.LedControlHandler(padapter, LED_CTL_LINK);
r8712_os_indicate_connect(padapter); r8712_os_indicate_connect(padapter);
if (padapter->registrypriv.power_mgnt > PS_MODE_ACTIVE) if (padapter->registrypriv.power_mgnt > PS_MODE_ACTIVE)
_set_timer(&pmlmepriv->dhcp_timer, 60000); mod_timer(&pmlmepriv->dhcp_timer,
jiffies + msecs_to_jiffies(60000));
} }
...@@ -916,7 +917,8 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf) ...@@ -916,7 +917,8 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf)
goto ignore_joinbss_callback; goto ignore_joinbss_callback;
} else { } else {
if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) {
_set_timer(&pmlmepriv->assoc_timer, 1); mod_timer(&pmlmepriv->assoc_timer,
jiffies + msecs_to_jiffies(1));
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment