Skip to contentSkip to conversation

usb: typec: retimer: Add missing id check in match callback

PATCH In review Nícolas F. R. A. Prado 3 participants 3 messages Jul 25, 2022 – Aug 2, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: typec: retimer: Add missing id check in match callback

The fwnode_connection_find_match() function handles two cases: named references and graph endpoints. In the second case, the match function passed in is called with the id to check for the match. However, the match function for the recently added type-c retimer class assumes the connection has already been matched (which is only true for the first case).

The result is that with that change, all type-c nodes with graph endpoints defer probe indefinitely, independently of having a retimer connection or not.

Add the missing check, like is done by the type-c mux and usb role switch code, to fix the issue.

Fixes ddaf8d96f93b ("usb: typec: Add support for retimers")

---

 drivers/usb/typec/retimer.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/usb/typec/retimer.c +7 -2
index 051eaa7d2899..2003731f1bee 100644
@@ -36,8 +36,13 @@ static int retimer_fwnode_match(struct device *dev, const void *fwnode)
 
 static void *typec_retimer_match(struct fwnode_handle *fwnode, const char *id, void *data)
 {
-	struct device *dev  = class_find_device(&retimer_class, NULL, fwnode,
-						retimer_fwnode_match);
+	struct device *dev;
+
+	if (id && !fwnode_property_present(fwnode, id))
+		return NULL;
+
+	dev = class_find_device(&retimer_class, NULL, fwnode,
+				retimer_fwnode_match);
 
 	return dev ? to_typec_retimer(dev) : ERR_PTR(-EPROBE_DEFER);
 }
Signature · 1 line
2.37.0
Reviewed-by on v1 1/1
#1 lore raw

HI Nícolas,

Quoted 12 lines · Nícolas F. R. A. Prado

The fwnode_connection_find_match() function handles two cases: named references and graph endpoints. In the second case, the match function passed in is called with the id to check for the match. However, the match function for the recently added type-c retimer class assumes the connection has already been matched (which is only true for the first case).

The result is that with that change, all type-c nodes with graph endpoints defer probe indefinitely, independently of having a retimer connection or not.

Quoted 5 lines

Add the missing check, like is done by the type-c mux and usb role switch code, to fix the issue.

Fixes ddaf8d96f93b ("usb: typec: Add support for retimers")

FWIW,

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Nícolas F. R. A. Prado
Quoted 11 lines · Nícolas F. R. A. Prado

The fwnode_connection_find_match() function handles two cases: named references and graph endpoints. In the second case, the match function passed in is called with the id to check for the match. However, the match function for the recently added type-c retimer class assumes the connection has already been matched (which is only true for the first case).

The result is that with that change, all type-c nodes with graph endpoints defer probe indefinitely, independently of having a retimer connection or not.

Quoted 5 lines

Add the missing check, like is done by the type-c mux and usb role switch code, to fix the issue.

Fixes ddaf8d96f93b ("usb: typec: Add support for retimers")
Quoted 15 lines

---

 drivers/usb/typec/retimer.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/usb/typec/retimer.c +0 -2
index 051eaa7d2899..2003731f1bee 100644
@@ -36,8 +36,13 @@ static int retimer_fwnode_match(struct device *dev, const void *fwnode)
 
 static void *typec_retimer_match(struct fwnode_handle *fwnode, const char *id, void *data)
 {
-	struct device *dev  = class_find_device(&retimer_class, NULL, fwnode,
-						retimer_fwnode_match);

drivers/usb/typec/retimer.c static int retimer_fwnode_match(struct device *dev, const void *fwnode) · line 48

Quoted 10 lines
drivers/usb/typec/retimer.c +7 -0
+	struct device *dev;
+
+	if (id && !fwnode_property_present(fwnode, id))
+		return NULL;
+
+	dev = class_find_device(&retimer_class, NULL, fwnode,
+				retimer_fwnode_match);
 
 	return dev ? to_typec_retimer(dev) : ERR_PTR(-EPROBE_DEFER);
 }

thanks,

Signature · 1 line
heikki