From 11286125326bb9d5e295c7c85fb1dc91ca2af46b Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Mon, 16 Oct 2017 17:29:26 -0700 Subject: [PATCH] isdnloop: 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. Added missing initialization for rb_timer. Cc: Karsten Keil Cc: "David S. Miller" Cc: Al Viro Cc: Stephen Hemminger Cc: Arnd Bergmann Cc: Johannes Berg Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: David S. Miller --- drivers/isdn/isdnloop/isdnloop.c | 33 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c index e97232646ba1..a4597e96c916 100644 --- a/drivers/isdn/isdnloop/isdnloop.c +++ b/drivers/isdn/isdnloop/isdnloop.c @@ -90,9 +90,9 @@ isdnloop_bchan_send(isdnloop_card *card, int ch) * data = pointer to card struct, set by kernel timer.data */ static void -isdnloop_pollbchan(unsigned long data) +isdnloop_pollbchan(struct timer_list *t) { - isdnloop_card *card = (isdnloop_card *) data; + isdnloop_card *card = from_timer(card, t, rb_timer); unsigned long flags; if (card->flags & ISDNLOOP_FLAGS_B1ACTIVE) @@ -305,9 +305,9 @@ isdnloop_putmsg(isdnloop_card *card, unsigned char c) * data = pointer to card struct */ static void -isdnloop_polldchan(unsigned long data) +isdnloop_polldchan(struct timer_list *t) { - isdnloop_card *card = (isdnloop_card *) data; + isdnloop_card *card = from_timer(card, t, st_timer); struct sk_buff *skb; int avail; int left; @@ -373,8 +373,6 @@ isdnloop_polldchan(unsigned long data) card->flags |= ISDNLOOP_FLAGS_RBTIMER; spin_lock_irqsave(&card->isdnloop_lock, flags); del_timer(&card->rb_timer); - card->rb_timer.function = isdnloop_pollbchan; - card->rb_timer.data = (unsigned long) card; card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD; add_timer(&card->rb_timer); spin_unlock_irqrestore(&card->isdnloop_lock, flags); @@ -588,9 +586,10 @@ isdnloop_atimeout(isdnloop_card *card, int ch) * Wrapper for isdnloop_atimeout(). */ static void -isdnloop_atimeout0(unsigned long data) +isdnloop_atimeout0(struct timer_list *t) { - isdnloop_card *card = (isdnloop_card *) data; + isdnloop_card *card = from_timer(card, t, c_timer[0]); + isdnloop_atimeout(card, 0); } @@ -598,9 +597,10 @@ isdnloop_atimeout0(unsigned long data) * Wrapper for isdnloop_atimeout(). */ static void -isdnloop_atimeout1(unsigned long data) +isdnloop_atimeout1(struct timer_list *t) { - isdnloop_card *card = (isdnloop_card *) data; + isdnloop_card *card = from_timer(card, t, c_timer[1]); + isdnloop_atimeout(card, 1); } @@ -617,13 +617,9 @@ isdnloop_start_ctimer(isdnloop_card *card, int ch) unsigned long flags; spin_lock_irqsave(&card->isdnloop_lock, flags); - init_timer(&card->c_timer[ch]); + timer_setup(&card->c_timer[ch], ch ? isdnloop_atimeout1 + : isdnloop_atimeout0, 0); card->c_timer[ch].expires = jiffies + ISDNLOOP_TIMER_ALERTWAIT; - if (ch) - card->c_timer[ch].function = isdnloop_atimeout1; - else - card->c_timer[ch].function = isdnloop_atimeout0; - card->c_timer[ch].data = (unsigned long) card; add_timer(&card->c_timer[ch]); spin_unlock_irqrestore(&card->isdnloop_lock, flags); } @@ -1113,10 +1109,9 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp) sdef.ptype); return -EINVAL; } - init_timer(&card->st_timer); + timer_setup(&card->rb_timer, isdnloop_pollbchan, 0); + timer_setup(&card->st_timer, isdnloop_polldchan, 0); card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD; - card->st_timer.function = isdnloop_polldchan; - card->st_timer.data = (unsigned long) card; add_timer(&card->st_timer); card->flags |= ISDNLOOP_FLAGS_RUNNING; spin_unlock_irqrestore(&card->isdnloop_lock, flags);