aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2019-05-31 10:15:40 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2019-06-03 04:55:38 -0400
commitfde777791eb83f6c5845b81af89de6be60a2b2ce (patch)
tree6a5800a2ed670460a797d7a2f38cd1979a96e14e
parent83b34afb6b79c69f5478a7249451cab858af97d6 (diff)
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>
-rw-r--r--drivers/base/devcon.c26
-rw-r--r--drivers/usb/roles/class.c2
2 files changed, 27 insertions, 1 deletions
diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c
index 04db9ae235e4..f7035fc12b92 100644
--- a/drivers/base/devcon.c
+++ b/drivers/base/devcon.c
@@ -38,6 +38,28 @@ fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
38 return NULL; 38 return NULL;
39} 39}
40 40
41static void *
42fwnode_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
41/** 63/**
42 * device_connection_find_match - Find physical connection to a device 64 * device_connection_find_match - Find physical connection to a device
43 * @dev: Device with the connection 65 * @dev: Device with the connection
@@ -65,6 +87,10 @@ void *device_connection_find_match(struct device *dev, const char *con_id,
65 ret = fwnode_graph_devcon_match(fwnode, con_id, data, match); 87 ret = fwnode_graph_devcon_match(fwnode, con_id, data, match);
66 if (ret) 88 if (ret)
67 return ret; 89 return ret;
90
91 ret = fwnode_devcon_match(fwnode, con_id, data, match);
92 if (ret)
93 return ret;
68 } 94 }
69 95
70 mutex_lock(&devcon_lock); 96 mutex_lock(&devcon_lock);
diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index f45d8df5cfb8..86defca6623e 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -101,7 +101,7 @@ static void *usb_role_switch_match(struct device_connection *con, int ep,
101 struct device *dev; 101 struct device *dev;
102 102
103 if (con->fwnode) { 103 if (con->fwnode) {
104 if (!fwnode_property_present(con->fwnode, con->id)) 104 if (con->id && !fwnode_property_present(con->fwnode, con->id))
105 return NULL; 105 return NULL;
106 106
107 dev = class_find_device(role_class, NULL, con->fwnode, 107 dev = class_find_device(role_class, NULL, con->fwnode,