of_private.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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_OVERLAY)
  74. void of_overlay_mutex_lock(void);
  75. void of_overlay_mutex_unlock(void);
  76. int of_free_phandle_cache(void);
  77. void of_populate_phandle_cache(void);
  78. #else
  79. static inline void of_overlay_mutex_lock(void) {};
  80. static inline void of_overlay_mutex_unlock(void) {};
  81. #endif
  82. #if defined(CONFIG_OF_UNITTEST) && defined(CONFIG_OF_OVERLAY)
  83. extern void __init unittest_unflatten_overlay_base(void);
  84. #else
  85. static inline void unittest_unflatten_overlay_base(void) {};
  86. #endif
  87. extern void *__unflatten_device_tree(const void *blob,
  88. struct device_node *dad,
  89. struct device_node **mynodes,
  90. void *(*dt_alloc)(u64 size, u64 align),
  91. bool detached);
  92. /**
  93. * General utilities for working with live trees.
  94. *
  95. * All functions with two leading underscores operate
  96. * without taking node references, so you either have to
  97. * own the devtree lock or work on detached trees only.
  98. */
  99. struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags);
  100. struct device_node *__of_node_dup(const struct device_node *np,
  101. const char *full_name);
  102. struct device_node *__of_find_node_by_path(struct device_node *parent,
  103. const char *path);
  104. struct device_node *__of_find_node_by_full_path(struct device_node *node,
  105. const char *path);
  106. extern const void *__of_get_property(const struct device_node *np,
  107. const char *name, int *lenp);
  108. extern int __of_add_property(struct device_node *np, struct property *prop);
  109. extern int __of_add_property_sysfs(struct device_node *np,
  110. struct property *prop);
  111. extern int __of_remove_property(struct device_node *np, struct property *prop);
  112. extern void __of_remove_property_sysfs(struct device_node *np,
  113. struct property *prop);
  114. extern int __of_update_property(struct device_node *np,
  115. struct property *newprop, struct property **oldprop);
  116. extern void __of_update_property_sysfs(struct device_node *np,
  117. struct property *newprop, struct property *oldprop);
  118. extern int __of_attach_node_sysfs(struct device_node *np);
  119. extern void __of_detach_node(struct device_node *np);
  120. extern void __of_detach_node_sysfs(struct device_node *np);
  121. extern void __of_sysfs_remove_bin_file(struct device_node *np,
  122. struct property *prop);
  123. /* illegal phandle value (set when unresolved) */
  124. #define OF_PHANDLE_ILLEGAL 0xdeadbeef
  125. /* iterators for transactions, used for overlays */
  126. /* forward iterator */
  127. #define for_each_transaction_entry(_oft, _te) \
  128. list_for_each_entry(_te, &(_oft)->te_list, node)
  129. /* reverse iterator */
  130. #define for_each_transaction_entry_reverse(_oft, _te) \
  131. list_for_each_entry_reverse(_te, &(_oft)->te_list, node)
  132. #endif /* _LINUX_OF_PRIVATE_H */