ufdt_prop_dict.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #ifndef UFDT_PROP_DICT_H
  17. #define UFDT_PROP_DICT_H
  18. struct fdt_property;
  19. struct ufdt_prop_dict {
  20. int mem_size;
  21. int num_used;
  22. void *fdtp;
  23. const struct fdt_property **props;
  24. };
  25. /*
  26. * Allocates some new spaces and creates a new ufdt_prop_dict.
  27. *
  28. * @return: a pointer to the newly created ufdt_prop_dict or
  29. * NULL if dto_malloc failed
  30. */
  31. int ufdt_prop_dict_construct(struct ufdt_prop_dict *dict, void *fdtp);
  32. /*
  33. * Frees all space dto_malloced, not including ufdt_nodes in the table.
  34. */
  35. void ufdt_prop_dict_destruct(struct ufdt_prop_dict *dict);
  36. /*
  37. * Adds a fdt_property (as pointer) to the ufdt_prop_dict.
  38. * @return: 0 if success
  39. * < 0 otherwise
  40. *
  41. * @Time: O(length of node->name)
  42. */
  43. int ufdt_prop_dict_add(struct ufdt_prop_dict *dict,
  44. const struct fdt_property *prop);
  45. /*
  46. * Returns the pointer to the fdt_property with name
  47. *
  48. * @return: a pointer to the node or
  49. * NULL if no such node in ufdt_prop_dict with same name.
  50. *
  51. * @Time: O(len = |name|)
  52. */
  53. const struct fdt_property *ufdt_prop_dict_find(const struct ufdt_prop_dict *dict,
  54. const char *name);
  55. #endif