summaryrefslogtreecommitdiffstats
path: root/include/linux/module_compat.h
blob: 766cb58ea443eeca7abcf5cf94e61f2ae4d2ab78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef _SPL_MODULE_COMPAT_H
#define _SPL_MODULE_COMPAT_H

#include <linux/module.h>

#define spl_module_init(init_fn)                                        \
static int                                                              \
spl_##init_fn(void)                                                     \
{                                                                       \
	int rc;                                                         \
	                                                                \
	spl_setup();                                                    \
	rc = init_fn();                                                 \
                                                                        \
	return rc;                                                      \
}                                                                       \
                                                                        \
module_init(spl_##init_fn)

#define spl_module_exit(exit_fn)                                        \
static void                                                             \
spl_##exit_fn(void)                                                     \
{                                                                       \
	int rc;                                                         \
                                                                        \
	rc = exit_fn();                                                 \
	spl_cleanup();                                                  \
	if (rc)                                                         \
		printk(KERN_ERR "SPL: Failure %d unloading "            \
		       "dependent module\n", rc);                       \
}                                                                       \
                                                                        \
module_exit(spl_##exit_fn)

#endif /* _SPL_MODULE_COMPAT_H */