When implementing migration between bindings with different structure, properties might move from one node to another. Introduce a helper function to do this, releaving the caller from having to care about the datatype of the property and/or peek into the struct property. Signed-off-by: Bjorn Andersson <bjorn.andersson@xxxxxxxxxxxxxxxx> --- drivers/of/dynamic.c | 20 ++++++++++++++++++++ include/linux/of.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 0aba760f7577..e4d7ff53a892 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -1073,6 +1073,26 @@ int of_changeset_add_prop_bool(struct of_changeset *ocs, struct device_node *np, } EXPORT_SYMBOL_GPL(of_changeset_add_prop_bool); +/** + * of_changeset_add_prop_copy() - Add a property with name and value copied + * from an existing property, to a changeset. + * + * @ocs: changeset pointer + * @np: device node pointer + * @prop: existing property to copy + * + * Create a new property with name and value copied from a provided property, + * to a changeset. + * + * Return: 0 on success, a negative error value in case of an error. + */ +int of_changeset_add_prop_copy(struct of_changeset *ocs, struct device_node *np, + const struct property *prop) +{ + return of_changeset_add_prop_helper(ocs, np, prop); +} +EXPORT_SYMBOL_GPL(of_changeset_add_prop_copy); + static int of_changeset_update_prop_helper(struct of_changeset *ocs, struct device_node *np, const struct property *pp) diff --git a/include/linux/of.h b/include/linux/of.h index f921786cb8ac..6a9bcdf9d629 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1667,6 +1667,9 @@ int of_changeset_update_prop_string(struct of_changeset *ocs, int of_changeset_add_prop_bool(struct of_changeset *ocs, struct device_node *np, const char *prop_name); +int of_changeset_add_prop_copy(struct of_changeset *ocs, struct device_node *np, + const struct property *prop); + #else /* CONFIG_OF_DYNAMIC */ static inline int of_reconfig_notifier_register(struct notifier_block *nb) { -- 2.45.2