Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

atm: idt77252: 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 required adding a pointer back
to vc_map, and adjusting the locking around removal a bit.

Cc: Chas Williams <3chas3@gmail.com>
Cc: linux-atm-general@lists.sourceforge.net
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Kees Cook and committed by
David S. Miller
3d2ceaa6 847f03ee

+15 -9
+12 -9
drivers/atm/idt77252.c
··· 2073 2073 } 2074 2074 2075 2075 static void 2076 - idt77252_est_timer(unsigned long data) 2076 + idt77252_est_timer(struct timer_list *t) 2077 2077 { 2078 - struct vc_map *vc = (struct vc_map *)data; 2078 + struct rate_estimator *est = from_timer(est, t, timer); 2079 + struct vc_map *vc = est->vc; 2079 2080 struct idt77252_dev *card = vc->card; 2080 - struct rate_estimator *est; 2081 2081 unsigned long flags; 2082 2082 u32 rate, cps; 2083 2083 u64 ncells; 2084 2084 u8 lacr; 2085 2085 2086 2086 spin_lock_irqsave(&vc->lock, flags); 2087 - est = vc->estimator; 2088 - if (!est) 2087 + if (!vc->estimator) 2089 2088 goto out; 2090 - 2091 2089 ncells = est->cells; 2092 2090 2093 2091 rate = ((u32)(ncells - est->last_cells)) << (7 - est->interval); ··· 2124 2126 est->maxcps = pcr < 0 ? -pcr : pcr; 2125 2127 est->cps = est->maxcps; 2126 2128 est->avcps = est->cps << 5; 2129 + est->vc = vc; 2127 2130 2128 2131 est->interval = 2; /* XXX: make this configurable */ 2129 2132 est->ewma_log = 2; /* XXX: make this configurable */ 2130 - setup_timer(&est->timer, idt77252_est_timer, (unsigned long)vc); 2133 + timer_setup(&est->timer, idt77252_est_timer, 0); 2131 2134 mod_timer(&est->timer, jiffies + ((HZ / 4) << est->interval)); 2132 2135 2133 2136 return est; ··· 2208 2209 idt77252_init_ubr(struct idt77252_dev *card, struct vc_map *vc, 2209 2210 struct atm_vcc *vcc, struct atm_qos *qos) 2210 2211 { 2212 + struct rate_estimator *est = NULL; 2211 2213 unsigned long flags; 2212 2214 int tcr; 2213 2215 2214 2216 spin_lock_irqsave(&vc->lock, flags); 2215 2217 if (vc->estimator) { 2216 - del_timer(&vc->estimator->timer); 2217 - kfree(vc->estimator); 2218 + est = vc->estimator; 2218 2219 vc->estimator = NULL; 2219 2220 } 2220 2221 spin_unlock_irqrestore(&vc->lock, flags); 2222 + if (est) { 2223 + del_timer_sync(&est->timer); 2224 + kfree(est); 2225 + } 2221 2226 2222 2227 tcr = atm_pcr_goal(&qos->txtp); 2223 2228 if (tcr == 0)
+3
drivers/atm/idt77252.h
··· 184 184 unsigned char sequence; 185 185 }; 186 186 187 + struct vc_map; 188 + 187 189 struct rate_estimator { 188 190 struct timer_list timer; 189 191 unsigned int interval; ··· 195 193 long avcps; 196 194 u32 cps; 197 195 u32 maxcps; 196 + struct vc_map *vc; 198 197 }; 199 198 200 199 struct vc_map {