Skip to content

Commit d7cf559

Browse files
Heikki Krogerusgregkh
authored andcommitted
device property: Move fwnode_connection_find_match() under drivers/base/property.c
The function is now only a helper that searches the connection from device graph and then by checking if the supplied connection identifier matches a property that contains reference. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20200907120532.37611-2-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 28d9fdf commit d7cf559

5 files changed

Lines changed: 88 additions & 111 deletions

File tree

‎drivers/base/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ obj-y := component.o core.o bus.o dd.o syscore.o \
66
cpu.o firmware.o init.o map.o devres.o \
77
attribute_container.o transport_class.o \
88
topology.o container.o property.o cacheinfo.o \
9-
devcon.o swnode.o
9+
swnode.o
1010
obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
1111
obj-y += power/
1212
obj-$(CONFIG_ISA_BUS_API) += isa.o

‎drivers/base/devcon.c‎

Lines changed: 0 additions & 101 deletions
This file was deleted.

‎drivers/base/property.c‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,3 +1184,76 @@ const void *device_get_match_data(struct device *dev)
11841184
return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev);
11851185
}
11861186
EXPORT_SYMBOL_GPL(device_get_match_data);
1187+
1188+
static void *
1189+
fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
1190+
void *data, devcon_match_fn_t match)
1191+
{
1192+
struct fwnode_handle *node;
1193+
struct fwnode_handle *ep;
1194+
void *ret;
1195+
1196+
fwnode_graph_for_each_endpoint(fwnode, ep) {
1197+
node = fwnode_graph_get_remote_port_parent(ep);
1198+
if (!fwnode_device_is_available(node))
1199+
continue;
1200+
1201+
ret = match(node, con_id, data);
1202+
fwnode_handle_put(node);
1203+
if (ret) {
1204+
fwnode_handle_put(ep);
1205+
return ret;
1206+
}
1207+
}
1208+
return NULL;
1209+
}
1210+
1211+
static void *
1212+
fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
1213+
void *data, devcon_match_fn_t match)
1214+
{
1215+
struct fwnode_handle *node;
1216+
void *ret;
1217+
int i;
1218+
1219+
for (i = 0; ; i++) {
1220+
node = fwnode_find_reference(fwnode, con_id, i);
1221+
if (IS_ERR(node))
1222+
break;
1223+
1224+
ret = match(node, NULL, data);
1225+
fwnode_handle_put(node);
1226+
if (ret)
1227+
return ret;
1228+
}
1229+
1230+
return NULL;
1231+
}
1232+
1233+
/**
1234+
* fwnode_connection_find_match - Find connection from a device node
1235+
* @fwnode: Device node with the connection
1236+
* @con_id: Identifier for the connection
1237+
* @data: Data for the match function
1238+
* @match: Function to check and convert the connection description
1239+
*
1240+
* Find a connection with unique identifier @con_id between @fwnode and another
1241+
* device node. @match will be used to convert the connection description to
1242+
* data the caller is expecting to be returned.
1243+
*/
1244+
void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
1245+
const char *con_id, void *data,
1246+
devcon_match_fn_t match)
1247+
{
1248+
void *ret;
1249+
1250+
if (!fwnode || !match)
1251+
return NULL;
1252+
1253+
ret = fwnode_graph_devcon_match(fwnode, con_id, data, match);
1254+
if (ret)
1255+
return ret;
1256+
1257+
return fwnode_devcon_match(fwnode, con_id, data, match);
1258+
}
1259+
EXPORT_SYMBOL_GPL(fwnode_connection_find_match);

‎include/linux/device.h‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,6 @@ struct device_dma_parameters {
292292
unsigned long segment_boundary_mask;
293293
};
294294

295-
typedef void *(*devcon_match_fn_t)(struct fwnode_handle *fwnode, const char *id,
296-
void *data);
297-
298-
void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
299-
const char *con_id, void *data,
300-
devcon_match_fn_t match);
301-
void *device_connection_find_match(struct device *dev, const char *con_id,
302-
void *data, devcon_match_fn_t match);
303-
304295
/**
305296
* enum device_link_state - Device link states.
306297
* @DL_STATE_NONE: The presence of the drivers is not being tracked.

‎include/linux/property.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,20 @@ fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode,
418418
int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
419419
struct fwnode_endpoint *endpoint);
420420

421+
typedef void *(*devcon_match_fn_t)(struct fwnode_handle *fwnode, const char *id,
422+
void *data);
423+
424+
void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
425+
const char *con_id, void *data,
426+
devcon_match_fn_t match);
427+
428+
static inline void *device_connection_find_match(struct device *dev,
429+
const char *con_id, void *data,
430+
devcon_match_fn_t match)
431+
{
432+
return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match);
433+
}
434+
421435
/* -------------------------------------------------------------------------- */
422436
/* Software fwnode support - when HW description is incomplete or missing */
423437

0 commit comments

Comments
 (0)