of_private.h 5.1 KB

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