of_private.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. #ifndef _LINUX_OF_PRIVATE_H
  3. #define _LINUX_OF_PRIVATE_H
  4. /*
  5. * Private symbols used by OF support code
  6. *
  7. * Paul Mackerras August 1996.
  8. * Copyright (C) 1996-2005 Paul Mackerras.
  9. */
  10. /**
  11. * struct alias_prop - Alias property in 'aliases' node
  12. * @link: List node to link the structure in aliases_lookup list
  13. * @alias: Alias property name
  14. * @np: Pointer to device_node that the alias stands for
  15. * @id: Index value from end of alias name
  16. * @stem: Alias string without the index
  17. *
  18. * The structure represents one alias property of 'aliases' node as
  19. * an entry in aliases_lookup list.
  20. */
  21. struct alias_prop {
  22. struct list_head link;
  23. const char *alias;
  24. struct device_node *np;
  25. int id;
  26. char stem[0];
  27. };
  28. extern struct mutex of_mutex;
  29. extern struct list_head aliases_lookup;
  30. extern struct kset *of_kset;
  31. #if defined(CONFIG_OF_DYNAMIC)
  32. extern int of_property_notify(int action, struct device_node *np,
  33. struct property *prop, struct property *old_prop);
  34. extern void of_node_release(struct kobject *kobj);
  35. extern int __of_changeset_apply_entries(struct of_changeset *ocs,
  36. int *ret_revert);
  37. extern int __of_changeset_apply_notify(struct of_changeset *ocs);
  38. extern int __of_changeset_revert_entries(struct of_changeset *ocs,
  39. int *ret_apply);
  40. extern int __of_changeset_revert_notify(struct of_changeset *ocs);
  41. #else /* CONFIG_OF_DYNAMIC */
  42. static inline int of_property_notify(int action, struct device_node *np,
  43. struct property *prop, struct property *old_prop)
  44. {
  45. return 0;
  46. }
  47. #endif /* CONFIG_OF_DYNAMIC */
  48. #if defined(CONFIG_OF_KOBJ)
  49. int of_node_is_attached(struct device_node *node);
  50. int __of_add_property_sysfs(struct device_node *np, struct property *pp);
  51. void __of_remove_property_sysfs(struct device_node *np, struct property *prop);
  52. void __of_update_property_sysfs(struct device_node *np, struct property *newprop,
  53. struct property *oldprop);
  54. int __of_attach_node_sysfs(struct device_node *np);
  55. void __of_detach_node_sysfs(struct device_node *np);
  56. #else
  57. static inline int __of_add_property_sysfs(struct device_node *np, struct property *pp)
  58. {
  59. return 0;
  60. }
  61. static inline void __of_remove_property_sysfs(struct device_node *np, struct property *prop) {}
  62. static inline void __of_update_property_sysfs(struct device_node *np,
  63. struct property *newprop, struct property *oldprop) {}
  64. static inline int __of_attach_node_sysfs(struct device_node *np)
  65. {
  66. return 0;
  67. }
  68. static inline void __of_detach_node_sysfs(struct device_node *np) {}
  69. #endif
  70. #if defined(CONFIG_OF_RESOLVE)
  71. int of_resolve_phandles(struct device_node *tree);
  72. #endif
  73. #if defined(CONFIG_OF_DYNAMIC)
  74. void __of_free_phandle_cache_entry(phandle handle);
  75. #endif
  76. #if defined(CONFIG_OF_OVERLAY)
  77. void of_overlay_mutex_lock(void);
  78. void of_overlay_mutex_unlock(void);
  79. int of_free_phandle_cache(void);
  80. void of_populate_phandle_cache(void);
  81. #else
  82. static inline void of_overlay_mutex_lock(void) {};
  83. static inline void of_overlay_mutex_unlock(void) {};
  84. #endif
  85. #if defined(CONFIG_OF_UNITTEST) && defined(CONFIG_OF_OVERLAY)
  86. extern void __init unittest_unflatten_overlay_base(void);
  87. #else
  88. static inline void unittest_unflatten_overlay_base(void) {};
  89. #endif
  90. extern void *__unflatten_device_tree(const void *blob,
  91. struct device_node *dad,
  92. struct device_node **mynodes,
  93. void *(*dt_alloc)(u64 size, u64 align),
  94. bool detached);
  95. /**
  96. * General utilities for working with live trees.
  97. *
  98. * All functions with two leading underscores operate
  99. * without taking node references, so you either have to
  100. * own the devtree lock or work on detached trees only.
  101. */
  102. struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags);
  103. struct device_node *__of_node_dup(const struct device_node *np,
  104. const char *full_name);
  105. struct device_node *__of_find_node_by_path(struct device_node *parent,
  106. const char *path);
  107. struct device_node *__of_find_node_by_full_path(struct device_node *node,
  108. const char *path);
  109. extern const void *__of_get_property(const struct device_node *np,
  110. const char *name, int *lenp);
  111. extern int __of_add_property(struct device_node *np, struct property *prop);
  112. extern int __of_add_property_sysfs(struct device_node *np,
  113. struct property *prop);
  114. extern int __of_remove_property(struct device_node *np, struct property *prop);
  115. extern void __of_remove_property_sysfs(struct device_node *np,
  116. struct property *prop);
  117. extern int __of_update_property(struct device_node *np,
  118. struct property *newprop, struct property **oldprop);
  119. extern void __of_update_property_sysfs(struct device_node *np,
  120. struct property *newprop, struct property *oldprop);
  121. extern int __of_attach_node_sysfs(struct device_node *np);
  122. extern void __of_detach_node(struct device_node *np);
  123. extern void __of_detach_node_sysfs(struct device_node *np);
  124. extern void __of_sysfs_remove_bin_file(struct device_node *np,
  125. struct property *prop);
  126. /* illegal phandle value (set when unresolved) */
  127. #define OF_PHANDLE_ILLEGAL 0xdeadbeef
  128. /* iterators for transactions, used for overlays */
  129. /* forward iterator */
  130. #define for_each_transaction_entry(_oft, _te) \
  131. list_for_each_entry(_te, &(_oft)->te_list, node)
  132. /* reverse iterator */
  133. #define for_each_transaction_entry_reverse(_oft, _te) \
  134. list_for_each_entry_reverse(_te, &(_oft)->te_list, node)
  135. #endif /* _LINUX_OF_PRIVATE_H */