Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Muhammad Falak R Wani and committed by
David S. Miller
15db6e0d a2a658a3

+3 -8
+3 -8
net/hsr/hsr_device.c
··· 461 461 hsr->sequence_nr = HSR_SEQNR_START; 462 462 hsr->sup_sequence_nr = HSR_SUP_SEQNR_START; 463 463 464 - init_timer(&hsr->announce_timer); 465 - hsr->announce_timer.function = hsr_announce; 466 - hsr->announce_timer.data = (unsigned long) hsr; 464 + setup_timer(&hsr->announce_timer, hsr_announce, (unsigned long)hsr); 467 465 468 - init_timer(&hsr->prune_timer); 469 - hsr->prune_timer.function = hsr_prune_nodes; 470 - hsr->prune_timer.data = (unsigned long) hsr; 466 + setup_timer(&hsr->prune_timer, hsr_prune_nodes, (unsigned long)hsr); 471 467 472 468 ether_addr_copy(hsr->sup_multicast_addr, def_multicast_addr); 473 469 hsr->sup_multicast_addr[ETH_ALEN - 1] = multicast_spec; ··· 498 502 if (res) 499 503 goto fail; 500 504 501 - hsr->prune_timer.expires = jiffies + msecs_to_jiffies(PRUNE_PERIOD); 502 - add_timer(&hsr->prune_timer); 505 + mod_timer(&hsr->prune_timer, jiffies + msecs_to_jiffies(PRUNE_PERIOD)); 503 506 504 507 return 0; 505 508