Commit 13aba1e5 authored by Victor Ding's avatar Victor Ding Committed by Prashant Malani

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: default avatarVictor Ding <victording@chromium.org>
Reviewed-by: default avatarBenson Leung <bleung@chromium.org>
Reviewed-by: default avatarGuenter Roeck <groeck@chromium.org>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20230124075555.v3.1.I6c0a089123fdf143f94ef4cca8677639031856cf@changeidSigned-off-by: default avatarPrashant Malani <pmalani@chromium.org>
parent 6514bac4
...@@ -75,27 +75,33 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port, ...@@ -75,27 +75,33 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
struct fwnode_handle *fwnode, struct fwnode_handle *fwnode,
struct device *dev) struct device *dev)
{ {
int ret = 0;
port->mux = fwnode_typec_mux_get(fwnode, NULL); port->mux = fwnode_typec_mux_get(fwnode, NULL);
if (IS_ERR(port->mux)) { if (IS_ERR(port->mux)) {
dev_dbg(dev, "Mux handle not found.\n"); ret = PTR_ERR(port->mux);
dev_dbg(dev, "Mux handle not found: %d.\n", ret);
goto mux_err; goto mux_err;
} }
port->retimer = fwnode_typec_retimer_get(fwnode); port->retimer = fwnode_typec_retimer_get(fwnode);
if (IS_ERR(port->retimer)) { if (IS_ERR(port->retimer)) {
dev_dbg(dev, "Retimer handle not found.\n"); ret = PTR_ERR(port->retimer);
dev_dbg(dev, "Retimer handle not found: %d.\n", ret);
goto retimer_sw_err; goto retimer_sw_err;
} }
port->ori_sw = fwnode_typec_switch_get(fwnode); port->ori_sw = fwnode_typec_switch_get(fwnode);
if (IS_ERR(port->ori_sw)) { if (IS_ERR(port->ori_sw)) {
dev_dbg(dev, "Orientation switch handle not found.\n"); ret = PTR_ERR(port->ori_sw);
dev_dbg(dev, "Orientation switch handle not found: %d\n", ret);
goto ori_sw_err; goto ori_sw_err;
} }
port->role_sw = fwnode_usb_role_switch_get(fwnode); port->role_sw = fwnode_usb_role_switch_get(fwnode);
if (IS_ERR(port->role_sw)) { if (IS_ERR(port->role_sw)) {
dev_dbg(dev, "USB role switch handle not found.\n"); ret = PTR_ERR(port->role_sw);
dev_dbg(dev, "USB role switch handle not found: %d\n", ret);
goto role_sw_err; goto role_sw_err;
} }
...@@ -111,7 +117,7 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port, ...@@ -111,7 +117,7 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
typec_mux_put(port->mux); typec_mux_put(port->mux);
port->mux = NULL; port->mux = NULL;
mux_err: mux_err:
return -ENODEV; return ret;
} }
static int cros_typec_add_partner(struct cros_typec_data *typec, int port_num, 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) ...@@ -359,9 +365,11 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
} }
ret = cros_typec_get_switch_handles(cros_port, fwnode, dev); ret = cros_typec_get_switch_handles(cros_port, fwnode, dev);
if (ret) if (ret) {
dev_dbg(dev, "No switch control for port %d\n", dev_dbg(dev, "No switch control for port %d, err: %d\n", port_num, ret);
port_num); if (ret == -EPROBE_DEFER)
goto unregister_ports;
}
ret = cros_typec_register_port_altmodes(typec, port_num); ret = cros_typec_register_port_altmodes(typec, port_num);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment