Skip to content

Commit 13aba1e

Browse files
Victor DingPrashant Malani
authored andcommitted
platform/chrome: cros_ec_typec: allow deferred probe of switch handles
`fwnode_typec_{retimer,mux,switch}_get()` could return `-EPROBE_DEFER`, which is called from `cros_typec_get_switch_handles`. When this happens, it does not indicate absence of switches; instead, it only hints that probing of switches should occur at a later time. Progagate `-EPROBE_DEFER` to upper layer logic so that they can re-try probing switches as a better time. Signed-off-by: Victor Ding <[email protected]> Reviewed-by: Benson Leung <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/20230124075555.v3.1.I6c0a089123fdf143f94ef4cca8677639031856cf@changeid Signed-off-by: Prashant Malani <[email protected]>
1 parent 6514bac commit 13aba1e

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,33 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
7575
struct fwnode_handle *fwnode,
7676
struct device *dev)
7777
{
78+
int ret = 0;
79+
7880
port->mux = fwnode_typec_mux_get(fwnode, NULL);
7981
if (IS_ERR(port->mux)) {
80-
dev_dbg(dev, "Mux handle not found.\n");
82+
ret = PTR_ERR(port->mux);
83+
dev_dbg(dev, "Mux handle not found: %d.\n", ret);
8184
goto mux_err;
8285
}
8386

8487
port->retimer = fwnode_typec_retimer_get(fwnode);
8588
if (IS_ERR(port->retimer)) {
86-
dev_dbg(dev, "Retimer handle not found.\n");
89+
ret = PTR_ERR(port->retimer);
90+
dev_dbg(dev, "Retimer handle not found: %d.\n", ret);
8791
goto retimer_sw_err;
8892
}
8993

9094
port->ori_sw = fwnode_typec_switch_get(fwnode);
9195
if (IS_ERR(port->ori_sw)) {
92-
dev_dbg(dev, "Orientation switch handle not found.\n");
96+
ret = PTR_ERR(port->ori_sw);
97+
dev_dbg(dev, "Orientation switch handle not found: %d\n", ret);
9398
goto ori_sw_err;
9499
}
95100

96101
port->role_sw = fwnode_usb_role_switch_get(fwnode);
97102
if (IS_ERR(port->role_sw)) {
98-
dev_dbg(dev, "USB role switch handle not found.\n");
103+
ret = PTR_ERR(port->role_sw);
104+
dev_dbg(dev, "USB role switch handle not found: %d\n", ret);
99105
goto role_sw_err;
100106
}
101107

@@ -111,7 +117,7 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
111117
typec_mux_put(port->mux);
112118
port->mux = NULL;
113119
mux_err:
114-
return -ENODEV;
120+
return ret;
115121
}
116122

117123
static int cros_typec_add_partner(struct cros_typec_data *typec, int port_num,
@@ -359,9 +365,11 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
359365
}
360366

361367
ret = cros_typec_get_switch_handles(cros_port, fwnode, dev);
362-
if (ret)
363-
dev_dbg(dev, "No switch control for port %d\n",
364-
port_num);
368+
if (ret) {
369+
dev_dbg(dev, "No switch control for port %d, err: %d\n", port_num, ret);
370+
if (ret == -EPROBE_DEFER)
371+
goto unregister_ports;
372+
}
365373

366374
ret = cros_typec_register_port_altmodes(typec, port_num);
367375
if (ret) {

0 commit comments

Comments
 (0)