2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2025-01-22 12:33:59 +08:00

ethernet/intel: Convert timers to use timer_setup()

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>
This commit is contained in:
Kees Cook 2017-10-16 17:29:35 -07:00 committed by David S. Miller
parent d039ef68e9
commit 26566eae80
10 changed files with 43 additions and 50 deletions

View 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 }; struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
u32 speed; u32 speed;
@ -2920,7 +2920,7 @@ static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_set_master(pdev); 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); INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task);

View 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 * Need to wait a few seconds after link up to get diagnostic information from
* the phy * 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)) if (test_bit(__E1000_DOWN, &adapter->state))
return; return;
@ -5159,9 +5159,9 @@ static void e1000e_check_82574_phy_workaround(struct e1000_adapter *adapter)
* e1000_watchdog - Timer Call-back * e1000_watchdog - Timer Call-back
* @data: pointer to adapter cast into an unsigned long * @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 */ /* Do the rest outside of interrupt context */
schedule_work(&adapter->watchdog_task); 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; goto err_eeprom;
} }
setup_timer(&adapter->watchdog_timer, e1000_watchdog, timer_setup(&adapter->watchdog_timer, e1000_watchdog, 0);
(unsigned long)adapter); timer_setup(&adapter->phy_info_timer, e1000_update_phy_info, 0);
setup_timer(&adapter->phy_info_timer, e1000_update_phy_info,
(unsigned long)adapter);
INIT_WORK(&adapter->reset_task, e1000_reset_task); INIT_WORK(&adapter->reset_task, e1000_reset_task);
INIT_WORK(&adapter->watchdog_task, e1000_watchdog_task); INIT_WORK(&adapter->watchdog_task, e1000_watchdog_task);

View File

@ -213,9 +213,10 @@ static void fm10k_start_service_event(struct fm10k_intfc *interface)
* fm10k_service_timer - Timer Call-back * fm10k_service_timer - Timer Call-back
* @data: pointer to interface cast into an unsigned long * @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 */ /* Reset the timer */
mod_timer(&interface->service_timer, (HZ * 2) + jiffies); 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 /* Initialize service timer and service task late in order to avoid
* cleanup issues. * cleanup issues.
*/ */
setup_timer(&interface->service_timer, &fm10k_service_timer, timer_setup(&interface->service_timer, fm10k_service_timer, 0);
(unsigned long)interface);
INIT_WORK(&interface->service_task, fm10k_service_task); INIT_WORK(&interface->service_task, fm10k_service_task);
/* Setup the MAC/VLAN queue */ /* Setup the MAC/VLAN queue */

View File

@ -8800,9 +8800,9 @@ static void i40e_service_task(struct work_struct *work)
* i40e_service_timer - timer callback * i40e_service_timer - timer callback
* @data: pointer to PF struct * @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, mod_timer(&pf->service_timer,
round_jiffies(jiffies + pf->service_timer_period)); 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 */ #endif /* CONFIG_I40E_DCB */
/* set up periodic task facility */ /* 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; pf->service_timer_period = HZ;
INIT_WORK(&pf->service_task, i40e_service_task); 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 */ /* no more scheduling of any task */
set_bit(__I40E_SUSPENDED, pf->state); set_bit(__I40E_SUSPENDED, pf->state);
set_bit(__I40E_DOWN, pf->state); set_bit(__I40E_DOWN, pf->state);
if (pf->service_timer.data) if (pf->service_timer.function)
del_timer_sync(&pf->service_timer); del_timer_sync(&pf->service_timer);
if (pf->service_task.func) if (pf->service_task.func)
cancel_work_sync(&pf->service_task); cancel_work_sync(&pf->service_task);

View File

@ -1594,9 +1594,10 @@ err:
* i40evf_watchdog_timer - Periodic call-back timer * i40evf_watchdog_timer - Periodic call-back timer
* @data: pointer to adapter disguised as unsigned long * @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); schedule_work(&adapter->watchdog_task);
/* timer will be rescheduled in 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); ether_addr_copy(netdev->perm_addr, adapter->hw.mac.addr);
} }
setup_timer(&adapter->watchdog_timer, &i40evf_watchdog_timer, timer_setup(&adapter->watchdog_timer, i40evf_watchdog_timer, 0);
(unsigned long)adapter);
mod_timer(&adapter->watchdog_timer, jiffies + 1); mod_timer(&adapter->watchdog_timer, jiffies + 1);
adapter->tx_desc_count = I40EVF_DEFAULT_TXD; adapter->tx_desc_count = I40EVF_DEFAULT_TXD;

View 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_tx_ring(struct igb_ring *);
static void igb_clean_rx_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_set_rx_mode(struct net_device *);
static void igb_update_phy_info(unsigned long); static void igb_update_phy_info(struct timer_list *);
static void igb_watchdog(unsigned long); static void igb_watchdog(struct timer_list *);
static void igb_watchdog_task(struct work_struct *); static void igb_watchdog_task(struct work_struct *);
static netdev_tx_t igb_xmit_frame(struct sk_buff *skb, struct net_device *); static netdev_tx_t igb_xmit_frame(struct sk_buff *skb, struct net_device *);
static void igb_get_stats64(struct net_device *dev, 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); wr32(E1000_TXPBS, I210_TXPBSIZE_DEFAULT);
} }
setup_timer(&adapter->watchdog_timer, igb_watchdog, timer_setup(&adapter->watchdog_timer, igb_watchdog, 0);
(unsigned long) adapter); timer_setup(&adapter->phy_info_timer, igb_update_phy_info, 0);
setup_timer(&adapter->phy_info_timer, igb_update_phy_info,
(unsigned long) adapter);
INIT_WORK(&adapter->reset_task, igb_reset_task); INIT_WORK(&adapter->reset_task, igb_reset_task);
INIT_WORK(&adapter->watchdog_task, igb_watchdog_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 /* Need to wait a few seconds after link up to get diagnostic information from
* the phy * 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); igb_get_phy_info(&adapter->hw);
} }
@ -4514,9 +4512,9 @@ static void igb_check_lvmmc(struct igb_adapter *adapter)
* igb_watchdog - Timer Call-back * igb_watchdog - Timer Call-back
* @data: pointer to adapter cast into an unsigned long * @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 */ /* Do the rest outside of interrupt context */
schedule_work(&adapter->watchdog_task); schedule_work(&adapter->watchdog_task);
} }

View File

@ -1915,9 +1915,9 @@ static bool igbvf_has_link(struct igbvf_adapter *adapter)
* igbvf_watchdog - Timer Call-back * igbvf_watchdog - Timer Call-back
* @data: pointer to adapter cast into an unsigned long * @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 */ /* Do the rest outside of interrupt context */
schedule_work(&adapter->watchdog_task); 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); netdev->addr_len);
} }
setup_timer(&adapter->watchdog_timer, &igbvf_watchdog, timer_setup(&adapter->watchdog_timer, igbvf_watchdog, 0);
(unsigned long)adapter);
INIT_WORK(&adapter->reset_task, igbvf_reset_task); INIT_WORK(&adapter->reset_task, igbvf_reset_task);
INIT_WORK(&adapter->watchdog_task, igbvf_watchdog_task); INIT_WORK(&adapter->watchdog_task, igbvf_watchdog_task);

View 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_tx_ring(struct ixgb_adapter *adapter);
static void ixgb_clean_rx_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_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, static netdev_tx_t ixgb_xmit_frame(struct sk_buff *skb,
struct net_device *netdev); struct net_device *netdev);
static int ixgb_change_mtu(struct net_device *netdev, int new_mtu); 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); adapter->part_num = ixgb_get_ee_pba_number(&adapter->hw);
setup_timer(&adapter->watchdog_timer, ixgb_watchdog, timer_setup(&adapter->watchdog_timer, ixgb_watchdog, 0);
(unsigned long)adapter);
INIT_WORK(&adapter->tx_timeout_task, ixgb_tx_timeout_task); INIT_WORK(&adapter->tx_timeout_task, ixgb_tx_timeout_task);
@ -1151,9 +1150,9 @@ alloc_failed:
**/ **/
static void 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 net_device *netdev = adapter->netdev;
struct ixgb_desc_ring *txdr = &adapter->tx_ring; struct ixgb_desc_ring *txdr = &adapter->tx_ring;

View File

@ -7690,9 +7690,9 @@ static void ixgbe_sfp_link_config_subtask(struct ixgbe_adapter *adapter)
* ixgbe_service_timer - Timer Call-back * ixgbe_service_timer - Timer Call-back
* @data: pointer to adapter cast into an unsigned long * @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; unsigned long next_event_offset;
/* poll faster when waiting for link */ /* poll faster when waiting for link */
@ -10508,8 +10508,7 @@ skip_sriov:
ether_addr_copy(hw->mac.addr, hw->mac.perm_addr); ether_addr_copy(hw->mac.addr, hw->mac.perm_addr);
ixgbe_mac_set_default_filter(adapter); ixgbe_mac_set_default_filter(adapter);
setup_timer(&adapter->service_timer, &ixgbe_service_timer, timer_setup(&adapter->service_timer, ixgbe_service_timer, 0);
(unsigned long) adapter);
if (ixgbe_removed(hw->hw_addr)) { if (ixgbe_removed(hw->hw_addr)) {
err = -EIO; err = -EIO;

View File

@ -2747,9 +2747,10 @@ void ixgbevf_update_stats(struct ixgbevf_adapter *adapter)
* ixgbevf_service_timer - Timer Call-back * ixgbevf_service_timer - Timer Call-back
* @data: pointer to adapter cast into an unsigned long * @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 */ /* Reset the timer */
mod_timer(&adapter->service_timer, (HZ * 2) + jiffies); 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; goto err_sw_init;
} }
setup_timer(&adapter->service_timer, &ixgbevf_service_timer, timer_setup(&adapter->service_timer, ixgbevf_service_timer, 0);
(unsigned long)adapter);
INIT_WORK(&adapter->service_task, ixgbevf_service_task); INIT_WORK(&adapter->service_task, ixgbevf_service_task);
set_bit(__IXGBEVF_SERVICE_INITED, &adapter->state); set_bit(__IXGBEVF_SERVICE_INITED, &adapter->state);