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

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>

authored by

Heikki Krogerus and committed by
Rafael J. Wysocki
fde77779 83b34afb

+27 -1
+26
drivers/base/devcon.c
··· 38 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 64 * device_connection_find_match - Find physical connection to a device 43 65 * @dev: Device with the connection ··· 85 63 86 64 if (fwnode) { 87 65 ret = fwnode_graph_devcon_match(fwnode, con_id, data, match); 66 + if (ret) 67 + return ret; 68 + 69 + ret = fwnode_devcon_match(fwnode, con_id, data, match); 88 70 if (ret) 89 71 return ret; 90 72 }
+1 -1
drivers/usb/roles/class.c
··· 101 101 struct device *dev; 102 102 103 103 if (con->fwnode) { 104 - if (!fwnode_property_present(con->fwnode, con->id)) 104 + if (con->id && !fwnode_property_present(con->fwnode, con->id)) 105 105 return NULL; 106 106 107 107 dev = class_find_device(role_class, NULL, con->fwnode,