Skip to content

Commit f4653ec

Browse files
Saravana Kannanrobherring
authored andcommitted
of: property: Improve finding the consumer of a remote-endpoint property
We have a more accurate function to find the right consumer of a remote-endpoint property instead of searching for a parent with compatible string property. So, use that instead. While at it, make the code to find the consumer a bit more flexible and based on the property being parsed. Fixes: f7514a6 ("of: property: fw_devlink: Add support for remote-endpoint") Signed-off-by: Saravana Kannan <saravanak@google.com> Link: https://lore.kernel.org/r/20240207011803.2637531-2-saravanak@google.com Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 17adc3f commit f4653ec

File tree

1 file changed

+10
-37
lines changed

1 file changed

+10
-37
lines changed

drivers/of/property.c

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,36 +1063,6 @@ of_fwnode_device_get_match_data(const struct fwnode_handle *fwnode,
10631063
return of_device_get_match_data(dev);
10641064
}
10651065

1066-
static struct device_node *of_get_compat_node(struct device_node *np)
1067-
{
1068-
of_node_get(np);
1069-
1070-
while (np) {
1071-
if (!of_device_is_available(np)) {
1072-
of_node_put(np);
1073-
np = NULL;
1074-
}
1075-
1076-
if (of_property_present(np, "compatible"))
1077-
break;
1078-
1079-
np = of_get_next_parent(np);
1080-
}
1081-
1082-
return np;
1083-
}
1084-
1085-
static struct device_node *of_get_compat_node_parent(struct device_node *np)
1086-
{
1087-
struct device_node *parent, *node;
1088-
1089-
parent = of_get_parent(np);
1090-
node = of_get_compat_node(parent);
1091-
of_node_put(parent);
1092-
1093-
return node;
1094-
}
1095-
10961066
static void of_link_to_phandle(struct device_node *con_np,
10971067
struct device_node *sup_np)
10981068
{
@@ -1222,10 +1192,10 @@ static struct device_node *parse_##fname(struct device_node *np, \
12221192
* parse_prop.prop_name: Name of property holding a phandle value
12231193
* parse_prop.index: For properties holding a list of phandles, this is the
12241194
* index into the list
1195+
* @get_con_dev: If the consumer node containing the property is never converted
1196+
* to a struct device, implement this ops so fw_devlink can use it
1197+
* to find the true consumer.
12251198
* @optional: Describes whether a supplier is mandatory or not
1226-
* @node_not_dev: The consumer node containing the property is never converted
1227-
* to a struct device. Instead, parse ancestor nodes for the
1228-
* compatible property to find a node corresponding to a device.
12291199
*
12301200
* Returns:
12311201
* parse_prop() return values are
@@ -1236,8 +1206,8 @@ static struct device_node *parse_##fname(struct device_node *np, \
12361206
struct supplier_bindings {
12371207
struct device_node *(*parse_prop)(struct device_node *np,
12381208
const char *prop_name, int index);
1209+
struct device_node *(*get_con_dev)(struct device_node *np);
12391210
bool optional;
1240-
bool node_not_dev;
12411211
};
12421212

12431213
DEFINE_SIMPLE_PROP(clocks, "clocks", "#clock-cells")
@@ -1352,7 +1322,10 @@ static const struct supplier_bindings of_supplier_bindings[] = {
13521322
{ .parse_prop = parse_pinctrl6, },
13531323
{ .parse_prop = parse_pinctrl7, },
13541324
{ .parse_prop = parse_pinctrl8, },
1355-
{ .parse_prop = parse_remote_endpoint, .node_not_dev = true, },
1325+
{
1326+
.parse_prop = parse_remote_endpoint,
1327+
.get_con_dev = of_graph_get_port_parent,
1328+
},
13561329
{ .parse_prop = parse_pwms, },
13571330
{ .parse_prop = parse_resets, },
13581331
{ .parse_prop = parse_leds, },
@@ -1403,8 +1376,8 @@ static int of_link_property(struct device_node *con_np, const char *prop_name)
14031376
while ((phandle = s->parse_prop(con_np, prop_name, i))) {
14041377
struct device_node *con_dev_np;
14051378

1406-
con_dev_np = s->node_not_dev
1407-
? of_get_compat_node_parent(con_np)
1379+
con_dev_np = s->get_con_dev
1380+
? s->get_con_dev(con_np)
14081381
: of_node_get(con_np);
14091382
matched = true;
14101383
i++;

0 commit comments

Comments
 (0)