1 /* Copyright (c) 2004 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>
12 MODULE_LICENSE("GPL");
13 MODULE_AUTHOR("Sam Hopkins <sah@coraid.com>");
14 MODULE_DESCRIPTION("AoE block/char driver for 2.6.[0-9]+");
15 MODULE_VERSION(VERSION
);
17 enum { TINIT
, TRUN
, TKILL
};
20 discover_timer(ulong vp
)
22 static struct timer_list t
;
23 static volatile ulong die
;
24 static spinlock_t lock
;
26 enum { DTIMERTICK
= HZ
* 60 }; /* one minute */
31 spin_lock_init(&lock
);
33 t
.function
= discover_timer
;
36 spin_lock_irqsave(&lock
, flags
);
38 t
.expires
= jiffies
+ DTIMERTICK
;
41 spin_unlock_irqrestore(&lock
, flags
);
43 aoecmd_cfg(0xffff, 0xff);
46 spin_lock_irqsave(&lock
, flags
);
48 spin_unlock_irqrestore(&lock
, flags
);
59 discover_timer(TKILL
);
62 unregister_blkdev(AOE_MAJOR
, DEVICE_NAME
);
65 aoeblk_exit(); /* free cache after de-allocating bufs */
85 ret
= register_blkdev(AOE_MAJOR
, DEVICE_NAME
);
87 printk(KERN_ERR
"aoe: aoeblk_init: can't register major\n");
92 "aoe: aoe_init: AoE v2.6-%s initialised.\n",
94 discover_timer(TINIT
);
106 printk(KERN_INFO
"aoe: aoe_init: initialisation failure.\n");
110 module_init(aoe_init
);
111 module_exit(aoe_exit
);