Lines Matching refs:dict
43 const struct ufdt_prop_dict *dict, const char *name) { in _ufdt_prop_dict_find_index_by_name() argument
46 int size = dict->mem_size; in _ufdt_prop_dict_find_index_by_name()
50 const struct fdt_property **prop_ptr = &dict->props[idx]; in _ufdt_prop_dict_find_index_by_name()
54 const char *prop_name = fdt_string(dict->fdtp, fdt32_to_cpu(prop->nameoff)); in _ufdt_prop_dict_find_index_by_name()
63 struct ufdt_prop_dict *dict, const struct fdt_property *prop) { in _ufdt_prop_dict_find_index() argument
64 const char *name = fdt_string(dict->fdtp, fdt32_to_cpu(prop->nameoff)); in _ufdt_prop_dict_find_index()
66 return _ufdt_prop_dict_find_index_by_name(dict, name); in _ufdt_prop_dict_find_index()
69 int _ufdt_prop_dict_construct_int(struct ufdt_prop_dict *dict, void *fdtp, in _ufdt_prop_dict_construct_int() argument
77 dict->mem_size = size; in _ufdt_prop_dict_construct_int()
78 dict->num_used = 0; in _ufdt_prop_dict_construct_int()
79 dict->fdtp = fdtp; in _ufdt_prop_dict_construct_int()
80 dict->props = props; in _ufdt_prop_dict_construct_int()
85 int ufdt_prop_dict_construct(struct ufdt_prop_dict *dict, void *fdtp) { in ufdt_prop_dict_construct() argument
86 return _ufdt_prop_dict_construct_int(dict, fdtp, UFDT_PROP_DICT_INIT_SZ); in ufdt_prop_dict_construct()
89 void ufdt_prop_dict_destruct(struct ufdt_prop_dict *dict) { in ufdt_prop_dict_destruct() argument
90 if (dict == NULL) return; in ufdt_prop_dict_destruct()
92 dto_free(dict->props); in ufdt_prop_dict_destruct()
95 static int _ufdt_prop_dict_enlarge_if_needed(struct ufdt_prop_dict *dict) { in _ufdt_prop_dict_enlarge_if_needed() argument
96 if (dict == NULL) return -1; in _ufdt_prop_dict_enlarge_if_needed()
99 if (dict->num_used * DICT_LIMIT_DEN <= dict->mem_size * DICT_LIMIT_NUM) { in _ufdt_prop_dict_enlarge_if_needed()
103 int new_size = dict->mem_size * 2; in _ufdt_prop_dict_enlarge_if_needed()
105 _ufdt_prop_dict_construct_int(&temp_dict, dict->fdtp, new_size); in _ufdt_prop_dict_enlarge_if_needed()
107 for (int i = 0; i < dict->mem_size; i++) { in _ufdt_prop_dict_enlarge_if_needed()
108 const struct fdt_property *prop = dict->props[i]; in _ufdt_prop_dict_enlarge_if_needed()
120 dto_free(dict->props); in _ufdt_prop_dict_enlarge_if_needed()
122 dict->mem_size = new_size; in _ufdt_prop_dict_enlarge_if_needed()
123 dict->props = temp_dict.props; in _ufdt_prop_dict_enlarge_if_needed()
128 int ufdt_prop_dict_add(struct ufdt_prop_dict *dict, in ufdt_prop_dict_add() argument
130 const struct fdt_property **prop_ptr = _ufdt_prop_dict_find_index(dict, prop); in ufdt_prop_dict_add()
136 if (*prop_ptr == NULL) dict->num_used++; in ufdt_prop_dict_add()
139 return _ufdt_prop_dict_enlarge_if_needed(dict); in ufdt_prop_dict_add()
142 const struct fdt_property *ufdt_prop_dict_find(const struct ufdt_prop_dict *dict, in ufdt_prop_dict_find() argument
145 _ufdt_prop_dict_find_index_by_name(dict, name); in ufdt_prop_dict_find()