[PATCH v2 2/3] FIXUP: "device connection: Find connections also by checking the references"
From: Hans de Goede
Date: Wed Apr 17 2019 - 17:00:59 EST
The reference we are looking for might be in a child node, rather then
directly in the device's own fwnode. A typical example of this is a
usb connector node with references to various muxes / switches.
Note that we do not hit this problem for the device_connection_find_match
calls in typec_switch_get and typec_mux_get because these get called
from typec_register_port and typec_register_port creates a new device
with its fwnode pointing to the usb-connector fwnode and that new
device (rather then the parent) is passed to typec_switch/mux_get and
thus to device_connection_find_match.
Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
drivers/base/devcon.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c
index 4cdf95532b63..6f6f870c21eb 100644
--- a/drivers/base/devcon.c
+++ b/drivers/base/devcon.c
@@ -76,7 +76,7 @@ fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
void *device_connection_find_match(struct device *dev, const char *con_id,
void *data, devcon_match_fn_t match)
{
- struct fwnode_handle *fwnode = dev_fwnode(dev);
+ struct fwnode_handle *child, *fwnode = dev_fwnode(dev);
const char *devname = dev_name(dev);
struct device_connection *con;
void *ret = NULL;
@@ -93,6 +93,12 @@ void *device_connection_find_match(struct device *dev, const char *con_id,
ret = fwnode_devcon_match(fwnode, con_id, data, match);
if (ret)
return ret;
+
+ fwnode_for_each_child_node(fwnode, child) {
+ ret = fwnode_devcon_match(child, con_id, data, match);
+ if (ret)
+ return ret;
+ }
}
mutex_lock(&devcon_lock);
--
2.21.0
--------------D211A57CD2C7E9759BD27377
Content-Type: text/x-patch;
name="0003-usb-roles-Check-for-NULL-con_id.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="0003-usb-roles-Check-for-NULL-con_id.patch"