ethernet/intel: Convert timers to use timer_setup()
authorKees Cook <keescook@chromium.org>
Tue, 17 Oct 2017 00:29:35 +0000 (17:29 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Oct 2017 11:40:26 +0000 (12:40 +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. Switches test of .data field to
.function, since .data will be going away.

Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/intel/e100.c
drivers/net/ethernet/intel/e1000e/netdev.c
drivers/net/ethernet/intel/fm10k/fm10k_pci.c
drivers/net/ethernet/intel/i40e/i40e_main.c
drivers/net/ethernet/intel/i40evf/i40evf_main.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igbvf/netdev.c
drivers/net/ethernet/intel/ixgb/ixgb_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c

index 184f11242f56d56e4a4c8ed2fde6b4e70d82cc52..44b3937f7e81a43469553afbcae7f14becbf6316 100644 (file)
@@ -1710,9 +1710,9 @@ static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex)
        }
 }
 
-static void e100_watchdog(unsigned long data)
+static void e100_watchdog(struct timer_list *t)
 {
-       struct nic *nic = (struct nic *)data;
+       struct nic *nic = from_timer(nic, t, watchdog);
        struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
        u32 speed;
 
@@ -2920,7 +2920,7 @@ static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        pci_set_master(pdev);
 
-       setup_timer(&nic->watchdog, e100_watchdog, (unsigned long)nic);
+       timer_setup(&nic->watchdog, e100_watchdog, 0);
 
        INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task);
 
index bf8f38f769534a03de66d3558efc51d967a9854a..f2f49239b01509e120a292605ef4e0e9ef21c248 100644 (file)
@@ -4823,9 +4823,9 @@ static void e1000e_update_phy_task(struct work_struct *work)
  * Need to wait a few seconds after link up to get diagnostic information from
  * the phy
  **/
-static void e1000_update_phy_info(unsigned long data)
+static void e1000_update_phy_info(struct timer_list *t)
 {
-       struct e1000_adapter *adapter = (struct e1000_adapter *)data;
+       struct e1000_adapter *adapter = from_timer(adapter, t, phy_info_timer);
 
        if (test_bit(__E1000_DOWN, &adapter->state))
                return;
@@ -5159,9 +5159,9 @@ static void e1000e_check_82574_phy_workaround(struct e1000_adapter *adapter)
  * e1000_watchdog - Timer Call-back
  * @data: pointer to adapter cast into an unsigned long
  **/
-static void e1000_watchdog(unsigned long data)
+static void e1000_watchdog(struct timer_list *t)
 {
-       struct e1000_adapter *adapter = (struct e1000_adapter *)data;
+       struct e1000_adapter *adapter = from_timer(adapter, t, watchdog_timer);
 
        /* Do the rest outside of interrupt context */
        schedule_work(&adapter->watchdog_task);
@@ -7267,10 +7267,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto err_eeprom;
        }
 
-       setup_timer(&adapter->watchdog_timer, e1000_watchdog,
-                   (unsigned long)adapter);
-       setup_timer(&adapter->phy_info_timer, e1000_update_phy_info,
-                   (unsigned long)adapter);
+       timer_setup(&adapter->watchdog_timer, e1000_watchdog, 0);
+       timer_setup(&adapter->phy_info_timer, e1000_update_phy_info, 0);
 
        INIT_WORK(&adapter->reset_task, e1000_reset_task);
        INIT_WORK(&adapter->watchdog_task, e1000_watchdog_task);
index 1e9ae3197b172dbc1a3899df1ec23baef84b8419..7f605221a6867ed8e4c53de10048040f06e509d6 100644 (file)
@@ -213,9 +213,10 @@ static void fm10k_start_service_event(struct fm10k_intfc *interface)
  * fm10k_service_timer - Timer Call-back
  * @data: pointer to interface cast into an unsigned long
  **/
-static void fm10k_service_timer(unsigned long data)
+static void fm10k_service_timer(struct timer_list *t)
 {
-       struct fm10k_intfc *interface = (struct fm10k_intfc *)data;
+       struct fm10k_intfc *interface = from_timer(interface, t,
+                                                  service_timer);
 
        /* Reset the timer */
        mod_timer(&interface->service_timer, (HZ * 2) + jiffies);
@@ -2315,8 +2316,7 @@ static int fm10k_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        /* Initialize service timer and service task late in order to avoid
         * cleanup issues.
         */
-       setup_timer(&interface->service_timer, &fm10k_service_timer,
-                   (unsigned long)interface);
+       timer_setup(&interface->service_timer, fm10k_service_timer, 0);
        INIT_WORK(&interface->service_task, fm10k_service_task);
 
        /* Setup the MAC/VLAN queue */
index bb31d53c49234065c693fb5a44bda5a13277b360..39989147b30baa8c9cb502cb8550f1f21c65d9c5 100644 (file)
@@ -8800,9 +8800,9 @@ static void i40e_service_task(struct work_struct *work)
  * i40e_service_timer - timer callback
  * @data: pointer to PF struct
  **/
-static void i40e_service_timer(unsigned long data)
+static void i40e_service_timer(struct timer_list *t)
 {
-       struct i40e_pf *pf = (struct i40e_pf *)data;
+       struct i40e_pf *pf = from_timer(pf, t, service_timer);
 
        mod_timer(&pf->service_timer,
                  round_jiffies(jiffies + pf->service_timer_period));
@@ -12648,7 +12648,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 #endif /* CONFIG_I40E_DCB */
 
        /* set up periodic task facility */
-       setup_timer(&pf->service_timer, i40e_service_timer, (unsigned long)pf);
+       timer_setup(&pf->service_timer, i40e_service_timer, 0);
        pf->service_timer_period = HZ;
 
        INIT_WORK(&pf->service_task, i40e_service_task);
@@ -12972,7 +12972,7 @@ static void i40e_remove(struct pci_dev *pdev)
        /* no more scheduling of any task */
        set_bit(__I40E_SUSPENDED, pf->state);
        set_bit(__I40E_DOWN, pf->state);
-       if (pf->service_timer.data)
+       if (pf->service_timer.function)
                del_timer_sync(&pf->service_timer);
        if (pf->service_task.func)
                cancel_work_sync(&pf->service_task);
index 5bcbd46e2f6c4a84294bd93c51c8f2711f88119a..ca2ebdbd24d7c9ce832af711942671ac622d4a15 100644 (file)
@@ -1594,9 +1594,10 @@ err:
  * i40evf_watchdog_timer - Periodic call-back timer
  * @data: pointer to adapter disguised as unsigned long
  **/
-static void i40evf_watchdog_timer(unsigned long data)
+static void i40evf_watchdog_timer(struct timer_list *t)
 {
-       struct i40evf_adapter *adapter = (struct i40evf_adapter *)data;
+       struct i40evf_adapter *adapter = from_timer(adapter, t,
+                                                   watchdog_timer);
 
        schedule_work(&adapter->watchdog_task);
        /* timer will be rescheduled in watchdog task */
@@ -2748,8 +2749,7 @@ static void i40evf_init_task(struct work_struct *work)
                ether_addr_copy(netdev->perm_addr, adapter->hw.mac.addr);
        }
 
-       setup_timer(&adapter->watchdog_timer, &i40evf_watchdog_timer,
-                   (unsigned long)adapter);
+       timer_setup(&adapter->watchdog_timer, i40evf_watchdog_timer, 0);
        mod_timer(&adapter->watchdog_timer, jiffies + 1);
 
        adapter->tx_desc_count = I40EVF_DEFAULT_TXD;
index 837d9b46a390526711a1ebcb3b43c1a5b13a708b..58d01a2113678752928a1ac560e8b65ed8198586 100644 (file)
@@ -133,8 +133,8 @@ static void igb_clean_all_rx_rings(struct igb_adapter *);
 static void igb_clean_tx_ring(struct igb_ring *);
 static void igb_clean_rx_ring(struct igb_ring *);
 static void igb_set_rx_mode(struct net_device *);
-static void igb_update_phy_info(unsigned long);
-static void igb_watchdog(unsigned long);
+static void igb_update_phy_info(struct timer_list *);
+static void igb_watchdog(struct timer_list *);
 static void igb_watchdog_task(struct work_struct *);
 static netdev_tx_t igb_xmit_frame(struct sk_buff *skb, struct net_device *);
 static void igb_get_stats64(struct net_device *dev,
@@ -2538,10 +2538,8 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                wr32(E1000_TXPBS, I210_TXPBSIZE_DEFAULT);
        }
 
-       setup_timer(&adapter->watchdog_timer, igb_watchdog,
-                   (unsigned long) adapter);
-       setup_timer(&adapter->phy_info_timer, igb_update_phy_info,
-                   (unsigned long) adapter);
+       timer_setup(&adapter->watchdog_timer, igb_watchdog, 0);
+       timer_setup(&adapter->phy_info_timer, igb_update_phy_info, 0);
 
        INIT_WORK(&adapter->reset_task, igb_reset_task);
        INIT_WORK(&adapter->watchdog_task, igb_watchdog_task);
@@ -4425,9 +4423,9 @@ static void igb_spoof_check(struct igb_adapter *adapter)
 /* Need to wait a few seconds after link up to get diagnostic information from
  * the phy
  */
-static void igb_update_phy_info(unsigned long data)
+static void igb_update_phy_info(struct timer_list *t)
 {
-       struct igb_adapter *adapter = (struct igb_adapter *) data;
+       struct igb_adapter *adapter = from_timer(adapter, t, phy_info_timer);
        igb_get_phy_info(&adapter->hw);
 }
 
@@ -4514,9 +4512,9 @@ static void igb_check_lvmmc(struct igb_adapter *adapter)
  *  igb_watchdog - Timer Call-back
  *  @data: pointer to adapter cast into an unsigned long
  **/
-static void igb_watchdog(unsigned long data)
+static void igb_watchdog(struct timer_list *t)
 {
-       struct igb_adapter *adapter = (struct igb_adapter *)data;
+       struct igb_adapter *adapter = from_timer(adapter, t, watchdog_timer);
        /* Do the rest outside of interrupt context */
        schedule_work(&adapter->watchdog_task);
 }
index 1ed556911b1472fdcf3d085f0276cc189633f847..713e8df23744a46ea30824a014f875bd28d29fc5 100644 (file)
@@ -1915,9 +1915,9 @@ static bool igbvf_has_link(struct igbvf_adapter *adapter)
  * igbvf_watchdog - Timer Call-back
  * @data: pointer to adapter cast into an unsigned long
  **/
-static void igbvf_watchdog(unsigned long data)
+static void igbvf_watchdog(struct timer_list *t)
 {
-       struct igbvf_adapter *adapter = (struct igbvf_adapter *)data;
+       struct igbvf_adapter *adapter = from_timer(adapter, t, watchdog_timer);
 
        /* Do the rest outside of interrupt context */
        schedule_work(&adapter->watchdog_task);
@@ -2878,8 +2878,7 @@ static int igbvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                       netdev->addr_len);
        }
 
-       setup_timer(&adapter->watchdog_timer, &igbvf_watchdog,
-                   (unsigned long)adapter);
+       timer_setup(&adapter->watchdog_timer, igbvf_watchdog, 0);
 
        INIT_WORK(&adapter->reset_task, igbvf_reset_task);
        INIT_WORK(&adapter->watchdog_task, igbvf_watchdog_task);
index 1e6ec2277d547aea39870db1387c1894506fb3ee..2353c383f0a7de092b4ba6581af4516ad692069c 100644 (file)
@@ -83,7 +83,7 @@ static void ixgb_setup_rctl(struct ixgb_adapter *adapter);
 static void ixgb_clean_tx_ring(struct ixgb_adapter *adapter);
 static void ixgb_clean_rx_ring(struct ixgb_adapter *adapter);
 static void ixgb_set_multi(struct net_device *netdev);
-static void ixgb_watchdog(unsigned long data);
+static void ixgb_watchdog(struct timer_list *t);
 static netdev_tx_t ixgb_xmit_frame(struct sk_buff *skb,
                                   struct net_device *netdev);
 static int ixgb_change_mtu(struct net_device *netdev, int new_mtu);
@@ -508,8 +508,7 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        adapter->part_num = ixgb_get_ee_pba_number(&adapter->hw);
 
-       setup_timer(&adapter->watchdog_timer, ixgb_watchdog,
-                   (unsigned long)adapter);
+       timer_setup(&adapter->watchdog_timer, ixgb_watchdog, 0);
 
        INIT_WORK(&adapter->tx_timeout_task, ixgb_tx_timeout_task);
 
@@ -1151,9 +1150,9 @@ alloc_failed:
  **/
 
 static void
-ixgb_watchdog(unsigned long data)
+ixgb_watchdog(struct timer_list *t)
 {
-       struct ixgb_adapter *adapter = (struct ixgb_adapter *)data;
+       struct ixgb_adapter *adapter = from_timer(adapter, t, watchdog_timer);
        struct net_device *netdev = adapter->netdev;
        struct ixgb_desc_ring *txdr = &adapter->tx_ring;
 
index 7683c14024aa18546a93bae8a1d74e4b7bcfae5d..3e83edd10e23ac65bdfdbbfae81a3cd1172e1ac6 100644 (file)
@@ -7690,9 +7690,9 @@ static void ixgbe_sfp_link_config_subtask(struct ixgbe_adapter *adapter)
  * ixgbe_service_timer - Timer Call-back
  * @data: pointer to adapter cast into an unsigned long
  **/
-static void ixgbe_service_timer(unsigned long data)
+static void ixgbe_service_timer(struct timer_list *t)
 {
-       struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)data;
+       struct ixgbe_adapter *adapter = from_timer(adapter, t, service_timer);
        unsigned long next_event_offset;
 
        /* poll faster when waiting for link */
@@ -10508,8 +10508,7 @@ skip_sriov:
        ether_addr_copy(hw->mac.addr, hw->mac.perm_addr);
        ixgbe_mac_set_default_filter(adapter);
 
-       setup_timer(&adapter->service_timer, &ixgbe_service_timer,
-                   (unsigned long) adapter);
+       timer_setup(&adapter->service_timer, ixgbe_service_timer, 0);
 
        if (ixgbe_removed(hw->hw_addr)) {
                err = -EIO;
index 032f8ac06357aefa7a695c6685b8bbbbf7a8949e..12d3601b1d57f9fa977acd54c646e81c3d1b9048 100644 (file)
@@ -2747,9 +2747,10 @@ void ixgbevf_update_stats(struct ixgbevf_adapter *adapter)
  * ixgbevf_service_timer - Timer Call-back
  * @data: pointer to adapter cast into an unsigned long
  **/
-static void ixgbevf_service_timer(unsigned long data)
+static void ixgbevf_service_timer(struct timer_list *t)
 {
-       struct ixgbevf_adapter *adapter = (struct ixgbevf_adapter *)data;
+       struct ixgbevf_adapter *adapter = from_timer(adapter, t,
+                                                    service_timer);
 
        /* Reset the timer */
        mod_timer(&adapter->service_timer, (HZ * 2) + jiffies);
@@ -4120,8 +4121,7 @@ static int ixgbevf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto err_sw_init;
        }
 
-       setup_timer(&adapter->service_timer, &ixgbevf_service_timer,
-                   (unsigned long)adapter);
+       timer_setup(&adapter->service_timer, ixgbevf_service_timer, 0);
 
        INIT_WORK(&adapter->service_task, ixgbevf_service_task);
        set_bit(__IXGBEVF_SERVICE_INITED, &adapter->state);