]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - include/linux/of.h
mod_devicetable: fix PHY module format
[mirror_ubuntu-bionic-kernel.git] / include / linux / of.h
index b240ed69dc9626a266498807e568a5b09c0b888b..49bd3a25e16cccad3a55355a3b30d02a2b5c24b7 100644 (file)
@@ -37,9 +37,15 @@ struct property {
        int     length;
        void    *value;
        struct property *next;
+#if defined(CONFIG_OF_DYNAMIC) || defined(CONFIG_SPARC)
        unsigned long _flags;
+#endif
+#if defined(CONFIG_OF_PROMTREE)
        unsigned int unique_id;
+#endif
+#if defined(CONFIG_OF_KOBJ)
        struct bin_attribute attr;
+#endif
 };
 
 #if defined(CONFIG_SPARC)
@@ -58,7 +64,9 @@ struct device_node {
        struct  device_node *parent;
        struct  device_node *child;
        struct  device_node *sibling;
+#if defined(CONFIG_OF_KOBJ)
        struct  kobject kobj;
+#endif
        unsigned long _flags;
        void    *data;
 #if defined(CONFIG_SPARC)
@@ -103,21 +111,17 @@ extern struct kobj_type of_node_ktype;
 extern const struct fwnode_operations of_fwnode_ops;
 static inline void of_node_init(struct device_node *node)
 {
+#if defined(CONFIG_OF_KOBJ)
        kobject_init(&node->kobj, &of_node_ktype);
+#endif
        node->fwnode.ops = &of_fwnode_ops;
 }
 
-/* true when node is initialized */
-static inline int of_node_is_initialized(struct device_node *node)
-{
-       return node && node->kobj.state_initialized;
-}
-
-/* true when node is attached (i.e. present on sysfs) */
-static inline int of_node_is_attached(struct device_node *node)
-{
-       return node && node->kobj.state_in_sysfs;
-}
+#if defined(CONFIG_OF_KOBJ)
+#define of_node_kobj(n) (&(n)->kobj)
+#else
+#define of_node_kobj(n) NULL
+#endif
 
 #ifdef CONFIG_OF_DYNAMIC
 extern struct device_node *of_node_get(struct device_node *node);
@@ -138,11 +142,16 @@ extern struct device_node *of_aliases;
 extern struct device_node *of_stdout;
 extern raw_spinlock_t devtree_lock;
 
-/* flag descriptions (need to be visible even when !CONFIG_OF) */
-#define OF_DYNAMIC     1 /* node and properties were allocated via kmalloc */
-#define OF_DETACHED    2 /* node has been detached from the device tree */
-#define OF_POPULATED   3 /* device already created for the node */
-#define OF_POPULATED_BUS       4 /* of_platform_populate recursed to children of this node */
+/*
+ * struct device_node flag descriptions
+ * (need to be visible even when !CONFIG_OF)
+ */
+#define OF_DYNAMIC             1 /* (and properties) allocated via kmalloc */
+#define OF_DETACHED            2 /* detached from the device tree */
+#define OF_POPULATED           3 /* device already created */
+#define OF_POPULATED_BUS       4 /* platform bus created for children */
+#define OF_OVERLAY             5 /* allocated for an overlay */
+#define OF_OVERLAY_FREE_CSET   6 /* in overlay cset being freed */
 
 #define OF_BAD_ADDR    ((u64)-1)
 
@@ -203,6 +212,7 @@ static inline void of_node_clear_flag(struct device_node *n, unsigned long flag)
        clear_bit(flag, &n->_flags);
 }
 
+#if defined(CONFIG_OF_DYNAMIC) || defined(CONFIG_SPARC)
 static inline int of_property_check_flag(struct property *p, unsigned long flag)
 {
        return test_bit(flag, &p->_flags);
@@ -217,6 +227,7 @@ static inline void of_property_clear_flag(struct property *p, unsigned long flag
 {
        clear_bit(flag, &p->_flags);
 }
+#endif
 
 extern struct device_node *__of_find_all_nodes(struct device_node *prev);
 extern struct device_node *of_find_all_nodes(struct device_node *prev);
@@ -229,8 +240,8 @@ extern struct device_node *of_find_all_nodes(struct device_node *prev);
 static inline u64 of_read_number(const __be32 *cell, int size)
 {
        u64 r = 0;
-       while (size--)
-               r = (r << 32) | be32_to_cpu(*(cell++));
+       for (; size--; cell++)
+               r = (r << 32) | be32_to_cpu(*cell);
        return r;
 }
 
@@ -288,6 +299,8 @@ extern struct device_node *of_get_next_child(const struct device_node *node,
 extern struct device_node *of_get_next_available_child(
        const struct device_node *node, struct device_node *prev);
 
+extern struct device_node *of_get_compatible_child(const struct device_node *parent,
+                                       const char *compatible);
 extern struct device_node *of_get_child_by_name(const struct device_node *node,
                                        const char *name);
 
@@ -625,6 +638,12 @@ static inline bool of_have_populated_dt(void)
        return false;
 }
 
+static inline struct device_node *of_get_compatible_child(const struct device_node *parent,
+                                       const char *compatible)
+{
+       return NULL;
+}
+
 static inline struct device_node *of_get_child_by_name(
                                        const struct device_node *node,
                                        const char *name)
@@ -675,12 +694,6 @@ static inline int of_property_count_elems_of_size(const struct device_node *np,
        return -ENOSYS;
 }
 
-static inline int of_property_read_u32_index(const struct device_node *np,
-                       const char *propname, u32 index, u32 *out_value)
-{
-       return -ENOSYS;
-}
-
 static inline int of_property_read_u8_array(const struct device_node *np,
                        const char *propname, u8 *out_values, size_t sz)
 {
@@ -707,16 +720,14 @@ static inline int of_property_read_u64_array(const struct device_node *np,
        return -ENOSYS;
 }
 
-static inline int of_property_read_string(const struct device_node *np,
-                                         const char *propname,
-                                         const char **out_string)
+static inline int of_property_read_u32_index(const struct device_node *np,
+                       const char *propname, u32 index, u32 *out_value)
 {
        return -ENOSYS;
 }
 
-static inline int of_property_read_string_helper(const struct device_node *np,
-                                                const char *propname,
-                                                const char **out_strs, size_t sz, int index)
+static inline int of_property_read_u64_index(const struct device_node *np,
+                       const char *propname, u32 index, u64 *out_value)
 {
        return -ENOSYS;
 }
@@ -744,12 +755,51 @@ static inline int of_n_size_cells(struct device_node *np)
        return 0;
 }
 
+static inline int of_property_read_variable_u8_array(const struct device_node *np,
+                                       const char *propname, u8 *out_values,
+                                       size_t sz_min, size_t sz_max)
+{
+       return -ENOSYS;
+}
+
+static inline int of_property_read_variable_u16_array(const struct device_node *np,
+                                       const char *propname, u16 *out_values,
+                                       size_t sz_min, size_t sz_max)
+{
+       return -ENOSYS;
+}
+
+static inline int of_property_read_variable_u32_array(const struct device_node *np,
+                                       const char *propname,
+                                       u32 *out_values,
+                                       size_t sz_min,
+                                       size_t sz_max)
+{
+       return -ENOSYS;
+}
+
 static inline int of_property_read_u64(const struct device_node *np,
                                       const char *propname, u64 *out_value)
 {
        return -ENOSYS;
 }
 
+static inline int of_property_read_variable_u64_array(const struct device_node *np,
+                                       const char *propname,
+                                       u64 *out_values,
+                                       size_t sz_min,
+                                       size_t sz_max)
+{
+       return -ENOSYS;
+}
+
+static inline int of_property_read_string(const struct device_node *np,
+                                         const char *propname,
+                                         const char **out_string)
+{
+       return -ENOSYS;
+}
+
 static inline int of_property_match_string(const struct device_node *np,
                                           const char *propname,
                                           const char *string)
@@ -757,6 +807,13 @@ static inline int of_property_match_string(const struct device_node *np,
        return -ENOSYS;
 }
 
+static inline int of_property_read_string_helper(const struct device_node *np,
+                                                const char *propname,
+                                                const char **out_strs, size_t sz, int index)
+{
+       return -ENOSYS;
+}
+
 static inline struct device_node *of_parse_phandle(const struct device_node *np,
                                                   const char *phandle_name,
                                                   int index)
@@ -883,6 +940,12 @@ static inline void of_property_clear_flag(struct property *p, unsigned long flag
 #define of_node_cmp(s1, s2)            strcasecmp((s1), (s2))
 #endif
 
+static inline int of_prop_val_eq(struct property *p1, struct property *p2)
+{
+       return p1->length == p2->length &&
+              !memcmp(p1->value, p2->value, (size_t)p1->length);
+}
+
 #if defined(CONFIG_OF) && defined(CONFIG_NUMA)
 extern int of_node_to_nid(struct device_node *np);
 #else
@@ -1283,9 +1346,6 @@ static inline int of_reconfig_get_state_change(unsigned long action,
 }
 #endif /* CONFIG_OF_DYNAMIC */
 
-/* CONFIG_OF_RESOLVE api */
-extern int of_resolve_phandles(struct device_node *tree);
-
 /**
  * of_device_is_system_power_controller - Tells if system-power-controller is found for device_node
  * @np: Pointer to the given device_node
@@ -1302,7 +1362,7 @@ static inline bool of_device_is_system_power_controller(const struct device_node
  */
 
 enum of_overlay_notify_action {
-       OF_OVERLAY_PRE_APPLY,
+       OF_OVERLAY_PRE_APPLY = 0,
        OF_OVERLAY_POST_APPLY,
        OF_OVERLAY_PRE_REMOVE,
        OF_OVERLAY_POST_REMOVE,
@@ -1316,26 +1376,26 @@ struct of_overlay_notify_data {
 #ifdef CONFIG_OF_OVERLAY
 
 /* ID based overlays; the API for external users */
-int of_overlay_create(struct device_node *tree);
-int of_overlay_destroy(int id);
-int of_overlay_destroy_all(void);
+int of_overlay_apply(struct device_node *tree, int *ovcs_id);
+int of_overlay_remove(int *ovcs_id);
+int of_overlay_remove_all(void);
 
 int of_overlay_notifier_register(struct notifier_block *nb);
 int of_overlay_notifier_unregister(struct notifier_block *nb);
 
 #else
 
-static inline int of_overlay_create(struct device_node *tree)
+static inline int of_overlay_apply(struct device_node *tree, int *ovcs_id)
 {
        return -ENOTSUPP;
 }
 
-static inline int of_overlay_destroy(int id)
+static inline int of_overlay_remove(int *ovcs_id)
 {
        return -ENOTSUPP;
 }
 
-static inline int of_overlay_destroy_all(void)
+static inline int of_overlay_remove_all(void)
 {
        return -ENOTSUPP;
 }