]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
of: Constify struct property pointers
authorRob Herring (Arm) <robh@kernel.org>
Thu, 10 Oct 2024 16:27:17 +0000 (11:27 -0500)
committerRob Herring (Arm) <robh@kernel.org>
Tue, 15 Oct 2024 13:58:36 +0000 (08:58 -0500)
Most accesses to struct property do not modify it, so constify struct
property pointers where ever possible in the DT core code.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20241010-dt-const-v1-4-87a51f558425@kernel.org
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
drivers/of/base.c
drivers/of/kobj.c
drivers/of/of_private.h
drivers/of/overlay.c
drivers/of/property.c
drivers/of/resolver.c
include/linux/of.h

index d1aebb9795224473ed9aa9bd7a4d745c6d64a84d..d94efee4a7fc557b8d27967d1a6c6e43be300214 100644 (file)
@@ -270,7 +270,7 @@ EXPORT_SYMBOL(of_find_all_nodes);
 const void *__of_get_property(const struct device_node *np,
                              const char *name, int *lenp)
 {
-       struct property *pp = __of_find_property(np, name, lenp);
+       const struct property *pp = __of_find_property(np, name, lenp);
 
        return pp ? pp->value : NULL;
 }
@@ -282,7 +282,7 @@ const void *__of_get_property(const struct device_node *np,
 const void *of_get_property(const struct device_node *np, const char *name,
                            int *lenp)
 {
-       struct property *pp = of_find_property(np, name, lenp);
+       const struct property *pp = of_find_property(np, name, lenp);
 
        return pp ? pp->value : NULL;
 }
@@ -321,7 +321,7 @@ EXPORT_SYMBOL(of_get_property);
 static int __of_device_is_compatible(const struct device_node *device,
                                     const char *compat, const char *type, const char *name)
 {
-       struct property *prop;
+       const struct property *prop;
        const char *cp;
        int index = 0, score = 0;
 
@@ -828,7 +828,7 @@ struct device_node *__of_find_node_by_full_path(struct device_node *node,
 struct device_node *of_find_node_opts_by_path(const char *path, const char **opts)
 {
        struct device_node *np = NULL;
-       struct property *pp;
+       const struct property *pp;
        unsigned long flags;
        const char *separator = strchr(path, ':');
 
@@ -974,7 +974,7 @@ struct device_node *of_find_node_with_property(struct device_node *from,
        const char *prop_name)
 {
        struct device_node *np;
-       struct property *pp;
+       const struct property *pp;
        unsigned long flags;
 
        raw_spin_lock_irqsave(&devtree_lock, flags);
@@ -1769,7 +1769,7 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np,
  */
 void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
 {
-       struct property *pp;
+       const struct property *pp;
 
        of_aliases = of_find_node_by_path("/aliases");
        of_chosen = of_find_node_by_path("/chosen");
index 3dbce1e6f184fcd78ea6e04a41fe431069eb297e..aeb1709d4e85fe0cddb85fbea04887de8ce03ea0 100644 (file)
@@ -84,7 +84,7 @@ int __of_add_property_sysfs(struct device_node *np, struct property *pp)
        return rc;
 }
 
-void __of_sysfs_remove_bin_file(struct device_node *np, struct property *prop)
+void __of_sysfs_remove_bin_file(struct device_node *np, const struct property *prop)
 {
        if (!IS_ENABLED(CONFIG_SYSFS))
                return;
@@ -93,7 +93,7 @@ void __of_sysfs_remove_bin_file(struct device_node *np, struct property *prop)
        kfree(prop->attr.attr.name);
 }
 
-void __of_remove_property_sysfs(struct device_node *np, struct property *prop)
+void __of_remove_property_sysfs(struct device_node *np, const struct property *prop)
 {
        /* at early boot, bail here and defer setup to of_init() */
        if (of_kset && of_node_is_attached(np))
@@ -101,7 +101,7 @@ void __of_remove_property_sysfs(struct device_node *np, struct property *prop)
 }
 
 void __of_update_property_sysfs(struct device_node *np, struct property *newprop,
-               struct property *oldprop)
+               const struct property *oldprop)
 {
        /* At early boot, bail out and defer setup to of_init() */
        if (!of_kset)
index d957cc6ce437ae4f60c60fcca8634fec2d336603..53a4a5be9997ffa4d3592c8cefe08bdce7f58bcd 100644 (file)
@@ -69,9 +69,9 @@ static inline void of_platform_register_reconfig_notifier(void) { }
 #if defined(CONFIG_OF_KOBJ)
 int of_node_is_attached(const struct device_node *node);
 int __of_add_property_sysfs(struct device_node *np, struct property *pp);
-void __of_remove_property_sysfs(struct device_node *np, struct property *prop);
+void __of_remove_property_sysfs(struct device_node *np, const struct property *prop);
 void __of_update_property_sysfs(struct device_node *np, struct property *newprop,
-               struct property *oldprop);
+               const struct property *oldprop);
 int __of_attach_node_sysfs(struct device_node *np);
 void __of_detach_node_sysfs(struct device_node *np);
 #else
@@ -79,9 +79,9 @@ static inline int __of_add_property_sysfs(struct device_node *np, struct propert
 {
        return 0;
 }
-static inline void __of_remove_property_sysfs(struct device_node *np, struct property *prop) {}
+static inline void __of_remove_property_sysfs(struct device_node *np, const struct property *prop) {}
 static inline void __of_update_property_sysfs(struct device_node *np,
-               struct property *newprop, struct property *oldprop) {}
+               struct property *newprop, const struct property *oldprop) {}
 static inline int __of_attach_node_sysfs(struct device_node *np)
 {
        return 0;
@@ -142,7 +142,7 @@ extern int __of_update_property(struct device_node *np,
 extern void __of_detach_node(struct device_node *np);
 
 extern void __of_sysfs_remove_bin_file(struct device_node *np,
-                                      struct property *prop);
+                                      const struct property *prop);
 
 /* illegal phandle value (set when unresolved) */
 #define OF_PHANDLE_ILLEGAL     0xdeadbeef
index 19aaa96ee817da92b25ec0997e61f8ea62c0bd44..434f6dd6a86c1ffad2b0d490b2b612a5147994c5 100644 (file)
@@ -296,10 +296,11 @@ err_free_target_path:
  * invalid @overlay.
  */
 static int add_changeset_property(struct overlay_changeset *ovcs,
-               struct target *target, struct property *overlay_prop,
+               struct target *target, const struct property *overlay_prop,
                bool is_symbols_prop)
 {
-       struct property *new_prop = NULL, *prop;
+       struct property *new_prop = NULL;
+       const struct property *prop;
        int ret = 0;
 
        if (target->in_livetree)
index 11b922fde7af167cc69f6dd89826219653cd1ee8..33dd72cad4abeed38991245b71583a7bbcca157f 100644 (file)
@@ -68,7 +68,7 @@ EXPORT_SYMBOL(of_graph_is_present);
 int of_property_count_elems_of_size(const struct device_node *np,
                                const char *propname, int elem_size)
 {
-       struct property *prop = of_find_property(np, propname, NULL);
+       const struct property *prop = of_find_property(np, propname, NULL);
 
        if (!prop)
                return -EINVAL;
@@ -104,7 +104,7 @@ EXPORT_SYMBOL_GPL(of_property_count_elems_of_size);
 static void *of_find_property_value_of_size(const struct device_node *np,
                        const char *propname, u32 min, u32 max, size_t *len)
 {
-       struct property *prop = of_find_property(np, propname, NULL);
+       const struct property *prop = of_find_property(np, propname, NULL);
 
        if (!prop)
                return ERR_PTR(-EINVAL);
@@ -530,7 +530,7 @@ int of_property_read_string_helper(const struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(of_property_read_string_helper);
 
-const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
+const __be32 *of_prop_next_u32(const struct property *prop, const __be32 *cur,
                               u32 *pu)
 {
        const void *curv = cur;
@@ -553,7 +553,7 @@ out_val:
 }
 EXPORT_SYMBOL_GPL(of_prop_next_u32);
 
-const char *of_prop_next_string(struct property *prop, const char *cur)
+const char *of_prop_next_string(const struct property *prop, const char *cur)
 {
        const void *curv = cur;
 
@@ -1466,7 +1466,7 @@ static int of_fwnode_irq_get(const struct fwnode_handle *fwnode,
 
 static int of_fwnode_add_links(struct fwnode_handle *fwnode)
 {
-       struct property *p;
+       const struct property *p;
        struct device_node *con_np = to_of_node(fwnode);
 
        if (IS_ENABLED(CONFIG_X86))
index ee7769525bb2baabf5fab7a5025b4c199fc5db0d..779db058c42f5b8198ee3417dfaab80c81b43e4c 100644 (file)
@@ -42,7 +42,7 @@ static void adjust_overlay_phandles(struct device_node *overlay,
                int phandle_delta)
 {
        struct device_node *child;
-       struct property *prop;
+       const struct property *prop;
        phandle phandle;
 
        /* adjust node's phandle in node */
@@ -71,10 +71,10 @@ static void adjust_overlay_phandles(struct device_node *overlay,
 }
 
 static int update_usages_of_a_phandle_reference(struct device_node *overlay,
-               struct property *prop_fixup, phandle phandle)
+               const struct property *prop_fixup, phandle phandle)
 {
        struct device_node *refnode;
-       struct property *prop;
+       const struct property *prop;
        char *value __free(kfree) = kmemdup(prop_fixup->value, prop_fixup->length, GFP_KERNEL);
        char *cur, *end, *node_path, *prop_name, *s;
        int offset, len;
@@ -151,7 +151,7 @@ static int adjust_local_phandle_references(const struct device_node *local_fixup
                const struct device_node *overlay, int phandle_delta)
 {
        struct device_node *overlay_child;
-       struct property *prop_fix, *prop;
+       const struct property *prop_fix, *prop;
        int err, i, count;
        unsigned int off;
 
index 7875b308f13cdbb25d7e13e10250f39707c2ec08..086a60f3b8a6da1452f27757361af91d6c5c8bbd 100644 (file)
@@ -435,7 +435,7 @@ extern int of_detach_node(struct device_node *);
  * of_property_for_each_u32(np, "propname", u)
  *         printk("U32 value: %x\n", u);
  */
-const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
+const __be32 *of_prop_next_u32(const struct property *prop, const __be32 *cur,
                               u32 *pu);
 /*
  * struct property *prop;
@@ -444,7 +444,7 @@ const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
  * of_property_for_each_string(np, "propname", prop, s)
  *         printk("String value: %s\n", s);
  */
-const char *of_prop_next_string(struct property *prop, const char *cur);
+const char *of_prop_next_string(const struct property *prop, const char *cur);
 
 bool of_console_check(const struct device_node *dn, char *name, int index);
 
@@ -826,13 +826,13 @@ static inline bool of_console_check(const struct device_node *dn, const char *na
        return false;
 }
 
-static inline const __be32 *of_prop_next_u32(struct property *prop,
+static inline const __be32 *of_prop_next_u32(const struct property *prop,
                const __be32 *cur, u32 *pu)
 {
        return NULL;
 }
 
-static inline const char *of_prop_next_string(struct property *prop,
+static inline const char *of_prop_next_string(const struct property *prop,
                const char *cur)
 {
        return NULL;
@@ -899,7 +899,7 @@ static inline const void *of_device_get_match_data(const struct device *dev)
 #define of_node_cmp(s1, s2)            strcasecmp((s1), (s2))
 #endif
 
-static inline int of_prop_val_eq(struct property *p1, struct property *p2)
+static inline int of_prop_val_eq(const struct property *p1, const struct property *p2)
 {
        return p1->length == p2->length &&
               !memcmp(p1->value, p2->value, (size_t)p1->length);
@@ -1252,7 +1252,7 @@ static inline int of_property_read_string_index(const struct device_node *np,
 static inline bool of_property_read_bool(const struct device_node *np,
                                         const char *propname)
 {
-       struct property *prop = of_find_property(np, propname, NULL);
+       const struct property *prop = of_find_property(np, propname, NULL);
 
        return prop ? true : false;
 }
@@ -1430,7 +1430,7 @@ static inline int of_property_read_s32(const struct device_node *np,
             err = of_phandle_iterator_next(it))
 
 #define of_property_for_each_u32(np, propname, u)                      \
-       for (struct {struct property *prop; const __be32 *item; } _it = \
+       for (struct {const struct property *prop; const __be32 *item; } _it =   \
                {of_find_property(np, propname, NULL),                  \
                 of_prop_next_u32(_it.prop, NULL, &u)};                 \
             _it.item;                                                  \