-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
54 lines (43 loc) · 1.47 KB
/
main.c
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* SPDX-License-Identifier: GPL-2.0 */
#include <linux/module.h>
#include "main.h"
#include "features.h"
/* Import all the symbol namespaces that appear to be defined in the kernel
* sources so that we won't trigger any warning
*/
#include "generated/symbol_namespaces.h"
static char *features[MAX_FEATURES];
unsigned int features_len = 0;
module_param_array(features, charp, &features_len, 0);
MODULE_PARM_DESC(features, "Comma-separated list of features to enable. Available features are printed when loading the module");
static void modexit(void) {
if (deinit_features())
pr_err("Some errors happened while unloading LISA kernel module\n");
}
static int __init modinit(void) {
int ret;
ret = init_features(features, features_len);
if (ret) {
pr_err("Some errors happened while loading LISA kernel module\n");
/* Use one of the standard error code */
ret = -EINVAL;
/* If the user selected features manually, make module loading fail so
* that they are aware that things went wrong. Otherwise, just
* keep going as the user just wanted to enable as many features
* as possible.
*/
if (features_len) {
/* Call modexit() explicitly, since it will not be called when ret != 0.
* Not calling modexit() can (and will) result in kernel panic handlers
* installed by the module are not deregistered before the module code
* vanishes.
*/
modexit();
return ret;
}
}
return 0;
}
module_init(modinit);
module_exit(modexit);
MODULE_LICENSE("GPL");