Skip to content

Commit fde7777

Browse files
Heikki Krogerusrafaeljw
authored andcommitted
device connection: Find connections also by checking the references
We can also use this API to find named references that the device nodes have by using fwnode_property_get_reference_args() function. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 83b34af commit fde7777

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

drivers/base/devcon.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
3838
return NULL;
3939
}
4040

41+
static void *
42+
fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
43+
void *data, devcon_match_fn_t match)
44+
{
45+
struct device_connection con = { };
46+
void *ret;
47+
int i;
48+
49+
for (i = 0; ; i++) {
50+
con.fwnode = fwnode_find_reference(fwnode, con_id, i);
51+
if (IS_ERR(con.fwnode))
52+
break;
53+
54+
ret = match(&con, -1, data);
55+
fwnode_handle_put(con.fwnode);
56+
if (ret)
57+
return ret;
58+
}
59+
60+
return NULL;
61+
}
62+
4163
/**
4264
* device_connection_find_match - Find physical connection to a device
4365
* @dev: Device with the connection
@@ -65,6 +87,10 @@ void *device_connection_find_match(struct device *dev, const char *con_id,
6587
ret = fwnode_graph_devcon_match(fwnode, con_id, data, match);
6688
if (ret)
6789
return ret;
90+
91+
ret = fwnode_devcon_match(fwnode, con_id, data, match);
92+
if (ret)
93+
return ret;
6894
}
6995

7096
mutex_lock(&devcon_lock);

drivers/usb/roles/class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void *usb_role_switch_match(struct device_connection *con, int ep,
101101
struct device *dev;
102102

103103
if (con->fwnode) {
104-
if (!fwnode_property_present(con->fwnode, con->id))
104+
if (con->id && !fwnode_property_present(con->fwnode, con->id))
105105
return NULL;
106106

107107
dev = class_find_device(role_class, NULL, con->fwnode,

0 commit comments

Comments
 (0)