Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Heikki Krogerus and committed by
Greg Kroah-Hartman
d7cf5590 28d9fdf0

+88 -111
+1 -1
drivers/base/Makefile
··· 6 6 cpu.o firmware.o init.o map.o devres.o \ 7 7 attribute_container.o transport_class.o \ 8 8 topology.o container.o property.o cacheinfo.o \ 9 - devcon.o swnode.o 9 + swnode.o 10 10 obj-$(CONFIG_DEVTMPFS) += devtmpfs.o 11 11 obj-y += power/ 12 12 obj-$(CONFIG_ISA_BUS_API) += isa.o
-101
drivers/base/devcon.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /** 3 - * Device connections 4 - * 5 - * Copyright (C) 2018 Intel Corporation 6 - * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com> 7 - */ 8 - 9 - #include <linux/device.h> 10 - #include <linux/property.h> 11 - 12 - static void * 13 - fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id, 14 - void *data, devcon_match_fn_t match) 15 - { 16 - struct fwnode_handle *node; 17 - struct fwnode_handle *ep; 18 - void *ret; 19 - 20 - fwnode_graph_for_each_endpoint(fwnode, ep) { 21 - node = fwnode_graph_get_remote_port_parent(ep); 22 - if (!fwnode_device_is_available(node)) 23 - continue; 24 - 25 - ret = match(node, con_id, data); 26 - fwnode_handle_put(node); 27 - if (ret) { 28 - fwnode_handle_put(ep); 29 - return ret; 30 - } 31 - } 32 - return NULL; 33 - } 34 - 35 - static void * 36 - fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id, 37 - void *data, devcon_match_fn_t match) 38 - { 39 - struct fwnode_handle *node; 40 - void *ret; 41 - int i; 42 - 43 - for (i = 0; ; i++) { 44 - node = fwnode_find_reference(fwnode, con_id, i); 45 - if (IS_ERR(node)) 46 - break; 47 - 48 - ret = match(node, NULL, data); 49 - fwnode_handle_put(node); 50 - if (ret) 51 - return ret; 52 - } 53 - 54 - return NULL; 55 - } 56 - 57 - /** 58 - * fwnode_connection_find_match - Find connection from a device node 59 - * @fwnode: Device node with the connection 60 - * @con_id: Identifier for the connection 61 - * @data: Data for the match function 62 - * @match: Function to check and convert the connection description 63 - * 64 - * Find a connection with unique identifier @con_id between @fwnode and another 65 - * device node. @match will be used to convert the connection description to 66 - * data the caller is expecting to be returned. 67 - */ 68 - void *fwnode_connection_find_match(struct fwnode_handle *fwnode, 69 - const char *con_id, void *data, 70 - devcon_match_fn_t match) 71 - { 72 - void *ret; 73 - 74 - if (!fwnode || !match) 75 - return NULL; 76 - 77 - ret = fwnode_graph_devcon_match(fwnode, con_id, data, match); 78 - if (ret) 79 - return ret; 80 - 81 - return fwnode_devcon_match(fwnode, con_id, data, match); 82 - } 83 - EXPORT_SYMBOL_GPL(fwnode_connection_find_match); 84 - 85 - /** 86 - * device_connection_find_match - Find physical connection to a device 87 - * @dev: Device with the connection 88 - * @con_id: Identifier for the connection 89 - * @data: Data for the match function 90 - * @match: Function to check and convert the connection description 91 - * 92 - * Find a connection with unique identifier @con_id between @dev and another 93 - * device. @match will be used to convert the connection description to data the 94 - * caller is expecting to be returned. 95 - */ 96 - void *device_connection_find_match(struct device *dev, const char *con_id, 97 - void *data, devcon_match_fn_t match) 98 - { 99 - return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match); 100 - } 101 - EXPORT_SYMBOL_GPL(device_connection_find_match);
+73
drivers/base/property.c
··· 1184 1184 return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev); 1185 1185 } 1186 1186 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);
-9
include/linux/device.h
··· 292 292 unsigned long segment_boundary_mask; 293 293 }; 294 294 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 - 304 295 /** 305 296 * enum device_link_state - Device link states. 306 297 * @DL_STATE_NONE: The presence of the drivers is not being tracked.
+14
include/linux/property.h
··· 418 418 int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, 419 419 struct fwnode_endpoint *endpoint); 420 420 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 + 421 435 /* -------------------------------------------------------------------------- */ 422 436 /* Software fwnode support - when HW description is incomplete or missing */ 423 437