1 /* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */
4 * Module initialization routines, discover timer
7 #include <linux/hdreg.h>
8 #include <linux/blkdev.h>
9 #include <linux/module.h>
10 #include <linux/skbuff.h>
13 MODULE_LICENSE("GPL");
14 MODULE_AUTHOR("Sam Hopkins <sah@coraid.com>");
15 MODULE_DESCRIPTION("AoE block/char driver for 2.6.2 and newer 2.6 kernels");
16 MODULE_VERSION(VERSION
);
18 enum { TINIT
, TRUN
, TKILL
};
21 discover_timer(ulong vp
)
23 static struct timer_list t
;
24 static volatile ulong die
;
25 static spinlock_t lock
;
27 enum { DTIMERTICK
= HZ
* 60 }; /* one minute */
32 spin_lock_init(&lock
);
34 t
.function
= discover_timer
;
37 spin_lock_irqsave(&lock
, flags
);
39 t
.expires
= jiffies
+ DTIMERTICK
;
42 spin_unlock_irqrestore(&lock
, flags
);
44 aoecmd_cfg(0xffff, 0xff);
47 spin_lock_irqsave(&lock
, flags
);
49 spin_unlock_irqrestore(&lock
, flags
);
60 discover_timer(TKILL
);
63 unregister_blkdev(AOE_MAJOR
, DEVICE_NAME
);
66 aoeblk_exit(); /* free cache after de-allocating bufs */
86 ret
= register_blkdev(AOE_MAJOR
, DEVICE_NAME
);
88 printk(KERN_ERR
"aoe: can't register major\n");
92 printk(KERN_INFO
"aoe: AoE v%s initialised.\n", VERSION
);
93 discover_timer(TINIT
);
105 printk(KERN_INFO
"aoe: initialisation failure.\n");
109 module_init(aoe_init
);
110 module_exit(aoe_exit
);