Staging: rtl8192u: Combine initialization using setup_timer
authorSomya Anand <somyaanand214@gmail.com>
Wed, 11 Mar 2015 11:32:16 +0000 (17:02 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 16 Mar 2015 14:54:13 +0000 (15:54 +0100)
The function setup_timer combines the initialization of a timer with the
initialization of the timer's function and data fields.

So, this patch combines the multiline code for timer initialization using the function
setup_timer. This issue is identified via coccinelle script.

@@
expression E1, E2, E3;
type T;
@@
- init_timer(&E1);
...
(
- E1.function = E2;
...
- E1.data = (T)E3;
+ setup_timer(&E1, E2, (T)E3);
|
- E1.data = (T)E3;
...
- E1.function = E2;
+ setup_timer(&E1, E2, (T)E3);
|
- E1.function = E2;
+ setup_timer(&E1, E2, 0);
)

Signed-off-by: Somya Anand <somyaanand214@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
drivers/staging/rtl8192u/r8192U_core.c
drivers/staging/rtl8192u/r8192U_dm.c

index 9a607253823c574ca224cf5876dcb7e1c36bd241..31233d895ee9414c2206697d0d7e1dc3b1ae8613 100644 (file)
@@ -133,9 +133,8 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
        ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
 
        INIT_LIST_HEAD(&ieee->crypt_deinit_list);
-       init_timer(&ieee->crypt_deinit_timer);
-       ieee->crypt_deinit_timer.data = (unsigned long)ieee;
-       ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
+       setup_timer(&ieee->crypt_deinit_timer,
+                   ieee80211_crypt_deinit_handler, (unsigned long)ieee);
 
        spin_lock_init(&ieee->lock);
        spin_lock_init(&ieee->wpax_suitlist_lock);
index acaa723817e709dd574ffeedd89bb980d0f27a2f..0345f1caea546001b5d629292e94dfd4bc81a84a 100644 (file)
@@ -156,26 +156,16 @@ void TSInitialize(struct ieee80211_device *ieee)
                pTxTS->num = count;
                // The timers for the operation of Traffic Stream and Block Ack.
                // DLS related timer will be add here in the future!!
-               init_timer(&pTxTS->TsCommonInfo.SetupTimer);
-               pTxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pTxTS;
-               pTxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut;
-
-               init_timer(&pTxTS->TsCommonInfo.InactTimer);
-               pTxTS->TsCommonInfo.InactTimer.data = (unsigned long)pTxTS;
-               pTxTS->TsCommonInfo.InactTimer.function = TsInactTimeout;
-
-               init_timer(&pTxTS->TsAddBaTimer);
-               pTxTS->TsAddBaTimer.data = (unsigned long)pTxTS;
-               pTxTS->TsAddBaTimer.function = TsAddBaProcess;
-
-               init_timer(&pTxTS->TxPendingBARecord.Timer);
-               pTxTS->TxPendingBARecord.Timer.data = (unsigned long)pTxTS;
-               pTxTS->TxPendingBARecord.Timer.function = BaSetupTimeOut;
-
-               init_timer(&pTxTS->TxAdmittedBARecord.Timer);
-               pTxTS->TxAdmittedBARecord.Timer.data = (unsigned long)pTxTS;
-               pTxTS->TxAdmittedBARecord.Timer.function = TxBaInactTimeout;
-
+               setup_timer(&pTxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut,
+                           (unsigned long)pTxTS);
+               setup_timer(&pTxTS->TsCommonInfo.InactTimer, TsInactTimeout,
+                           (unsigned long)pTxTS);
+               setup_timer(&pTxTS->TsAddBaTimer, TsAddBaProcess,
+                           (unsigned long)pTxTS);
+               setup_timer(&pTxTS->TxPendingBARecord.Timer, BaSetupTimeOut,
+                           (unsigned long)pTxTS);
+               setup_timer(&pTxTS->TxAdmittedBARecord.Timer,
+                           TxBaInactTimeout, (unsigned long)pTxTS);
                ResetTxTsEntry(pTxTS);
                list_add_tail(&pTxTS->TsCommonInfo.List, &ieee->Tx_TS_Unused_List);
                pTxTS++;
@@ -189,23 +179,14 @@ void TSInitialize(struct ieee80211_device *ieee)
        {
                pRxTS->num = count;
                INIT_LIST_HEAD(&pRxTS->RxPendingPktList);
-
-               init_timer(&pRxTS->TsCommonInfo.SetupTimer);
-               pRxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pRxTS;
-               pRxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut;
-
-               init_timer(&pRxTS->TsCommonInfo.InactTimer);
-               pRxTS->TsCommonInfo.InactTimer.data = (unsigned long)pRxTS;
-               pRxTS->TsCommonInfo.InactTimer.function = TsInactTimeout;
-
-               init_timer(&pRxTS->RxAdmittedBARecord.Timer);
-               pRxTS->RxAdmittedBARecord.Timer.data = (unsigned long)pRxTS;
-               pRxTS->RxAdmittedBARecord.Timer.function = RxBaInactTimeout;
-
-               init_timer(&pRxTS->RxPktPendingTimer);
-               pRxTS->RxPktPendingTimer.data = (unsigned long)pRxTS;
-               pRxTS->RxPktPendingTimer.function = RxPktPendingTimeout;
-
+               setup_timer(&pRxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut,
+                           (unsigned long)pRxTS);
+               setup_timer(&pRxTS->TsCommonInfo.InactTimer, TsInactTimeout,
+                           (unsigned long)pRxTS);
+               setup_timer(&pRxTS->RxAdmittedBARecord.Timer,
+                           RxBaInactTimeout, (unsigned long)pRxTS);
+               setup_timer(&pRxTS->RxPktPendingTimer, RxPktPendingTimeout,
+                           (unsigned long)pRxTS);
                ResetRxTsEntry(pRxTS);
                list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List);
                pRxTS++;
index 8f7a3219eff13e01eb548a622f19f6ea11d0427b..b6cd7ea744ad710e0d021cdb9a391a9db56639bd 100644 (file)
@@ -2549,9 +2549,8 @@ static short rtl8192_init(struct net_device *dev)
        rtl8192_read_eeprom_info(dev);
        rtl8192_get_channel_map(dev);
        init_hal_dm(dev);
-       init_timer(&priv->watch_dog_timer);
-       priv->watch_dog_timer.data = (unsigned long)dev;
-       priv->watch_dog_timer.function = watch_dog_timer_callback;
+       setup_timer(&priv->watch_dog_timer, watch_dog_timer_callback,
+                   (unsigned long)dev);
        if (rtl8192_usb_initendpoints(dev) != 0) {
                DMESG("Endopoints initialization failed");
                return -ENOMEM;
index 16cafcdb26c6bece8f394a021abc4a82e4cb379d..4c62cb8f00657515c279ac509a1ac4c803369fc2 100644 (file)
@@ -2681,10 +2681,8 @@ static void dm_init_fsync(struct net_device *dev)
        priv->ieee80211->fsync_seconddiff_ratethreshold = 200;
        priv->ieee80211->fsync_state = Default_Fsync;
        priv->framesyncMonitor = 1;     /* current default 0xc38 monitor on */
-
-       init_timer(&priv->fsync_timer);
-       priv->fsync_timer.data = (unsigned long)dev;
-       priv->fsync_timer.function = dm_fsync_timer_callback;
+       setup_timer(&priv->fsync_timer, dm_fsync_timer_callback,
+                   (unsigned long)dev);
 }
 
 static void dm_deInit_fsync(struct net_device *dev)