diff options
author | Kees Cook <keescook@chromium.org> | 2017-08-30 17:53:24 -0400 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2017-11-06 15:50:09 -0500 |
commit | 5ea22086ed42bef8dde93f45a42a3ace486eb788 (patch) | |
tree | 3fb75d197d16d63878fdb4a478e9f6a555a95f80 /drivers | |
parent | 10738ba8e02bc8cb1c4e832611621aa9666f4a24 (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/aoe/aoemain.c | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/drivers/block/aoe/aoemain.c b/drivers/block/aoe/aoemain.c index 4b987c2fefbe..251482066977 100644 --- a/drivers/block/aoe/aoemain.c +++ b/drivers/block/aoe/aoemain.c | |||
@@ -15,49 +15,19 @@ MODULE_AUTHOR("Sam Hopkins <sah@coraid.com>"); | |||
15 | MODULE_DESCRIPTION("AoE block/char driver for 2.6.2 and newer 2.6 kernels"); | 15 | MODULE_DESCRIPTION("AoE block/char driver for 2.6.2 and newer 2.6 kernels"); |
16 | MODULE_VERSION(VERSION); | 16 | MODULE_VERSION(VERSION); |
17 | 17 | ||
18 | enum { TINIT, TRUN, TKILL }; | 18 | static struct timer_list timer; |
19 | 19 | ||
20 | static void | 20 | static void discover_timer(struct timer_list *t) |
21 | discover_timer(ulong vp) | ||
22 | { | 21 | { |
23 | static struct timer_list t; | 22 | mod_timer(t, jiffies + HZ * 60); /* one minute */ |
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); | ||
50 | 23 | ||
51 | del_timer_sync(&t); | 24 | aoecmd_cfg(0xffff, 0xff); |
52 | default: | ||
53 | return; | ||
54 | } | ||
55 | } | 25 | } |
56 | 26 | ||
57 | static void | 27 | static void |
58 | aoe_exit(void) | 28 | aoe_exit(void) |
59 | { | 29 | { |
60 | discover_timer(TKILL); | 30 | del_timer_sync(&timer); |
61 | 31 | ||
62 | aoenet_exit(); | 32 | aoenet_exit(); |
63 | unregister_blkdev(AOE_MAJOR, DEVICE_NAME); | 33 | unregister_blkdev(AOE_MAJOR, DEVICE_NAME); |
@@ -93,7 +63,9 @@ aoe_init(void) | |||
93 | goto blkreg_fail; | 63 | goto blkreg_fail; |
94 | } | 64 | } |
95 | printk(KERN_INFO "aoe: AoE v%s initialised.\n", VERSION); | 65 | 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); | ||
97 | return 0; | 69 | return 0; |
98 | blkreg_fail: | 70 | blkreg_fail: |
99 | aoecmd_exit(); | 71 | aoecmd_exit(); |