]>
Commit | Line | Data |
---|---|---|
fea05a26 | 1 | /* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */ |
1da177e4 LT |
2 | /* |
3 | * aoemain.c | |
4 | * Module initialization routines, discover timer | |
5 | */ | |
6 | ||
7 | #include <linux/hdreg.h> | |
8 | #include <linux/blkdev.h> | |
9 | #include <linux/module.h> | |
e9bb8fb0 | 10 | #include <linux/skbuff.h> |
1da177e4 LT |
11 | #include "aoe.h" |
12 | ||
13 | MODULE_LICENSE("GPL"); | |
14 | MODULE_AUTHOR("Sam Hopkins <sah@coraid.com>"); | |
02edb05e | 15 | MODULE_DESCRIPTION("AoE block/char driver for 2.6.2 and newer 2.6 kernels"); |
1da177e4 LT |
16 | MODULE_VERSION(VERSION); |
17 | ||
5ea22086 | 18 | static struct timer_list timer; |
1da177e4 | 19 | |
5ea22086 | 20 | static void discover_timer(struct timer_list *t) |
1da177e4 | 21 | { |
5ea22086 | 22 | mod_timer(t, jiffies + HZ * 60); /* one minute */ |
1da177e4 | 23 | |
5ea22086 | 24 | aoecmd_cfg(0xffff, 0xff); |
1da177e4 LT |
25 | } |
26 | ||
e7cc005f | 27 | static void __exit |
1da177e4 LT |
28 | aoe_exit(void) |
29 | { | |
5ea22086 | 30 | del_timer_sync(&timer); |
1da177e4 LT |
31 | |
32 | aoenet_exit(); | |
33 | unregister_blkdev(AOE_MAJOR, DEVICE_NAME); | |
896831f5 | 34 | aoecmd_exit(); |
1da177e4 LT |
35 | aoechr_exit(); |
36 | aoedev_exit(); | |
37 | aoeblk_exit(); /* free cache after de-allocating bufs */ | |
38 | } | |
39 | ||
40 | static int __init | |
41 | aoe_init(void) | |
42 | { | |
43 | int ret; | |
44 | ||
45 | ret = aoedev_init(); | |
46 | if (ret) | |
47 | return ret; | |
48 | ret = aoechr_init(); | |
49 | if (ret) | |
50 | goto chr_fail; | |
51 | ret = aoeblk_init(); | |
52 | if (ret) | |
53 | goto blk_fail; | |
54 | ret = aoenet_init(); | |
55 | if (ret) | |
56 | goto net_fail; | |
896831f5 EC |
57 | ret = aoecmd_init(); |
58 | if (ret) | |
59 | goto cmd_fail; | |
1da177e4 LT |
60 | ret = register_blkdev(AOE_MAJOR, DEVICE_NAME); |
61 | if (ret < 0) { | |
a12c93f0 | 62 | printk(KERN_ERR "aoe: can't register major\n"); |
1da177e4 LT |
63 | goto blkreg_fail; |
64 | } | |
a12c93f0 | 65 | printk(KERN_INFO "aoe: AoE v%s initialised.\n", VERSION); |
5ea22086 KC |
66 | |
67 | timer_setup(&timer, discover_timer, 0); | |
68 | discover_timer(&timer); | |
1da177e4 | 69 | return 0; |
1da177e4 | 70 | blkreg_fail: |
896831f5 EC |
71 | aoecmd_exit(); |
72 | cmd_fail: | |
1da177e4 LT |
73 | aoenet_exit(); |
74 | net_fail: | |
75 | aoeblk_exit(); | |
76 | blk_fail: | |
77 | aoechr_exit(); | |
78 | chr_fail: | |
79 | aoedev_exit(); | |
a04b41cd | 80 | |
a12c93f0 | 81 | printk(KERN_INFO "aoe: initialisation failure.\n"); |
1da177e4 LT |
82 | return ret; |
83 | } | |
84 | ||
85 | module_init(aoe_init); | |
86 | module_exit(aoe_exit); | |
87 |