diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-01-24 00:20:07 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:53:35 -0500 |
commit | b24b8a247ff65c01b252025926fe564209fae4fc (patch) | |
tree | 8a9e0ea1e24b4733d8b9433d41877659505e9da4 /net/ipv4 | |
parent | a92aa318b4b369091fd80433c80e62838db8bc1c (diff) |
[NET]: Convert init_timer into setup_timer
Many-many code in the kernel initialized the timer->function
and timer->data together with calling init_timer(timer). There
is already a helper for this. Use it for networking code.
The patch is HUGE, but makes the code 130 lines shorter
(98 insertions(+), 228 deletions(-)).
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/igmp.c | 14 | ||||
-rw-r--r-- | net/ipv4/inet_connection_sock.c | 17 | ||||
-rw-r--r-- | net/ipv4/inet_fragment.c | 5 | ||||
-rw-r--r-- | net/ipv4/ipmr.c | 3 | ||||
-rw-r--r-- | net/ipv4/ipvs/ip_vs_conn.c | 4 | ||||
-rw-r--r-- | net/ipv4/ipvs/ip_vs_est.c | 3 | ||||
-rw-r--r-- | net/ipv4/ipvs/ip_vs_lblc.c | 5 | ||||
-rw-r--r-- | net/ipv4/ipvs/ip_vs_lblcr.c | 5 | ||||
-rw-r--r-- | net/ipv4/route.c | 6 |
9 files changed, 21 insertions, 41 deletions
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 7dbc282d4f9f..701558564e96 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -1234,9 +1234,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) | |||
1234 | spin_lock_init(&im->lock); | 1234 | spin_lock_init(&im->lock); |
1235 | #ifdef CONFIG_IP_MULTICAST | 1235 | #ifdef CONFIG_IP_MULTICAST |
1236 | im->tm_running=0; | 1236 | im->tm_running=0; |
1237 | init_timer(&im->timer); | 1237 | setup_timer(&im->timer, &igmp_timer_expire, (unsigned long)im); |
1238 | im->timer.data=(unsigned long)im; | ||
1239 | im->timer.function=&igmp_timer_expire; | ||
1240 | im->unsolicit_count = IGMP_Unsolicited_Report_Count; | 1238 | im->unsolicit_count = IGMP_Unsolicited_Report_Count; |
1241 | im->reporter = 0; | 1239 | im->reporter = 0; |
1242 | im->gsquery = 0; | 1240 | im->gsquery = 0; |
@@ -1338,13 +1336,11 @@ void ip_mc_init_dev(struct in_device *in_dev) | |||
1338 | in_dev->mc_tomb = NULL; | 1336 | in_dev->mc_tomb = NULL; |
1339 | #ifdef CONFIG_IP_MULTICAST | 1337 | #ifdef CONFIG_IP_MULTICAST |
1340 | in_dev->mr_gq_running = 0; | 1338 | in_dev->mr_gq_running = 0; |
1341 | init_timer(&in_dev->mr_gq_timer); | 1339 | setup_timer(&in_dev->mr_gq_timer, igmp_gq_timer_expire, |
1342 | in_dev->mr_gq_timer.data=(unsigned long) in_dev; | 1340 | (unsigned long)in_dev); |
1343 | in_dev->mr_gq_timer.function=&igmp_gq_timer_expire; | ||
1344 | in_dev->mr_ifc_count = 0; | 1341 | in_dev->mr_ifc_count = 0; |
1345 | init_timer(&in_dev->mr_ifc_timer); | 1342 | setup_timer(&in_dev->mr_ifc_timer, igmp_ifc_timer_expire, |
1346 | in_dev->mr_ifc_timer.data=(unsigned long) in_dev; | 1343 | (unsigned long)in_dev); |
1347 | in_dev->mr_ifc_timer.function=&igmp_ifc_timer_expire; | ||
1348 | in_dev->mr_qrv = IGMP_Unsolicited_Report_Count; | 1344 | in_dev->mr_qrv = IGMP_Unsolicited_Report_Count; |
1349 | #endif | 1345 | #endif |
1350 | 1346 | ||
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 8fb6ca23700a..1c2a32f6bfc4 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -277,18 +277,11 @@ void inet_csk_init_xmit_timers(struct sock *sk, | |||
277 | { | 277 | { |
278 | struct inet_connection_sock *icsk = inet_csk(sk); | 278 | struct inet_connection_sock *icsk = inet_csk(sk); |
279 | 279 | ||
280 | init_timer(&icsk->icsk_retransmit_timer); | 280 | setup_timer(&icsk->icsk_retransmit_timer, retransmit_handler, |
281 | init_timer(&icsk->icsk_delack_timer); | 281 | (unsigned long)sk); |
282 | init_timer(&sk->sk_timer); | 282 | setup_timer(&icsk->icsk_delack_timer, delack_handler, |
283 | 283 | (unsigned long)sk); | |
284 | icsk->icsk_retransmit_timer.function = retransmit_handler; | 284 | setup_timer(&sk->sk_timer, keepalive_handler, (unsigned long)sk); |
285 | icsk->icsk_delack_timer.function = delack_handler; | ||
286 | sk->sk_timer.function = keepalive_handler; | ||
287 | |||
288 | icsk->icsk_retransmit_timer.data = | ||
289 | icsk->icsk_delack_timer.data = | ||
290 | sk->sk_timer.data = (unsigned long)sk; | ||
291 | |||
292 | icsk->icsk_pending = icsk->icsk_ack.pending = 0; | 285 | icsk->icsk_pending = icsk->icsk_ack.pending = 0; |
293 | } | 286 | } |
294 | 287 | ||
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index e15e04fc6661..737910767ff1 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c | |||
@@ -66,9 +66,8 @@ void inet_frags_init(struct inet_frags *f) | |||
66 | f->nqueues = 0; | 66 | f->nqueues = 0; |
67 | atomic_set(&f->mem, 0); | 67 | atomic_set(&f->mem, 0); |
68 | 68 | ||
69 | init_timer(&f->secret_timer); | 69 | setup_timer(&f->secret_timer, inet_frag_secret_rebuild, |
70 | f->secret_timer.function = inet_frag_secret_rebuild; | 70 | (unsigned long)f); |
71 | f->secret_timer.data = (unsigned long)f; | ||
72 | f->secret_timer.expires = jiffies + f->ctl->secret_interval; | 71 | f->secret_timer.expires = jiffies + f->ctl->secret_interval; |
73 | add_timer(&f->secret_timer); | 72 | add_timer(&f->secret_timer); |
74 | } | 73 | } |
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 37bb497d92af..ba6c23cdf47b 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -1889,8 +1889,7 @@ void __init ip_mr_init(void) | |||
1889 | sizeof(struct mfc_cache), | 1889 | sizeof(struct mfc_cache), |
1890 | 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, | 1890 | 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, |
1891 | NULL); | 1891 | NULL); |
1892 | init_timer(&ipmr_expire_timer); | 1892 | setup_timer(&ipmr_expire_timer, ipmr_expire_process, 0); |
1893 | ipmr_expire_timer.function=ipmr_expire_process; | ||
1894 | register_netdevice_notifier(&ip_mr_notifier); | 1893 | register_netdevice_notifier(&ip_mr_notifier); |
1895 | #ifdef CONFIG_PROC_FS | 1894 | #ifdef CONFIG_PROC_FS |
1896 | proc_net_fops_create(&init_net, "ip_mr_vif", 0, &ipmr_vif_fops); | 1895 | proc_net_fops_create(&init_net, "ip_mr_vif", 0, &ipmr_vif_fops); |
diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c index 0a9f3c37e18d..a22cee43ed7c 100644 --- a/net/ipv4/ipvs/ip_vs_conn.c +++ b/net/ipv4/ipvs/ip_vs_conn.c | |||
@@ -629,9 +629,7 @@ ip_vs_conn_new(int proto, __be32 caddr, __be16 cport, __be32 vaddr, __be16 vport | |||
629 | } | 629 | } |
630 | 630 | ||
631 | INIT_LIST_HEAD(&cp->c_list); | 631 | INIT_LIST_HEAD(&cp->c_list); |
632 | init_timer(&cp->timer); | 632 | setup_timer(&cp->timer, ip_vs_conn_expire, (unsigned long)cp); |
633 | cp->timer.data = (unsigned long)cp; | ||
634 | cp->timer.function = ip_vs_conn_expire; | ||
635 | cp->protocol = proto; | 633 | cp->protocol = proto; |
636 | cp->caddr = caddr; | 634 | cp->caddr = caddr; |
637 | cp->cport = cport; | 635 | cp->cport = cport; |
diff --git a/net/ipv4/ipvs/ip_vs_est.c b/net/ipv4/ipvs/ip_vs_est.c index 7d68b80c4c19..efdd74e4fa28 100644 --- a/net/ipv4/ipvs/ip_vs_est.c +++ b/net/ipv4/ipvs/ip_vs_est.c | |||
@@ -146,9 +146,8 @@ int ip_vs_new_estimator(struct ip_vs_stats *stats) | |||
146 | write_lock_bh(&est_lock); | 146 | write_lock_bh(&est_lock); |
147 | est->next = est_list; | 147 | est->next = est_list; |
148 | if (est->next == NULL) { | 148 | if (est->next == NULL) { |
149 | init_timer(&est_timer); | 149 | setup_timer(&est_timer, estimation_timer, 0); |
150 | est_timer.expires = jiffies + 2*HZ; | 150 | est_timer.expires = jiffies + 2*HZ; |
151 | est_timer.function = estimation_timer; | ||
152 | add_timer(&est_timer); | 151 | add_timer(&est_timer); |
153 | } | 152 | } |
154 | est_list = est; | 153 | est_list = est; |
diff --git a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c index ad89644ef5d2..bf8c04a57548 100644 --- a/net/ipv4/ipvs/ip_vs_lblc.c +++ b/net/ipv4/ipvs/ip_vs_lblc.c | |||
@@ -391,9 +391,8 @@ static int ip_vs_lblc_init_svc(struct ip_vs_service *svc) | |||
391 | /* | 391 | /* |
392 | * Hook periodic timer for garbage collection | 392 | * Hook periodic timer for garbage collection |
393 | */ | 393 | */ |
394 | init_timer(&tbl->periodic_timer); | 394 | setup_timer(&tbl->periodic_timer, ip_vs_lblc_check_expire, |
395 | tbl->periodic_timer.data = (unsigned long)tbl; | 395 | (unsigned long)tbl); |
396 | tbl->periodic_timer.function = ip_vs_lblc_check_expire; | ||
397 | tbl->periodic_timer.expires = jiffies+CHECK_EXPIRE_INTERVAL; | 396 | tbl->periodic_timer.expires = jiffies+CHECK_EXPIRE_INTERVAL; |
398 | add_timer(&tbl->periodic_timer); | 397 | add_timer(&tbl->periodic_timer); |
399 | 398 | ||
diff --git a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c index 2a5ed85a3352..f50da6411378 100644 --- a/net/ipv4/ipvs/ip_vs_lblcr.c +++ b/net/ipv4/ipvs/ip_vs_lblcr.c | |||
@@ -575,9 +575,8 @@ static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc) | |||
575 | /* | 575 | /* |
576 | * Hook periodic timer for garbage collection | 576 | * Hook periodic timer for garbage collection |
577 | */ | 577 | */ |
578 | init_timer(&tbl->periodic_timer); | 578 | setup_timer(&tbl->periodic_timer, ip_vs_lblcr_check_expire, |
579 | tbl->periodic_timer.data = (unsigned long)tbl; | 579 | (unsigned long)tbl); |
580 | tbl->periodic_timer.function = ip_vs_lblcr_check_expire; | ||
581 | tbl->periodic_timer.expires = jiffies+CHECK_EXPIRE_INTERVAL; | 580 | tbl->periodic_timer.expires = jiffies+CHECK_EXPIRE_INTERVAL; |
582 | add_timer(&tbl->periodic_timer); | 581 | add_timer(&tbl->periodic_timer); |
583 | 582 | ||
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 28484f396b04..49e008568ddf 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2964,10 +2964,8 @@ int __init ip_rt_init(void) | |||
2964 | devinet_init(); | 2964 | devinet_init(); |
2965 | ip_fib_init(); | 2965 | ip_fib_init(); |
2966 | 2966 | ||
2967 | init_timer(&rt_flush_timer); | 2967 | setup_timer(&rt_flush_timer, rt_run_flush, 0); |
2968 | rt_flush_timer.function = rt_run_flush; | 2968 | setup_timer(&rt_secret_timer, rt_secret_rebuild, 0); |
2969 | init_timer(&rt_secret_timer); | ||
2970 | rt_secret_timer.function = rt_secret_rebuild; | ||
2971 | 2969 | ||
2972 | /* All the timers, started at system startup tend | 2970 | /* All the timers, started at system startup tend |
2973 | to synchronize. Perturb it a bit. | 2971 | to synchronize. Perturb it a bit. |