[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>
This commit is contained in:
committed by
David S. Miller
parent
a92aa318b4
commit
b24b8a247f
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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_sock_timeout, (unsigned long)sk);
|
||||
|
||||
bt_sock_link(&sco_sk_list, sk);
|
||||
return sk;
|
||||
|
Reference in New Issue
Block a user