Skip to contentSkip to conversation

Revert "usb: typec: mux: Remove requirement for the "orientation-switch" device property"

PATCH In review Heikki Krogerus 2 participants 2 messages Jun 2, 2021

Subsystems (2)
lore
Share & tools
lore

Heikki Krogerus

author maintainer
#0 lore raw

PATCH 1/1 Revert "usb: typec: mux: Remove requirement for the "orientation-switch" device property"

This reverts commit acad3e9c7250c5fd20d9778a163f2adc95de38f5.

The device property that can be used to identify the device class/type of the remote port parent when device graph is used is always needed after all. Without it there is no real way to know is the requested connection actually described in the device graph or not.

If the connection is described in the device graph but the device instance is still missing for what ever reason, the code defers probe for now.

Adding a comment to the code to explain this.

---
Hi,

I'm sorry about this again. I hope the comments help prevent me from doing the same thing again.

thanks,

---
 drivers/usb/typec/mux.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/usb/typec/mux.c +16 -0
index 603f3e698cc0b..664fb3513f480 100644
@@ -30,6 +30,22 @@ static void *typec_switch_match(struct fwnode_handle *fwnode, const char *id,
 {
 	struct device *dev;
 
+	/*
+	 * Device graph (OF graph) does not give any means to identify the
+	 * device type or the device class of the remote port parent that @fwnode
+	 * represents, so in order to identify the type or the class of @fwnode
+	 * an additional device property is needed. With typec switches the
+	 * property is named "orientation-switch" (@id). The value of the device
+	 * property is ignored.
+	 */
+	if (id && !fwnode_property_present(fwnode, id))
+		return NULL;
+
+	/*
+	 * At this point we are sure that @fwnode is a typec switch in all
+	 * cases. If the switch hasn't yet been registered for some reason, the
+	 * function "defers probe" for now.
+	 */
 	dev = class_find_device(&typec_mux_class, NULL, fwnode,
 				switch_fwnode_match);
 
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 15 lines

-----Original Message-----
From: Heikki Krogerus <[email protected]>
Sent: Wednesday, June 2, 2021 7:23 PM
To: Greg Kroah-Hartman <[email protected]>
Cc: Jun Li <[email protected]>; [email protected]
Subject: [PATCH] Revert "usb: typec: mux: Remove requirement for the "orientation-switch" device property"

This reverts commit acad3e9c7250c5fd20d9778a163f2adc95de38f5.

The device property that can be used to identify the device class/type of the remote port parent when device graph is used is always needed after all. Without it there is no real way to know is the requested connection actually described in the device graph or not.

Quoted 6 lines

If the connection is described in the device graph but the device instance is still missing for what ever reason, the code defers probe for now.

Adding a comment to the code to explain this.

Quoted 40 lines

---
Hi,

I'm sorry about this again. I hope the comments help prevent me from doing the same thing again.

thanks,

---
 drivers/usb/typec/mux.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/usb/typec/mux.c index renamed from drivers/usb/typec/mux.c +0 -0

603f3e698cc0b..664fb3513f480 100644

drivers/usb/typec/mux.c +16 -1
@@ -30,6 +30,22 @@ static void *typec_switch_match(struct fwnode_handle
 *fwnode, const char *id,  {
 	struct device *dev;
 
+	/*
+	 * Device graph (OF graph) does not give any means to identify the
+	 * device type or the device class of the remote port parent that @fwnode
+	 * represents, so in order to identify the type or the class of @fwnode
+	 * an additional device property is needed. With typec switches the
+	 * property is named "orientation-switch" (@id). The value of the device
+	 * property is ignored.
+	 */
+	if (id && !fwnode_property_present(fwnode, id))
+		return NULL;
+
+	/*
+	 * At this point we are sure that @fwnode is a typec switch in all
+	 * cases. If the switch hasn't yet been registered for some reason, the
+	 * function "defers probe" for now.
+	 */
 	dev = class_find_device(&typec_mux_class, NULL, fwnode,
 				switch_fwnode_match);
 
--

2.30.2