• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 /* ****************************************************************************
20   1 头文件包含
21 **************************************************************************** */
22 #include "oal_kernel_file.h"
23 
24 #ifdef __cplusplus
25 #if __cplusplus
26 extern "C" {
27 #endif
28 #endif
29 
30 /* ****************************************************************************
31   2 全局变量定义
32 **************************************************************************** */
33 #ifdef _PRE_CONFIG_CONN_HISI_SYSFS_SUPPORT
34 static oal_kobject *g_conn_syfs_root_object = HI_NULL;
35 static oal_kobject *g_conn_syfs_root_boot_object = HI_NULL;
36 
oal_get_sysfs_root_object(hi_void)37 oal_kobject *oal_get_sysfs_root_object(hi_void)
38 {
39     if (g_conn_syfs_root_object != HI_NULL)
40         return g_conn_syfs_root_object;
41     g_conn_syfs_root_object = kobject_create_and_add("hisys", HI_NULL);
42     return g_conn_syfs_root_object;
43 }
44 
oal_get_sysfs_root_boot_object(hi_void)45 oal_kobject *oal_get_sysfs_root_boot_object(hi_void)
46 {
47     static oal_kobject *root_boot_object = HI_NULL;
48     if (g_conn_syfs_root_boot_object != HI_NULL)
49         return g_conn_syfs_root_boot_object;
50     root_boot_object = oal_get_sysfs_root_object();
51     if (root_boot_object == HI_NULL)
52         return HI_NULL;
53     g_conn_syfs_root_boot_object = kobject_create_and_add("boot", root_boot_object);
54     return g_conn_syfs_root_boot_object;
55 }
56 
oal_conn_sysfs_root_obj_init(hi_void)57 oal_kobject *oal_conn_sysfs_root_obj_init(hi_void)
58 {
59     return oal_get_sysfs_root_object();
60 }
61 
oal_conn_sysfs_root_obj_exit(hi_void)62 hi_void oal_conn_sysfs_root_obj_exit(hi_void)
63 {
64     if (g_conn_syfs_root_object != HI_NULL) {
65         kobject_put(g_conn_syfs_root_object);
66         g_conn_syfs_root_object = HI_NULL;
67     }
68 }
69 
oal_conn_sysfs_root_boot_obj_exit(hi_void)70 hi_void oal_conn_sysfs_root_boot_obj_exit(hi_void)
71 {
72     if (g_conn_syfs_root_boot_object != HI_NULL) {
73         kobject_del(g_conn_syfs_root_boot_object);
74         g_conn_syfs_root_boot_object = HI_NULL;
75     }
76 }
77 
78 #else
79 oal_kobject *oal_get_sysfs_root_object(hi_void)
80 {
81     return HI_NULL;
82 }
83 
84 oal_kobject *oal_conn_sysfs_root_obj_init(hi_void)
85 {
86     return HI_NULL;
87 }
88 
89 hi_void oal_conn_sysfs_root_obj_exit(hi_void)
90 {
91     return;
92 }
93 
94 hi_void oal_conn_sysfs_root_boot_obj_exit(hi_void)
95 {
96     return;
97 }
98 #endif
99 
100 #ifdef __cplusplus
101 #if __cplusplus
102 }
103 #endif
104 #endif
105