diff options
Diffstat (limited to 'drivers/base/devcon.c')
-rw-r--r-- | drivers/base/devcon.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c index 1d488dc5dd0c..14e2178e09f8 100644 --- a/drivers/base/devcon.c +++ b/drivers/base/devcon.c | |||
@@ -12,9 +12,6 @@ | |||
12 | static DEFINE_MUTEX(devcon_lock); | 12 | static DEFINE_MUTEX(devcon_lock); |
13 | static LIST_HEAD(devcon_list); | 13 | static LIST_HEAD(devcon_list); |
14 | 14 | ||
15 | typedef void *(*devcon_match_fn_t)(struct device_connection *con, int ep, | ||
16 | void *data); | ||
17 | |||
18 | static void * | 15 | static void * |
19 | fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id, | 16 | fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id, |
20 | void *data, devcon_match_fn_t match) | 17 | void *data, devcon_match_fn_t match) |
@@ -61,6 +58,34 @@ fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id, | |||
61 | } | 58 | } |
62 | 59 | ||
63 | /** | 60 | /** |
61 | * fwnode_connection_find_match - Find connection from a device node | ||
62 | * @fwnode: Device node with the connection | ||
63 | * @con_id: Identifier for the connection | ||
64 | * @data: Data for the match function | ||
65 | * @match: Function to check and convert the connection description | ||
66 | * | ||
67 | * Find a connection with unique identifier @con_id between @fwnode and another | ||
68 | * device node. @match will be used to convert the connection description to | ||
69 | * data the caller is expecting to be returned. | ||
70 | */ | ||
71 | void *fwnode_connection_find_match(struct fwnode_handle *fwnode, | ||
72 | const char *con_id, void *data, | ||
73 | devcon_match_fn_t match) | ||
74 | { | ||
75 | void *ret; | ||
76 | |||
77 | if (!fwnode || !match) | ||
78 | return NULL; | ||
79 | |||
80 | ret = fwnode_graph_devcon_match(fwnode, con_id, data, match); | ||
81 | if (ret) | ||
82 | return ret; | ||
83 | |||
84 | return fwnode_devcon_match(fwnode, con_id, data, match); | ||
85 | } | ||
86 | EXPORT_SYMBOL_GPL(fwnode_connection_find_match); | ||
87 | |||
88 | /** | ||
64 | * device_connection_find_match - Find physical connection to a device | 89 | * device_connection_find_match - Find physical connection to a device |
65 | * @dev: Device with the connection | 90 | * @dev: Device with the connection |
66 | * @con_id: Identifier for the connection | 91 | * @con_id: Identifier for the connection |
@@ -83,15 +108,9 @@ void *device_connection_find_match(struct device *dev, const char *con_id, | |||
83 | if (!match) | 108 | if (!match) |
84 | return NULL; | 109 | return NULL; |
85 | 110 | ||
86 | if (fwnode) { | 111 | ret = fwnode_connection_find_match(fwnode, con_id, data, match); |
87 | ret = fwnode_graph_devcon_match(fwnode, con_id, data, match); | 112 | if (ret) |
88 | if (ret) | 113 | return ret; |
89 | return ret; | ||
90 | |||
91 | ret = fwnode_devcon_match(fwnode, con_id, data, match); | ||
92 | if (ret) | ||
93 | return ret; | ||
94 | } | ||
95 | 114 | ||
96 | mutex_lock(&devcon_lock); | 115 | mutex_lock(&devcon_lock); |
97 | 116 | ||