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

device property: Use multi-connection matchers for single case

The newly introduced helpers for searching for matches in the case of
multiple connections can be resused by the single-connection case, so do
this to save some duplication.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220422222351.1297276-3-bjorn.andersson@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Bjorn Andersson and committed by
Greg Kroah-Hartman
bcd6a517 7a20917d

+5 -50
+5 -50
drivers/base/property.c
··· 1193 1193 } 1194 1194 EXPORT_SYMBOL_GPL(device_get_match_data); 1195 1195 1196 - static void * 1197 - fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id, 1198 - void *data, devcon_match_fn_t match) 1199 - { 1200 - struct fwnode_handle *node; 1201 - struct fwnode_handle *ep; 1202 - void *ret; 1203 - 1204 - fwnode_graph_for_each_endpoint(fwnode, ep) { 1205 - node = fwnode_graph_get_remote_port_parent(ep); 1206 - if (!fwnode_device_is_available(node)) { 1207 - fwnode_handle_put(node); 1208 - continue; 1209 - } 1210 - 1211 - ret = match(node, con_id, data); 1212 - fwnode_handle_put(node); 1213 - if (ret) { 1214 - fwnode_handle_put(ep); 1215 - return ret; 1216 - } 1217 - } 1218 - return NULL; 1219 - } 1220 - 1221 1196 static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode, 1222 1197 const char *con_id, void *data, 1223 1198 devcon_match_fn_t match, ··· 1225 1250 } 1226 1251 } 1227 1252 return count; 1228 - } 1229 - 1230 - static void * 1231 - fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id, 1232 - void *data, devcon_match_fn_t match) 1233 - { 1234 - struct fwnode_handle *node; 1235 - void *ret; 1236 - int i; 1237 - 1238 - for (i = 0; ; i++) { 1239 - node = fwnode_find_reference(fwnode, con_id, i); 1240 - if (IS_ERR(node)) 1241 - break; 1242 - 1243 - ret = match(node, NULL, data); 1244 - fwnode_handle_put(node); 1245 - if (ret) 1246 - return ret; 1247 - } 1248 - 1249 - return NULL; 1250 1253 } 1251 1254 1252 1255 static unsigned int fwnode_devcon_matches(struct fwnode_handle *fwnode, ··· 1273 1320 const char *con_id, void *data, 1274 1321 devcon_match_fn_t match) 1275 1322 { 1323 + unsigned int count; 1276 1324 void *ret; 1277 1325 1278 1326 if (!fwnode || !match) 1279 1327 return NULL; 1280 1328 1281 - ret = fwnode_graph_devcon_match(fwnode, con_id, data, match); 1282 - if (ret) 1329 + count = fwnode_graph_devcon_matches(fwnode, con_id, data, match, &ret, 1); 1330 + if (count) 1283 1331 return ret; 1284 1332 1285 - return fwnode_devcon_match(fwnode, con_id, data, match); 1333 + count = fwnode_devcon_matches(fwnode, con_id, data, match, &ret, 1); 1334 + return count ? ret : NULL; 1286 1335 } 1287 1336 EXPORT_SYMBOL_GPL(fwnode_connection_find_match); 1288 1337