diff options
author | Heikki Krogerus <heikki.krogerus@linux.intel.com> | 2019-05-31 10:15:40 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2019-06-03 04:55:38 -0400 |
commit | fde777791eb83f6c5845b81af89de6be60a2b2ce (patch) | |
tree | 6a5800a2ed670460a797d7a2f38cd1979a96e14e /drivers/base/devcon.c | |
parent | 83b34afb6b79c69f5478a7249451cab858af97d6 (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>
Diffstat (limited to 'drivers/base/devcon.c')
-rw-r--r-- | drivers/base/devcon.c | 26 |
1 files changed, 26 insertions, 0 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 | ||
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 | |||
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); |