Skip to content

Commit 3d2ceaa

Browse files
keesdavem330
authored andcommitted
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 <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 847f03e commit 3d2ceaa

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

drivers/atm/idt77252.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,21 +2073,19 @@ idt77252_rate_logindex(struct idt77252_dev *card, int pcr)
20732073
}
20742074

20752075
static void
2076-
idt77252_est_timer(unsigned long data)
2076+
idt77252_est_timer(struct timer_list *t)
20772077
{
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;
20792080
struct idt77252_dev *card = vc->card;
2080-
struct rate_estimator *est;
20812081
unsigned long flags;
20822082
u32 rate, cps;
20832083
u64 ncells;
20842084
u8 lacr;
20852085

20862086
spin_lock_irqsave(&vc->lock, flags);
2087-
est = vc->estimator;
2088-
if (!est)
2087+
if (!vc->estimator)
20892088
goto out;
2090-
20912089
ncells = est->cells;
20922090

20932091
rate = ((u32)(ncells - est->last_cells)) << (7 - est->interval);
@@ -2126,10 +2124,11 @@ idt77252_init_est(struct vc_map *vc, int pcr)
21262124
est->maxcps = pcr < 0 ? -pcr : pcr;
21272125
est->cps = est->maxcps;
21282126
est->avcps = est->cps << 5;
2127+
est->vc = vc;
21292128

21302129
est->interval = 2; /* XXX: make this configurable */
21312130
est->ewma_log = 2; /* XXX: make this configurable */
2132-
setup_timer(&est->timer, idt77252_est_timer, (unsigned long)vc);
2131+
timer_setup(&est->timer, idt77252_est_timer, 0);
21332132
mod_timer(&est->timer, jiffies + ((HZ / 4) << est->interval));
21342133

21352134
return est;
@@ -2209,16 +2208,20 @@ static int
22092208
idt77252_init_ubr(struct idt77252_dev *card, struct vc_map *vc,
22102209
struct atm_vcc *vcc, struct atm_qos *qos)
22112210
{
2211+
struct rate_estimator *est = NULL;
22122212
unsigned long flags;
22132213
int tcr;
22142214

22152215
spin_lock_irqsave(&vc->lock, flags);
22162216
if (vc->estimator) {
2217-
del_timer(&vc->estimator->timer);
2218-
kfree(vc->estimator);
2217+
est = vc->estimator;
22192218
vc->estimator = NULL;
22202219
}
22212220
spin_unlock_irqrestore(&vc->lock, flags);
2221+
if (est) {
2222+
del_timer_sync(&est->timer);
2223+
kfree(est);
2224+
}
22222225

22232226
tcr = atm_pcr_goal(&qos->txtp);
22242227
if (tcr == 0)

drivers/atm/idt77252.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ struct aal1 {
184184
unsigned char sequence;
185185
};
186186

187+
struct vc_map;
188+
187189
struct rate_estimator {
188190
struct timer_list timer;
189191
unsigned int interval;
@@ -193,6 +195,7 @@ struct rate_estimator {
193195
long avcps;
194196
u32 cps;
195197
u32 maxcps;
198+
struct vc_map *vc;
196199
};
197200

198201
struct vc_map {

0 commit comments

Comments
 (0)