Commit d26c089e authored by Kees Cook's avatar Kees Cook Committed by David S. Miller

hdlc: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly. This adds a pointer back to the
net_device, and drops needless open-coded resetting of the .function and
.data fields.

Cc: David S. Miller <davem@davemloft.net>
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Cc: netdev@vger.kernel.org
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9f12a77e
...@@ -54,6 +54,7 @@ struct cisco_state { ...@@ -54,6 +54,7 @@ struct cisco_state {
cisco_proto settings; cisco_proto settings;
struct timer_list timer; struct timer_list timer;
struct net_device *dev;
spinlock_t lock; spinlock_t lock;
unsigned long last_poll; unsigned long last_poll;
int up; int up;
...@@ -257,11 +258,10 @@ static int cisco_rx(struct sk_buff *skb) ...@@ -257,11 +258,10 @@ static int cisco_rx(struct sk_buff *skb)
static void cisco_timer(unsigned long arg) static void cisco_timer(struct timer_list *t)
{ {
struct net_device *dev = (struct net_device *)arg; struct cisco_state *st = from_timer(st, t, timer);
hdlc_device *hdlc = dev_to_hdlc(dev); struct net_device *dev = st->dev;
struct cisco_state *st = state(hdlc);
spin_lock(&st->lock); spin_lock(&st->lock);
if (st->up && if (st->up &&
...@@ -276,8 +276,6 @@ static void cisco_timer(unsigned long arg) ...@@ -276,8 +276,6 @@ static void cisco_timer(unsigned long arg)
spin_unlock(&st->lock); spin_unlock(&st->lock);
st->timer.expires = jiffies + st->settings.interval * HZ; st->timer.expires = jiffies + st->settings.interval * HZ;
st->timer.function = cisco_timer;
st->timer.data = arg;
add_timer(&st->timer); add_timer(&st->timer);
} }
...@@ -293,7 +291,8 @@ static void cisco_start(struct net_device *dev) ...@@ -293,7 +291,8 @@ static void cisco_start(struct net_device *dev)
st->up = st->txseq = st->rxseq = 0; st->up = st->txseq = st->rxseq = 0;
spin_unlock_irqrestore(&st->lock, flags); spin_unlock_irqrestore(&st->lock, flags);
setup_timer(&st->timer, cisco_timer, (unsigned long)dev); st->dev = dev;
timer_setup(&st->timer, cisco_timer, 0);
st->timer.expires = jiffies + HZ; /* First poll after 1 s */ st->timer.expires = jiffies + HZ; /* First poll after 1 s */
add_timer(&st->timer); add_timer(&st->timer);
} }
......
...@@ -140,6 +140,7 @@ struct frad_state { ...@@ -140,6 +140,7 @@ struct frad_state {
int dce_pvc_count; int dce_pvc_count;
struct timer_list timer; struct timer_list timer;
struct net_device *dev;
unsigned long last_poll; unsigned long last_poll;
int reliable; int reliable;
int dce_changed; int dce_changed;
...@@ -597,9 +598,10 @@ static void fr_set_link_state(int reliable, struct net_device *dev) ...@@ -597,9 +598,10 @@ static void fr_set_link_state(int reliable, struct net_device *dev)
} }
static void fr_timer(unsigned long arg) static void fr_timer(struct timer_list *t)
{ {
struct net_device *dev = (struct net_device *)arg; struct frad_state *st = from_timer(st, t, timer);
struct net_device *dev = st->dev;
hdlc_device *hdlc = dev_to_hdlc(dev); hdlc_device *hdlc = dev_to_hdlc(dev);
int i, cnt = 0, reliable; int i, cnt = 0, reliable;
u32 list; u32 list;
...@@ -644,8 +646,6 @@ static void fr_timer(unsigned long arg) ...@@ -644,8 +646,6 @@ static void fr_timer(unsigned long arg)
state(hdlc)->settings.t391 * HZ; state(hdlc)->settings.t391 * HZ;
} }
state(hdlc)->timer.function = fr_timer;
state(hdlc)->timer.data = arg;
add_timer(&state(hdlc)->timer); add_timer(&state(hdlc)->timer);
} }
...@@ -1003,8 +1003,8 @@ static void fr_start(struct net_device *dev) ...@@ -1003,8 +1003,8 @@ static void fr_start(struct net_device *dev)
state(hdlc)->n391cnt = 0; state(hdlc)->n391cnt = 0;
state(hdlc)->txseq = state(hdlc)->rxseq = 0; state(hdlc)->txseq = state(hdlc)->rxseq = 0;
setup_timer(&state(hdlc)->timer, fr_timer, state(hdlc)->dev = dev;
(unsigned long)dev); timer_setup(&state(hdlc)->timer, fr_timer, 0);
/* First poll after 1 s */ /* First poll after 1 s */
state(hdlc)->timer.expires = jiffies + HZ; state(hdlc)->timer.expires = jiffies + HZ;
add_timer(&state(hdlc)->timer); add_timer(&state(hdlc)->timer);
......
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