Skip to content

Commit 5ea2208

Browse files
committed
block/aoe: discover_timer: 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 refactors the discover_timer to remove the needless locking and state machine used for synchronizing timer death. Using del_timer_sync() will already do the right thing. Cc: Jens Axboe <axboe@kernel.dk> Cc: "Ed L. Cashin" <ed.cashin@acm.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent 10738ba commit 5ea2208

1 file changed

Lines changed: 8 additions & 36 deletions

File tree

‎drivers/block/aoe/aoemain.c‎

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,49 +15,19 @@ MODULE_AUTHOR("Sam Hopkins <sah@coraid.com>");
1515
MODULE_DESCRIPTION("AoE block/char driver for 2.6.2 and newer 2.6 kernels");
1616
MODULE_VERSION(VERSION);
1717

18-
enum { TINIT, TRUN, TKILL };
18+
static struct timer_list timer;
1919

20-
static void
21-
discover_timer(ulong vp)
20+
static void discover_timer(struct timer_list *t)
2221
{
23-
static struct timer_list t;
24-
static volatile ulong die;
25-
static spinlock_t lock;
26-
ulong flags;
27-
enum { DTIMERTICK = HZ * 60 }; /* one minute */
28-
29-
switch (vp) {
30-
case TINIT:
31-
init_timer(&t);
32-
spin_lock_init(&lock);
33-
t.data = TRUN;
34-
t.function = discover_timer;
35-
die = 0;
36-
case TRUN:
37-
spin_lock_irqsave(&lock, flags);
38-
if (!die) {
39-
t.expires = jiffies + DTIMERTICK;
40-
add_timer(&t);
41-
}
42-
spin_unlock_irqrestore(&lock, flags);
43-
44-
aoecmd_cfg(0xffff, 0xff);
45-
return;
46-
case TKILL:
47-
spin_lock_irqsave(&lock, flags);
48-
die = 1;
49-
spin_unlock_irqrestore(&lock, flags);
22+
mod_timer(t, jiffies + HZ * 60); /* one minute */
5023

51-
del_timer_sync(&t);
52-
default:
53-
return;
54-
}
24+
aoecmd_cfg(0xffff, 0xff);
5525
}
5626

5727
static void
5828
aoe_exit(void)
5929
{
60-
discover_timer(TKILL);
30+
del_timer_sync(&timer);
6131

6232
aoenet_exit();
6333
unregister_blkdev(AOE_MAJOR, DEVICE_NAME);
@@ -93,7 +63,9 @@ aoe_init(void)
9363
goto blkreg_fail;
9464
}
9565
printk(KERN_INFO "aoe: AoE v%s initialised.\n", VERSION);
96-
discover_timer(TINIT);
66+
67+
timer_setup(&timer, discover_timer, 0);
68+
discover_timer(&timer);
9769
return 0;
9870
blkreg_fail:
9971
aoecmd_exit();

0 commit comments

Comments
 (0)