[PATCH v10 7/7] of: property: Add "depends-on" parsing support to of_fwnode_add_links()

From: Saravana Kannan
Date: Thu Aug 29 2019 - 03:46:36 EST


If dependencies inferred by of_fwnode_add_links() result in a cycle, it
can prevent the probing of all the devices in the cycle. The depends-on
property has been added to explicitly override inferred dependencies
when they create a cycle.

Add depends-on parsing support to of_fwnode_add_links() so that
platforms with cyclic dependencies can use "depends-on" to break the
cycle and continue successfully probing devices.

Signed-off-by: Saravana Kannan <saravanak@xxxxxxxxxx>
---
drivers/of/property.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 420c2d428184..78a262e24686 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1106,6 +1106,12 @@ static struct device_node *parse_interconnects(struct device_node *np,
"#interconnect-cells");
}

+static struct device_node *parse_depends_on(struct device_node *np,
+ const char *prop_name, int index)
+{
+ return parse_prop_cells(np, prop_name, index, "depends-on", NULL);
+}
+
static int strcmp_suffix(const char *str, const char *suffix)
{
unsigned int len, suffix_len;
@@ -1151,6 +1157,7 @@ static const struct supplier_bindings bindings[] = {
{ .parse_prop = parse_clocks, },
{ .parse_prop = parse_interconnects, },
{ .parse_prop = parse_regulators, },
+ { .parse_prop = parse_depends_on, },
{},
};

@@ -1203,6 +1210,12 @@ static int __of_link_to_suppliers(struct device *dev,
struct property *p;
int ret = 0;

+ if (of_find_property(con_np, "depends-on", NULL)) {
+ if (of_link_property(dev, con_np, "depends-on"))
+ ret = -EAGAIN;
+ return ret;
+ }
+
for_each_property_of_node(con_np, p)
if (of_link_property(dev, con_np, p->name))
ret = -EAGAIN;
--
2.23.0.187.g17f5b7556c-goog