Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

of: Constify struct property pointers

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>

+33 -32
+6 -6
drivers/of/base.c
··· 270 270 const void *__of_get_property(const struct device_node *np, 271 271 const char *name, int *lenp) 272 272 { 273 - struct property *pp = __of_find_property(np, name, lenp); 273 + const struct property *pp = __of_find_property(np, name, lenp); 274 274 275 275 return pp ? pp->value : NULL; 276 276 } ··· 282 282 const void *of_get_property(const struct device_node *np, const char *name, 283 283 int *lenp) 284 284 { 285 - struct property *pp = of_find_property(np, name, lenp); 285 + const struct property *pp = of_find_property(np, name, lenp); 286 286 287 287 return pp ? pp->value : NULL; 288 288 } ··· 321 321 static int __of_device_is_compatible(const struct device_node *device, 322 322 const char *compat, const char *type, const char *name) 323 323 { 324 - struct property *prop; 324 + const struct property *prop; 325 325 const char *cp; 326 326 int index = 0, score = 0; 327 327 ··· 828 828 struct device_node *of_find_node_opts_by_path(const char *path, const char **opts) 829 829 { 830 830 struct device_node *np = NULL; 831 - struct property *pp; 831 + const struct property *pp; 832 832 unsigned long flags; 833 833 const char *separator = strchr(path, ':'); 834 834 ··· 974 974 const char *prop_name) 975 975 { 976 976 struct device_node *np; 977 - struct property *pp; 977 + const struct property *pp; 978 978 unsigned long flags; 979 979 980 980 raw_spin_lock_irqsave(&devtree_lock, flags); ··· 1769 1769 */ 1770 1770 void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) 1771 1771 { 1772 - struct property *pp; 1772 + const struct property *pp; 1773 1773 1774 1774 of_aliases = of_find_node_by_path("/aliases"); 1775 1775 of_chosen = of_find_node_by_path("/chosen");
+3 -3
drivers/of/kobj.c
··· 84 84 return rc; 85 85 } 86 86 87 - void __of_sysfs_remove_bin_file(struct device_node *np, struct property *prop) 87 + void __of_sysfs_remove_bin_file(struct device_node *np, const struct property *prop) 88 88 { 89 89 if (!IS_ENABLED(CONFIG_SYSFS)) 90 90 return; ··· 93 93 kfree(prop->attr.attr.name); 94 94 } 95 95 96 - void __of_remove_property_sysfs(struct device_node *np, struct property *prop) 96 + void __of_remove_property_sysfs(struct device_node *np, const struct property *prop) 97 97 { 98 98 /* at early boot, bail here and defer setup to of_init() */ 99 99 if (of_kset && of_node_is_attached(np)) ··· 101 101 } 102 102 103 103 void __of_update_property_sysfs(struct device_node *np, struct property *newprop, 104 - struct property *oldprop) 104 + const struct property *oldprop) 105 105 { 106 106 /* At early boot, bail out and defer setup to of_init() */ 107 107 if (!of_kset)
+5 -5
drivers/of/of_private.h
··· 69 69 #if defined(CONFIG_OF_KOBJ) 70 70 int of_node_is_attached(const struct device_node *node); 71 71 int __of_add_property_sysfs(struct device_node *np, struct property *pp); 72 - void __of_remove_property_sysfs(struct device_node *np, struct property *prop); 72 + void __of_remove_property_sysfs(struct device_node *np, const struct property *prop); 73 73 void __of_update_property_sysfs(struct device_node *np, struct property *newprop, 74 - struct property *oldprop); 74 + const struct property *oldprop); 75 75 int __of_attach_node_sysfs(struct device_node *np); 76 76 void __of_detach_node_sysfs(struct device_node *np); 77 77 #else ··· 79 79 { 80 80 return 0; 81 81 } 82 - static inline void __of_remove_property_sysfs(struct device_node *np, struct property *prop) {} 82 + static inline void __of_remove_property_sysfs(struct device_node *np, const struct property *prop) {} 83 83 static inline void __of_update_property_sysfs(struct device_node *np, 84 - struct property *newprop, struct property *oldprop) {} 84 + struct property *newprop, const struct property *oldprop) {} 85 85 static inline int __of_attach_node_sysfs(struct device_node *np) 86 86 { 87 87 return 0; ··· 142 142 extern void __of_detach_node(struct device_node *np); 143 143 144 144 extern void __of_sysfs_remove_bin_file(struct device_node *np, 145 - struct property *prop); 145 + const struct property *prop); 146 146 147 147 /* illegal phandle value (set when unresolved) */ 148 148 #define OF_PHANDLE_ILLEGAL 0xdeadbeef
+3 -2
drivers/of/overlay.c
··· 296 296 * invalid @overlay. 297 297 */ 298 298 static int add_changeset_property(struct overlay_changeset *ovcs, 299 - struct target *target, struct property *overlay_prop, 299 + struct target *target, const struct property *overlay_prop, 300 300 bool is_symbols_prop) 301 301 { 302 - struct property *new_prop = NULL, *prop; 302 + struct property *new_prop = NULL; 303 + const struct property *prop; 303 304 int ret = 0; 304 305 305 306 if (target->in_livetree)
+5 -5
drivers/of/property.c
··· 68 68 int of_property_count_elems_of_size(const struct device_node *np, 69 69 const char *propname, int elem_size) 70 70 { 71 - struct property *prop = of_find_property(np, propname, NULL); 71 + const struct property *prop = of_find_property(np, propname, NULL); 72 72 73 73 if (!prop) 74 74 return -EINVAL; ··· 104 104 static void *of_find_property_value_of_size(const struct device_node *np, 105 105 const char *propname, u32 min, u32 max, size_t *len) 106 106 { 107 - struct property *prop = of_find_property(np, propname, NULL); 107 + const struct property *prop = of_find_property(np, propname, NULL); 108 108 109 109 if (!prop) 110 110 return ERR_PTR(-EINVAL); ··· 530 530 } 531 531 EXPORT_SYMBOL_GPL(of_property_read_string_helper); 532 532 533 - const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, 533 + const __be32 *of_prop_next_u32(const struct property *prop, const __be32 *cur, 534 534 u32 *pu) 535 535 { 536 536 const void *curv = cur; ··· 553 553 } 554 554 EXPORT_SYMBOL_GPL(of_prop_next_u32); 555 555 556 - const char *of_prop_next_string(struct property *prop, const char *cur) 556 + const char *of_prop_next_string(const struct property *prop, const char *cur) 557 557 { 558 558 const void *curv = cur; 559 559 ··· 1466 1466 1467 1467 static int of_fwnode_add_links(struct fwnode_handle *fwnode) 1468 1468 { 1469 - struct property *p; 1469 + const struct property *p; 1470 1470 struct device_node *con_np = to_of_node(fwnode); 1471 1471 1472 1472 if (IS_ENABLED(CONFIG_X86))
+4 -4
drivers/of/resolver.c
··· 42 42 int phandle_delta) 43 43 { 44 44 struct device_node *child; 45 - struct property *prop; 45 + const struct property *prop; 46 46 phandle phandle; 47 47 48 48 /* adjust node's phandle in node */ ··· 71 71 } 72 72 73 73 static int update_usages_of_a_phandle_reference(struct device_node *overlay, 74 - struct property *prop_fixup, phandle phandle) 74 + const struct property *prop_fixup, phandle phandle) 75 75 { 76 76 struct device_node *refnode; 77 - struct property *prop; 77 + const struct property *prop; 78 78 char *value __free(kfree) = kmemdup(prop_fixup->value, prop_fixup->length, GFP_KERNEL); 79 79 char *cur, *end, *node_path, *prop_name, *s; 80 80 int offset, len; ··· 151 151 const struct device_node *overlay, int phandle_delta) 152 152 { 153 153 struct device_node *overlay_child; 154 - struct property *prop_fix, *prop; 154 + const struct property *prop_fix, *prop; 155 155 int err, i, count; 156 156 unsigned int off; 157 157
+7 -7
include/linux/of.h
··· 435 435 * of_property_for_each_u32(np, "propname", u) 436 436 * printk("U32 value: %x\n", u); 437 437 */ 438 - const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, 438 + const __be32 *of_prop_next_u32(const struct property *prop, const __be32 *cur, 439 439 u32 *pu); 440 440 /* 441 441 * struct property *prop; ··· 444 444 * of_property_for_each_string(np, "propname", prop, s) 445 445 * printk("String value: %s\n", s); 446 446 */ 447 - const char *of_prop_next_string(struct property *prop, const char *cur); 447 + const char *of_prop_next_string(const struct property *prop, const char *cur); 448 448 449 449 bool of_console_check(const struct device_node *dn, char *name, int index); 450 450 ··· 826 826 return false; 827 827 } 828 828 829 - static inline const __be32 *of_prop_next_u32(struct property *prop, 829 + static inline const __be32 *of_prop_next_u32(const struct property *prop, 830 830 const __be32 *cur, u32 *pu) 831 831 { 832 832 return NULL; 833 833 } 834 834 835 - static inline const char *of_prop_next_string(struct property *prop, 835 + static inline const char *of_prop_next_string(const struct property *prop, 836 836 const char *cur) 837 837 { 838 838 return NULL; ··· 899 899 #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) 900 900 #endif 901 901 902 - static inline int of_prop_val_eq(struct property *p1, struct property *p2) 902 + static inline int of_prop_val_eq(const struct property *p1, const struct property *p2) 903 903 { 904 904 return p1->length == p2->length && 905 905 !memcmp(p1->value, p2->value, (size_t)p1->length); ··· 1252 1252 static inline bool of_property_read_bool(const struct device_node *np, 1253 1253 const char *propname) 1254 1254 { 1255 - struct property *prop = of_find_property(np, propname, NULL); 1255 + const struct property *prop = of_find_property(np, propname, NULL); 1256 1256 1257 1257 return prop ? true : false; 1258 1258 } ··· 1430 1430 err = of_phandle_iterator_next(it)) 1431 1431 1432 1432 #define of_property_for_each_u32(np, propname, u) \ 1433 - for (struct {struct property *prop; const __be32 *item; } _it = \ 1433 + for (struct {const struct property *prop; const __be32 *item; } _it = \ 1434 1434 {of_find_property(np, propname, NULL), \ 1435 1435 of_prop_next_u32(_it.prop, NULL, &u)}; \ 1436 1436 _it.item; \