Commit 9c63fea9 authored by Rob Herring (Arm)'s avatar Rob Herring (Arm)
Browse files

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: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20241010-dt-const-v1-4-87a51f558425@kernel.org


Signed-off-by: default avatarRob Herring (Arm) <robh@kernel.org>
parent ec8c2329
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -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");
+3 −3
Original line number Diff line number Diff line
@@ -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)
+5 −5
Original line number Diff line number Diff line
@@ -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
+3 −2
Original line number Diff line number Diff line
@@ -296,10 +296,11 @@ static struct property *dup_and_fixup_symbol_prop(
 * 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)
+5 −5
Original line number Diff line number Diff line
@@ -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 @@ const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
}
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))
Loading