Commit 15db6e0d authored by Muhammad Falak R Wani's avatar Muhammad Falak R Wani Committed by David S. Miller

net/hsr: Use setup_timer and mod_timer.

The function setup_timer combines the initialization of a timer with the
initialization of the timer's function and data fields. The mulitiline
code for timer initialization is now replaced with function setup_timer.

Also, quoting the mod_timer() function comment:
-> mod_timer() is a more efficient way to update the expire field of an
   active timer (if the timer is inactive it will be activated).

Use setup_timer() and mod_timer() to setup and arm a timer, making the
code compact and aid readablity.
Signed-off-by: default avatarMuhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a2a658a3
...@@ -461,13 +461,9 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], ...@@ -461,13 +461,9 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
hsr->sequence_nr = HSR_SEQNR_START; hsr->sequence_nr = HSR_SEQNR_START;
hsr->sup_sequence_nr = HSR_SUP_SEQNR_START; hsr->sup_sequence_nr = HSR_SUP_SEQNR_START;
init_timer(&hsr->announce_timer); setup_timer(&hsr->announce_timer, hsr_announce, (unsigned long)hsr);
hsr->announce_timer.function = hsr_announce;
hsr->announce_timer.data = (unsigned long) hsr;
init_timer(&hsr->prune_timer); setup_timer(&hsr->prune_timer, hsr_prune_nodes, (unsigned long)hsr);
hsr->prune_timer.function = hsr_prune_nodes;
hsr->prune_timer.data = (unsigned long) hsr;
ether_addr_copy(hsr->sup_multicast_addr, def_multicast_addr); ether_addr_copy(hsr->sup_multicast_addr, def_multicast_addr);
hsr->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec; hsr->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec;
...@@ -502,8 +498,7 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], ...@@ -502,8 +498,7 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
if (res) if (res)
goto fail; goto fail;
hsr->prune_timer.expires = jiffies + msecs_to_jiffies(PRUNE_PERIOD); mod_timer(&hsr->prune_timer, jiffies + msecs_to_jiffies(PRUNE_PERIOD));
add_timer(&hsr->prune_timer);
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