[PATCH 3/7] of: partition: implement of_partition_ensure_probed
Ahmad Fatoum
a.fatoum at pengutronix.de
Sun Jun 27 23:45:13 PDT 2021
The device tree nodes for both barebox environment and state can have
phandles that reference partitions. Environment runs at late_initcall
level, so deep probe will have populated the device by the time the
probe is called. barebox-state however is probed at device_initcall
level and thus must take care itself to ensure the partition provider is
probed. Add a new of_partition_ensure_probed that does this. It can
handle both legacy and new style (fixed) partitions.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/of/partition.c | 11 +++++++++++
include/of.h | 6 ++++++
2 files changed, 17 insertions(+)
diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index b6d0523fd960..10081363deee 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -118,6 +118,17 @@ int of_parse_partitions(struct cdev *cdev, struct device_node *node)
return 0;
}
+int of_partition_ensure_probed(struct device_node *np)
+{
+ np = of_get_parent(np);
+
+ if (of_device_is_compatible(np, "fixed-partitions"))
+ np = of_get_parent(np);
+
+ return np ? of_device_ensure_probed(np) : -EINVAL;
+}
+EXPORT_SYMBOL_GPL(of_partition_ensure_probed);
+
static void delete_subnodes(struct device_node *np)
{
struct device_node *part, *tmp;
diff --git a/include/of.h b/include/of.h
index 677f48d0aba1..4042d8dee8d4 100644
--- a/include/of.h
+++ b/include/of.h
@@ -283,6 +283,7 @@ extern int of_device_ensure_probed(struct device_node *np);
extern int of_device_ensure_probed_by_alias(const char *alias);
extern int of_devices_ensure_probed_by_property(const char *property_name);
extern int of_devices_ensure_probed_by_dev_id(const struct of_device_id *ids);
+extern int of_partition_ensure_probed(struct device_node *np);
struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node);
int of_parse_partitions(struct cdev *cdev, struct device_node *node);
@@ -398,6 +399,11 @@ of_devices_ensure_probed_by_dev_id(const struct of_device_id *ids)
return 0;
}
+static inline int of_partition_ensure_probed(struct device_node *np)
+{
+ return 0;
+}
+
static inline int of_bus_n_addr_cells(struct device_node *np)
{
return 0;
--
2.30.2
More information about the barebox
mailing list