OpenVZ Forum


Home » Mailing lists » Devel » [PATCH][NET] Convert init_timer into setup_timer
[PATCH][NET] Convert init_timer into setup_timer [message #23140] Tue, 13 November 2007 13:10 Go to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
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>

---

 net/802/tr.c                     |    4 +---
 net/appletalk/aarp.c             |    4 +---
 net/appletalk/ddp.c              |    5 ++---
 net/atm/lec.c                    |    5 ++---
 net/ax25/af_ax25.c               |    5 ++---
 net/bluetooth/hci_conn.c         |    9 ++-------
 net/bluetooth/hidp/core.c        |    5 +----
 net/bluetooth/l2cap.c            |   13 ++-----------
 net/bluetooth/rfcomm/core.c      |    4 +---
 net/bluetooth/sco.c              |    9 +--------
 net/core/flow.c                  |    3 +--
 net/core/neighbour.c             |   12 +++---------
 net/dccp/ccids/ccid2.c           |    6 ++----
 net/dccp/ccids/ccid3.c           |    7 ++-----
 net/dccp/timer.c                 |    5 ++---
 net/decnet/dn_route.c            |    3 +--
 net/econet/af_econet.c           |    3 +--
 net/ieee80211/ieee80211_module.c |    5 ++---
 net/ipv4/igmp.c                  |   14 +++++---------
 net/ipv4/inet_connection_sock.c  |   17 +++++------------
 net/ipv4/inet_fragment.c         |    5 ++---
 net/ipv4/ipmr.c                  |    3 +--
 net/ipv4/ipvs/ip_vs_conn.c       |    4 +---
 net/ipv4/ipvs/ip_vs_est.c        |    3 +--
 net/ipv4/ipvs/ip_vs_lblc.c       |    5 ++---
 net/ipv4/ipvs/ip_vs_lblcr.c      |    5 ++---
 net/ipv4/route.c                 |    6 ++----
 net/ipv6/addrconf.c              |    4 +---
 net/ipv6/mcast.c                 |   14 +++++---------
 net/irda/af_irda.c               |    5 ++---
 net/iucv/af_iucv.c               |    9 +--------
 net/llc/llc_conn.c               |   20 ++++++++------------
 net/llc/llc_station.c            |    5 ++---
 net/mac80211/sta_info.c          |    5 ++---
 net/netrom/nr_timer.c            |   19 ++++---------------
 net/rose/af_rose.c               |    5 ++---
 net/sched/sch_generic.c          |    9 +--------
 net/sched/sch_sfq.c              |    4 +---
 net/sctp/associola.c             |    8 +++-----
 net/sctp/transport.c             |   13 ++++---------
 net/sunrpc/sched.c               |    5 ++---
 net/sunrpc/xprt.c                |    5 ++---
 net/tipc/core.h                  |    4 +---
 net/x25/x25_link.c               |    5 +----
 net/x25/x25_timer.c              |    4 +---
 net/xfrm/xfrm_policy.c           |    5 ++---
 net/xfrm/xfrm_state.c            |    9 +++------
 47 files changed, 98 insertions(+), 228 deletions(-)

diff --git a/net/802/tr.c b/net/802/tr.c
index a2bd0f2..d8a5386 100644
--- a/net/802/tr.c
+++ b/net/802/tr.c
@@ -641,10 +641,8 @@ struct net_device *alloc_trdev(int sizeof_priv)
 
 static int __init rif_init(void)
 {
-	init_timer(&rif_timer);
 	rif_timer.expires  = sysctl_tr_rif_timeout;
-	rif_timer.data     = 0L;
-	rif_timer.function = rif_check_expire;
+	setup_timer(&rif_timer, rif_check_expire, 0);
 	add_timer(&rif_timer);
 
 	proc_net_fops_create(&init_net, "tr_rif", S_IRUGO, &rif_seq_fops);
diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c
index 6c5c6dc..b950fb6 100644
--- a/net/appletalk/aarp.c
+++ b/net/appletalk/aarp.c
@@ -874,9 +874,7 @@ void __init aarp_proto_init(void)
 	aarp_dl = register_snap_client(aarp_snap_id, aarp_rcv);
 	if (!aarp_dl)
 		printk(KERN_CRIT "Unable to register AARP with SNAP.\n");
-	init_timer(&aarp_timer);
-	aarp_timer.function = aarp_expire_timeout;
-	aarp_timer.data	    = 0;
+	setup_timer(&aarp_timer, aarp_expire_timeout, 0);
 	aarp_timer.expires  = jiffies + sysctl_aarp_expiry_time;
 	add_timer(&aarp_timer);
 	register_netdevice_notifier(&aarp_notifier);
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index e0d37d6..3be55c8 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -177,10 +177,9 @@ static inline void atalk_destroy_socket(struct sock *sk)
 
 	if (atomic_read(&sk->sk_wmem_alloc) ||
 	    atomic_read(&sk->sk_rmem_alloc)) {
-		init_timer(&sk->sk_timer);
+		setup_timer(&sk->sk_timer, atalk_destroy_timer,
+				(unsigned long)sk);
 		sk->sk_timer.expires	= jiffies + SOCK_DESTROY_TIME;
-		sk->sk_timer.function	= atalk_destroy_timer;
-		sk->sk_timer.data	= (unsigned long)sk;
 		add_timer(&sk->sk_timer);
 	} else
 		sock_put(sk);
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 7eb1b21..0a9c426 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -1789,9 +1789,8 @@ static struct lec_arp_table *make_entry(struct lec_priv *priv,
 	}
 	memcpy(to_return->mac_addr, mac_addr, ETH_ALEN);
 	INIT_HLIST_NODE(&to_return->next);
-	init_timer(&to_return->timer);
-	to_return->timer.function = lec_arp_expire_arp;
-	to_return->timer.data = (unsigned long)to_return;
+	setup_timer(&to_return->timer, lec_arp_expire_arp,
+			(unsigned long)to_return);
 	to_return->last_used = jiffies;
 	to_return->priv = priv;
 	skb_queue_head_init(&to_return->tx_wait);
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 8378afd..95a19c5 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -318,10 +318,9 @@ void ax25_destroy_socket(ax25_cb *ax25)
 		if (atomic_read(&ax25->sk->sk_wmem_alloc) ||
 		    atomic_read(&ax25->sk->sk_rmem_alloc)) {
 			/* Defer: outstanding buffers */
-			init_timer(&ax25->dtimer);
+			setup_timer(&ax25->dtimer, ax25_destroy_timer,
+					(unsigned long)ax25);
 			ax25->dtimer.expires  = jiffies + 2 * HZ;
-			ax25->dtimer.function = ax25_destroy_timer;
-			ax25->dtimer.data     = (unsigned long)ax25;
 			add_timer(&ax25->dtimer);
 		} else {
 			struct sock *sk=ax25->sk;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 9483320..7099f74 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -208,13 +208,8 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
 
 	skb_queue_head_init(&conn->data_q);
 
-	init_timer(&conn->disc_timer);
-	conn->disc_timer.function = hci_conn_timeout;
-	conn->disc_timer.data = (unsigned long) conn;
-
-	init_timer(&conn->idle_timer);
-	conn->idle_timer.function = hci_conn_idle;
-	conn->idle_timer.data = (unsigned long) conn;
+	setup_timer(&conn->disc_timer, hci_conn_timeout, (unsigned long)conn);
+	setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn);
 
 	atomic_set(&conn->refcnt, 0);
 
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 4bbacdd..782a226 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -811,10 +811,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
 	session->intr_sock = intr_sock;
 	session->state     = BT_CONNECTED;
 
-	init_timer(&session->timer);
-
-	session->timer.function = hidp_idle_timeout;
-	session->timer.data     = (unsigned long) session;
+	setup_timer(&session->timer, hidp_idle_timeout, (unsigned long)session);
 
 	skb_queue_head_init(&session->ctrl_transmit);
 	skb_queue_head_init(&session->intr_transmit);
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 477e052..a8811c0 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -99,13 +99,6 @@ static void l2cap_sock_clear_timer(struct sock *sk)
 	sk_stop_timer(sk, &sk->sk_timer);
 }
 
-static void l2cap_sock_init_timer(struct sock *sk)
-{
-	init_timer(&sk->sk_timer);
-	sk->sk_timer.function = l2cap_sock_timeout;
-	sk->sk_timer.data = (unsigned long)sk;
-}
-
 /* ---- L2CAP channels ---- */
 static struct sock *__l2cap_get_chan_by_dcid(struct l2cap_chan_list *l, u16 cid)
 {
@@ -395,9 +388,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status)
 
 	conn->feat_mask = 0;
 
-	init_timer(&conn->info_timer);
-	conn->info_timer.function = l2cap_info_timeout;
-	conn->info_timer.data = (unsigned long) conn;
+	setup_timer(&conn->info_timer, l2cap_info_timeout, (unsigned long)conn);
 
 	spin_lock_init(&conn->lock);
 	rwlock_init(&conn->chan_list.lock);
@@ -622,7 +613,7 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p
 	sk->sk_protocol = proto;
 	sk->sk_state    = BT_OPEN;
 
-	l2cap_sock_init_timer(sk);
+	setup_timer(&sk->sk_timer, l2cap_sock_timeout, (unsigned long)sk);
 
 	bt_sock_link(&l2cap_sk_list, sk);
 	return sk;
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index e7ac6ba..d3e4e18 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -279,9 +279,7 @@ struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio)
 	if (!d)
 		return NULL;
 
-	init_timer(&d->timer);
-	d->timer.function = rfcomm_dlc_timeout;
-	d->timer.data = (unsigned long) d;
+	setup_timer(&d->timer, rfcomm_dlc_timeout, (unsigned long)d);
 
 	skb_queue_head_init(&d->tx_queue);
 	spin_lock_init(&d->lock);
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 93ad1aa..b91d3c8 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -97,13 +97,6 @@ static void sco_sock_clear_timer(struct sock *sk)
 	sk_stop_timer(sk, &sk->sk_timer);
 }
 
-static void sco_sock_init_timer(struct sock *sk)
-{
-	init_timer(&sk->sk_timer);
-	sk->sk_timer.function = sco_sock_timeout;
-	sk->sk_timer.data = (unsigned long)sk;
-}
-
 /* ---- SCO connections ---- */
 static struct sco_conn *sco_conn_add(struct hci_conn *hcon, __u8 status)
 {
@@ -436,7 +429,7 @@ static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int pro
 	sk->sk_protocol = proto;
 	sk->sk_state    = BT_OPEN;
 
-	sco_sock_init_timer(sk);
+	setup_timer(&sk->sk_timer, sco_s
...

Re: [PATCH][NET] Convert init_timer into setup_timer [message #23142 is a reply to message #23140] Tue, 13 November 2007 13:34 Go to previous messageGo to next message
davem is currently offline  davem
Messages: 463
Registered: February 2006
Senior Member
From: Pavel Emelyanov <xemul@openvz.org>
Date: Tue, 13 Nov 2007 16:10:03 +0300

> 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>

I have no objection to this patch, but it is 2.6.25
material for sure.
Re: [PATCH][NET] Convert init_timer into setup_timer [message #23143 is a reply to message #23142] Tue, 13 November 2007 13:43 Go to previous messageGo to next message
Arnaldo Carvalho de M is currently offline  Arnaldo Carvalho de M
Messages: 27
Registered: October 2007
Junior Member
Em Tue, Nov 13, 2007 at 05:34:21AM -0800, David Miller escreveu:
> From: Pavel Emelyanov <xemul@openvz.org>
> Date: Tue, 13 Nov 2007 16:10:03 +0300
> 
> > 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>
> 
> I have no objection to this patch, but it is 2.6.25
> material for sure.

Agreed, Pavel, if you want please stick:

Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

- Arnaldo
Re: [PATCH][NET] Convert init_timer into setup_timer [message #23144 is a reply to message #23143] Tue, 13 November 2007 14:02 Go to previous messageGo to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
Arnaldo Carvalho de Melo wrote:
> Em Tue, Nov 13, 2007 at 05:34:21AM -0800, David Miller escreveu:
>> From: Pavel Emelyanov <xemul@openvz.org>
>> Date: Tue, 13 Nov 2007 16:10:03 +0300
>>
>>> 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>
>> I have no objection to this patch, but it is 2.6.25
>> material for sure.

OK.

> Agreed, Pavel, if you want please stick:
> 
> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Thanks! :)

> - Arnaldo
>
Re: [PATCH][NET] Convert init_timer into setup_timer [message #23165 is a reply to message #23143] Wed, 14 November 2007 05:14 Go to previous message
davem is currently offline  davem
Messages: 463
Registered: February 2006
Senior Member
From: "Arnaldo Carvalho de Melo" <acme@redhat.com>
Date: Tue, 13 Nov 2007 11:43:40 -0200

> Em Tue, Nov 13, 2007 at 05:34:21AM -0800, David Miller escreveu:
> > From: Pavel Emelyanov <xemul@openvz.org>
> > Date: Tue, 13 Nov 2007 16:10:03 +0300
> > 
> > > 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>
> > 
> > I have no objection to this patch, but it is 2.6.25
> > material for sure.
> 
> Agreed, Pavel, if you want please stick:
> 
> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

No need, I've applied it to net-2.6.25 :-)
Previous Topic: [NETFILTER]: Unable to delete a SAME rule (Using SAME target problems)
Next Topic: [RFC][ for -mm] memory controller enhancements for NUMA [1/10] record nid/zid on page_cgroup
Goto Forum:
  


Current Time: Wed Feb 28 10:28:18 GMT 2024

Total time taken to generate the page: 0.02380 seconds