• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2023 Huawei Device Co., Ltd.
4  */
5 
6 #include <linux/init.h>
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/types.h>
10 #include "xpm_log.h"
11 #include "xpm_hck.h"
12 #include "xpm_misc.h"
13 #include "xpm_report.h"
14 #include "xpm_debugfs.h"
15 
xpm_module_init(void)16 static int __init xpm_module_init(void)
17 {
18 	int ret;
19 
20 	ret = xpm_register_misc_device();
21 	if (ret) {
22 		xpm_log_error("xpm register misc device failed, ret = %d", ret);
23 		report_init_event(TYPE_DEVICEFS_UNINIT);
24 		return ret;
25 	}
26 
27 	ret = xpm_debugfs_init();
28 	if (ret) {
29 		xpm_log_error("xpm init debugfs failed, ret = %d", ret);
30 		xpm_deregister_misc_device();
31 		report_init_event(TYPE_DEBUGFS_UNINIT);
32 		return ret;
33 	}
34 
35 	xpm_register_xpm_hooks();
36 	xpm_register_hck_hooks();
37 
38 	xpm_log_info("xpm module init success");
39 	return 0;
40 }
41 
xpm_module_exit(void)42 static void __exit xpm_module_exit(void)
43 {
44 	xpm_deregister_misc_device();
45 	xpm_debugfs_exit();
46 	xpm_log_info("xpm module exit success");
47 }
48 
49 module_init(xpm_module_init);
50 module_exit(xpm_module_exit);
51 MODULE_LICENSE("GPL");
52