public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Revert "tcpm: allow looking for role_sw device in the main node"
@ 2026-02-24 11:01 Xu Yang
  2026-02-24 11:33 ` Arnaud Ferraris
  0 siblings, 1 reply; 9+ messages in thread
From: Xu Yang @ 2026-02-24 11:01 UTC (permalink / raw)
  To: badhri, heikki.krogerus, gregkh, arnaud.ferraris, dsimic
  Cc: linux-usb, linux-kernel, imx, jun.li

This reverts commit 1366cd228b0c67b60a2c0c26ef37fe9f7cfedb7f.

The fwnode_usb_role_switch_get() returns NULL only if no connection is
found, returns ERR_PTR(-EPROBE_DEFER) if connection is found but deferred
probe is needed, or a valid pointer of usb_role_switch.

When switching from NULL check to IS_ERR_OR_NULL(), usb_role_switch_get()
will return NULL pointer which will override ERR_PTR(-EPROBE_DEFER) which
is returned by fwnode_usb_role_switch_get(). Then usb role switch can't be
obtained because the defer probe info is lost. So the unique error should
not be regarded the same as NULL.

Fixes: 1366cd228b0c ("tcpm: allow looking for role_sw device in the main node")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

---
Also correct a description in 1366cd228b0c ("tcpm: allow looking for
role_sw device in the main node"), if the ports are defined in the tcpc
main node, NULL pointer is returned by fwnode_usb_role_switch_get()
instead of an error.
---
 drivers/usb/typec/tcpm/tcpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 1d2f3af034c5..8e0e14a2704e 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -7890,7 +7890,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	port->partner_desc.identity = &port->partner_ident;
 
 	port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode);
-	if (IS_ERR_OR_NULL(port->role_sw))
+	if (!port->role_sw)
 		port->role_sw = usb_role_switch_get(port->dev);
 	if (IS_ERR(port->role_sw)) {
 		err = PTR_ERR(port->role_sw);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-03-09  7:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24 11:01 [PATCH] Revert "tcpm: allow looking for role_sw device in the main node" Xu Yang
2026-02-24 11:33 ` Arnaud Ferraris
2026-02-25  2:57   ` Xu Yang
2026-02-27 15:45     ` Arnaud Ferraris
2026-03-05  9:40       ` Xu Yang
2026-03-05 16:36         ` Arnaud Ferraris
2026-03-06  9:52           ` Xu Yang
2026-03-06 16:24             ` Arnaud Ferraris
2026-03-09  7:36               ` Xu Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox