Commit e053b628 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Jeff Garzik

atlx: timer cleanup

Do some cleanup on timer usage in this driver:
  * Use round_jiffies to align wakeups and reduce power.
  * Remove atl1_watchdog which does nothing but rearm itself
  * Use setup_timer() function
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 02e71731
...@@ -1390,7 +1390,8 @@ static u32 atl1_check_link(struct atl1_adapter *adapter) ...@@ -1390,7 +1390,8 @@ static u32 atl1_check_link(struct atl1_adapter *adapter)
/* auto-neg, insert timer to re-config phy */ /* auto-neg, insert timer to re-config phy */
if (!adapter->phy_timer_pending) { if (!adapter->phy_timer_pending) {
adapter->phy_timer_pending = true; adapter->phy_timer_pending = true;
mod_timer(&adapter->phy_config_timer, jiffies + 3 * HZ); mod_timer(&adapter->phy_config_timer,
round_jiffies(jiffies + 3 * HZ));
} }
return 0; return 0;
...@@ -2525,17 +2526,6 @@ static irqreturn_t atl1_intr(int irq, void *data) ...@@ -2525,17 +2526,6 @@ static irqreturn_t atl1_intr(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
/*
* atl1_watchdog - Timer Call-back
* @data: pointer to netdev cast into an unsigned long
*/
static void atl1_watchdog(unsigned long data)
{
struct atl1_adapter *adapter = (struct atl1_adapter *)data;
/* Reset the timer */
mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
}
/* /*
* atl1_phy_config - Timer Call-back * atl1_phy_config - Timer Call-back
...@@ -2608,7 +2598,6 @@ static s32 atl1_up(struct atl1_adapter *adapter) ...@@ -2608,7 +2598,6 @@ static s32 atl1_up(struct atl1_adapter *adapter)
if (unlikely(err)) if (unlikely(err))
goto err_up; goto err_up;
mod_timer(&adapter->watchdog_timer, jiffies);
atlx_irq_enable(adapter); atlx_irq_enable(adapter);
atl1_check_link(adapter); atl1_check_link(adapter);
netif_start_queue(netdev); netif_start_queue(netdev);
...@@ -2626,7 +2615,6 @@ static void atl1_down(struct atl1_adapter *adapter) ...@@ -2626,7 +2615,6 @@ static void atl1_down(struct atl1_adapter *adapter)
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
netif_stop_queue(netdev); netif_stop_queue(netdev);
del_timer_sync(&adapter->watchdog_timer);
del_timer_sync(&adapter->phy_config_timer); del_timer_sync(&adapter->phy_config_timer);
adapter->phy_timer_pending = false; adapter->phy_timer_pending = false;
...@@ -3050,13 +3038,8 @@ static int __devinit atl1_probe(struct pci_dev *pdev, ...@@ -3050,13 +3038,8 @@ static int __devinit atl1_probe(struct pci_dev *pdev,
netif_carrier_off(netdev); netif_carrier_off(netdev);
netif_stop_queue(netdev); netif_stop_queue(netdev);
init_timer(&adapter->watchdog_timer); setup_timer(&adapter->phy_config_timer, &atl1_phy_config,
adapter->watchdog_timer.function = &atl1_watchdog; (unsigned long)adapter);
adapter->watchdog_timer.data = (unsigned long)adapter;
init_timer(&adapter->phy_config_timer);
adapter->phy_config_timer.function = &atl1_phy_config;
adapter->phy_config_timer.data = (unsigned long)adapter;
adapter->phy_timer_pending = false; adapter->phy_timer_pending = false;
INIT_WORK(&adapter->tx_timeout_task, atl1_tx_timeout_task); INIT_WORK(&adapter->tx_timeout_task, atl1_tx_timeout_task);
......
...@@ -765,7 +765,7 @@ struct atl1_adapter { ...@@ -765,7 +765,7 @@ struct atl1_adapter {
struct work_struct tx_timeout_task; struct work_struct tx_timeout_task;
struct work_struct link_chg_task; struct work_struct link_chg_task;
struct work_struct pcie_dma_to_rst_task; struct work_struct pcie_dma_to_rst_task;
struct timer_list watchdog_timer;
struct timer_list phy_config_timer; struct timer_list phy_config_timer;
bool phy_timer_pending; bool phy_timer_pending;
......
...@@ -724,7 +724,7 @@ static int atl2_open(struct net_device *netdev) ...@@ -724,7 +724,7 @@ static int atl2_open(struct net_device *netdev)
clear_bit(__ATL2_DOWN, &adapter->flags); clear_bit(__ATL2_DOWN, &adapter->flags);
mod_timer(&adapter->watchdog_timer, jiffies + 4*HZ); mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 4*HZ));
val = ATL2_READ_REG(&adapter->hw, REG_MASTER_CTRL); val = ATL2_READ_REG(&adapter->hw, REG_MASTER_CTRL);
ATL2_WRITE_REG(&adapter->hw, REG_MASTER_CTRL, ATL2_WRITE_REG(&adapter->hw, REG_MASTER_CTRL,
...@@ -1051,7 +1051,8 @@ static void atl2_watchdog(unsigned long data) ...@@ -1051,7 +1051,8 @@ static void atl2_watchdog(unsigned long data)
adapter->netdev->stats.rx_over_errors += drop_rxd + drop_rxs; adapter->netdev->stats.rx_over_errors += drop_rxd + drop_rxs;
/* Reset the timer */ /* Reset the timer */
mod_timer(&adapter->watchdog_timer, jiffies + 4 * HZ); mod_timer(&adapter->watchdog_timer,
round_jiffies(jiffies + 4 * HZ));
} }
} }
...@@ -1255,7 +1256,8 @@ static int atl2_check_link(struct atl2_adapter *adapter) ...@@ -1255,7 +1256,8 @@ static int atl2_check_link(struct atl2_adapter *adapter)
* (if interval smaller than 5 seconds, something strange) */ * (if interval smaller than 5 seconds, something strange) */
if (!test_bit(__ATL2_DOWN, &adapter->flags)) { if (!test_bit(__ATL2_DOWN, &adapter->flags)) {
if (!test_and_set_bit(0, &adapter->cfg_phy)) if (!test_and_set_bit(0, &adapter->cfg_phy))
mod_timer(&adapter->phy_config_timer, jiffies + 5 * HZ); mod_timer(&adapter->phy_config_timer,
round_jiffies(jiffies + 5 * HZ));
} }
return 0; return 0;
......
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