* [PATCH 1/2] of: implement of_copy_property
@ 2023-04-14 18:35 Ahmad Fatoum
2023-04-14 18:35 ` [PATCH 2/2] ARM: rpi: fixup prefix property from VideoCore FDT Ahmad Fatoum
2023-04-17 7:08 ` [PATCH 1/2] of: implement of_copy_property Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-04-14 18:35 UTC (permalink / raw)
To: barebox; +Cc: Daniel Brát, Ahmad Fatoum
For use in fixups, it can be useful to copy a property verbatim from the
barebox DT to the kernel DT. Add a helper that does just that.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/of/base.c | 16 ++++++++++++++++
include/of.h | 10 ++++++++++
test/self/of_manipulation.c | 2 +-
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 01bb7e3906b4..5644e8e9534d 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2318,6 +2318,22 @@ struct property *of_rename_property(struct device_node *np,
return pp;
}
+struct property *of_copy_property(const struct device_node *src,
+ const char *propname,
+ struct device_node *dst)
+{
+ struct property *prop;
+
+ prop = of_find_property(src, propname, NULL);
+ if (!prop)
+ return NULL;
+
+ return of_new_property(dst, propname,
+ of_property_get_value(prop), prop->length);
+}
+EXPORT_SYMBOL_GPL(of_copy_property);
+
+
/**
* of_set_property - create a property for a given node
* @node - the node
diff --git a/include/of.h b/include/of.h
index 22358f5579ec..4b0266fd3118 100644
--- a/include/of.h
+++ b/include/of.h
@@ -152,6 +152,9 @@ extern struct property *__of_new_property(struct device_node *node,
extern void of_delete_property(struct property *pp);
extern struct property *of_rename_property(struct device_node *np,
const char *old_name, const char *new_name);
+extern struct property *of_copy_property(const struct device_node *src,
+ const char *propname,
+ struct device_node *dst);
extern struct device_node *of_find_node_by_name(struct device_node *from,
const char *name);
@@ -576,6 +579,13 @@ static inline struct property *__of_new_property(struct device_node *node,
return NULL;
}
+static inline struct property *of_copy_property(const struct device_node *src,
+ const char *propname,
+ struct device_node *dst)
+{
+ return NULL;
+}
+
static inline void of_delete_property(struct property *pp)
{
}
diff --git a/test/self/of_manipulation.c b/test/self/of_manipulation.c
index f7f95fa269af..64913ac1eab8 100644
--- a/test/self/of_manipulation.c
+++ b/test/self/of_manipulation.c
@@ -63,7 +63,7 @@ static void test_of_basics(struct device_node *root)
of_property_write_u32(node2, "property2", 2);
of_property_write_u32(node1, "property3", 1);
- of_property_write_u32(node1, "property2", 2);
+ of_copy_property(node2, "property2", node1);
of_rename_property(node1, "property3", "property1");
assert_equal(node1, node2);
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] ARM: rpi: fixup prefix property from VideoCore FDT
2023-04-14 18:35 [PATCH 1/2] of: implement of_copy_property Ahmad Fatoum
@ 2023-04-14 18:35 ` Ahmad Fatoum
2023-04-17 7:08 ` [PATCH 1/2] of: implement of_copy_property Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-04-14 18:35 UTC (permalink / raw)
To: barebox; +Cc: Daniel Brát, Ahmad Fatoum
barebox will warn about lack of these properties when network booting.
To make network booted barebox behave identically to flashed barebox,
let's unconditionally copy them from VideoCore FDT into fixed up FDT.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/boards/raspberry-pi/rpi-common.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 3ed4510296ea..319a3d85ead5 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -256,6 +256,21 @@ static enum reset_src_type rpi_decode_pm_rsts(struct device_node *chosen,
return RESET_UKWN;
}
+static int rpi_vc_fdt_fixup(struct device_node *root, void *data)
+{
+ const struct device_node *vc_chosen = data;
+ struct device_node *chosen;
+
+ chosen = of_create_node(root, "/chosen");
+ if (!chosen)
+ return -ENOMEM;
+
+ of_copy_property(vc_chosen, "overlay_prefix", chosen);
+ of_copy_property(vc_chosen, "os_prefix", chosen);
+
+ return 0;
+}
+
static u32 rpi_boot_mode, rpi_boot_part;
/* Extract useful information from the VideoCore FDT we got.
* Some parameters are defined here:
@@ -289,6 +304,8 @@ static void rpi_vc_fdt_parse(void *fdt)
goto out;
}
+ of_register_fixup(rpi_vc_fdt_fixup, of_dup(chosen));
+
bootloader = of_find_node_by_name(chosen, "bootloader");
str = of_read_vc_string(chosen, "bootargs");
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] of: implement of_copy_property
2023-04-14 18:35 [PATCH 1/2] of: implement of_copy_property Ahmad Fatoum
2023-04-14 18:35 ` [PATCH 2/2] ARM: rpi: fixup prefix property from VideoCore FDT Ahmad Fatoum
@ 2023-04-17 7:08 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-04-17 7:08 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, Daniel Brát
On Fri, Apr 14, 2023 at 08:35:44PM +0200, Ahmad Fatoum wrote:
> For use in fixups, it can be useful to copy a property verbatim from the
> barebox DT to the kernel DT. Add a helper that does just that.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> drivers/of/base.c | 16 ++++++++++++++++
> include/of.h | 10 ++++++++++
> test/self/of_manipulation.c | 2 +-
> 3 files changed, 27 insertions(+), 1 deletion(-)
Applied, thanks
Sascha
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 01bb7e3906b4..5644e8e9534d 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -2318,6 +2318,22 @@ struct property *of_rename_property(struct device_node *np,
> return pp;
> }
>
> +struct property *of_copy_property(const struct device_node *src,
> + const char *propname,
> + struct device_node *dst)
> +{
> + struct property *prop;
> +
> + prop = of_find_property(src, propname, NULL);
> + if (!prop)
> + return NULL;
> +
> + return of_new_property(dst, propname,
> + of_property_get_value(prop), prop->length);
> +}
> +EXPORT_SYMBOL_GPL(of_copy_property);
> +
> +
> /**
> * of_set_property - create a property for a given node
> * @node - the node
> diff --git a/include/of.h b/include/of.h
> index 22358f5579ec..4b0266fd3118 100644
> --- a/include/of.h
> +++ b/include/of.h
> @@ -152,6 +152,9 @@ extern struct property *__of_new_property(struct device_node *node,
> extern void of_delete_property(struct property *pp);
> extern struct property *of_rename_property(struct device_node *np,
> const char *old_name, const char *new_name);
> +extern struct property *of_copy_property(const struct device_node *src,
> + const char *propname,
> + struct device_node *dst);
>
> extern struct device_node *of_find_node_by_name(struct device_node *from,
> const char *name);
> @@ -576,6 +579,13 @@ static inline struct property *__of_new_property(struct device_node *node,
> return NULL;
> }
>
> +static inline struct property *of_copy_property(const struct device_node *src,
> + const char *propname,
> + struct device_node *dst)
> +{
> + return NULL;
> +}
> +
> static inline void of_delete_property(struct property *pp)
> {
> }
> diff --git a/test/self/of_manipulation.c b/test/self/of_manipulation.c
> index f7f95fa269af..64913ac1eab8 100644
> --- a/test/self/of_manipulation.c
> +++ b/test/self/of_manipulation.c
> @@ -63,7 +63,7 @@ static void test_of_basics(struct device_node *root)
> of_property_write_u32(node2, "property2", 2);
>
> of_property_write_u32(node1, "property3", 1);
> - of_property_write_u32(node1, "property2", 2);
> + of_copy_property(node2, "property2", node1);
> of_rename_property(node1, "property3", "property1");
>
> assert_equal(node1, node2);
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-17 7:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14 18:35 [PATCH 1/2] of: implement of_copy_property Ahmad Fatoum
2023-04-14 18:35 ` [PATCH 2/2] ARM: rpi: fixup prefix property from VideoCore FDT Ahmad Fatoum
2023-04-17 7:08 ` [PATCH 1/2] of: implement of_copy_property Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox