1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef UFDT_PROP_DICT_H
18 #define UFDT_PROP_DICT_H
19 
20 struct fdt_property;
21 
22 struct ufdt_prop_dict {
23   int mem_size;
24   int num_used;
25   void *fdtp;
26   const struct fdt_property **props;
27 };
28 
29 /*
30  * Allocates some new spaces and creates a new ufdt_prop_dict.
31  *
32  * @return: a pointer to the newly created ufdt_prop_dict or
33  *          NULL if dto_malloc failed
34  */
35 int ufdt_prop_dict_construct(struct ufdt_prop_dict *dict, void *fdtp);
36 
37 /*
38  * Frees all space dto_malloced, not including ufdt_nodes in the table.
39  */
40 void ufdt_prop_dict_destruct(struct ufdt_prop_dict *dict);
41 
42 /*
43  * Adds a fdt_property (as pointer) to the ufdt_prop_dict.
44  * @return: 0 if success
45  *          < 0 otherwise
46  *
47  * @Time: O(length of node->name)
48  */
49 int ufdt_prop_dict_add(struct ufdt_prop_dict *dict,
50                        const struct fdt_property *prop);
51 
52 /*
53  * Returns the pointer to the fdt_property with name
54  *
55  * @return: a pointer to the node or
56  *          NULL if no such node in ufdt_prop_dict with same name.
57  *
58  * @Time: O(len = |name|)
59  */
60 const struct fdt_property *ufdt_prop_dict_find(const struct ufdt_prop_dict *dict,
61                                                const char *name);
62 
63 #endif
64