diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-09-05 12:36:39 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-09-12 10:54:40 +0200 |
commit | 11d909019a1759b3a35e55e974020b948a406c76 (patch) | |
tree | 0539bac7a9bbf5049daa95370f9659afa803465e /drivers | |
parent | 4ff6430adde85818b61d9243e8a50ab9eb64e421 (diff) | |
download | barebox-11d909019a1759b3a35e55e974020b948a406c76.tar.gz barebox-11d909019a1759b3a35e55e974020b948a406c76.tar.xz |
of: implement of_rename_property()
It's often desirable to have the same barebox binary for multiple
variants. DT-level differences between the variants are often handled
by having extra device tree nodes that are disabled by default and
patched as appropriate by board code. It can be useful to have a finer
granularity for patching though, that covers only a select property, e.g.:
usbotg1 {
vbus-supply = <®_vbus_common>;
vendor,specialvariant-vbus-supply = <®_vbus_specialvariant>;
};
The new of_rename_property allows board code to easily activate the
alternative vbus supply on the specialvariant:
of_rename_property(np, "vendor,specialvariant-vbus-supply",
"vbus-supply");
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220905103639.1750714-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/of/base.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 52e6a9294e..d2e7ea4ae7 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2301,6 +2301,22 @@ void of_delete_property(struct property *pp) free(pp); } +struct property *of_rename_property(struct device_node *np, + const char *old_name, const char *new_name) +{ + struct property *pp; + + pp = of_find_property(np, old_name, NULL); + if (!pp) + return NULL; + + of_property_write_bool(np, new_name, false); + + free(pp->name); + pp->name = xstrdup(new_name); + return pp; +} + /** * of_set_property - create a property for a given node * @node - the node |