}
}
-static void cros_typec_remove_partner(struct cros_typec_data *typec,
- int port_num)
+static int cros_typec_usb_disconnect_state(struct cros_typec_port *port)
{
- struct cros_typec_port *port = typec->ports[port_num];
-
- cros_typec_unregister_altmodes(typec, port_num, true);
-
port->state.alt = NULL;
port->state.mode = TYPEC_STATE_USB;
port->state.data = NULL;
usb_role_switch_set_role(port->role_sw, USB_ROLE_NONE);
typec_switch_set(port->ori_sw, TYPEC_ORIENTATION_NONE);
- typec_mux_set(port->mux, &port->state);
+
+ return typec_mux_set(port->mux, &port->state);
+}
+
+static void cros_typec_remove_partner(struct cros_typec_data *typec,
+ int port_num)
+{
+ struct cros_typec_port *port = typec->ports[port_num];
+
+ cros_typec_unregister_altmodes(typec, port_num, true);
+
+ cros_typec_usb_disconnect_state(port);
typec_unregister_partner(port->partner);
port->partner = NULL;
enum typec_orientation orientation;
int ret;
+ if (mux_flags == USB_PD_MUX_NONE) {
+ ret = cros_typec_usb_disconnect_state(port);
+ goto mux_ack;
+ }
+
if (mux_flags & USB_PD_MUX_POLARITY_INVERTED)
orientation = TYPEC_ORIENTATION_REVERSE;
else
mux_flags);
}
+mux_ack:
if (!typec->needs_mux_ack)
return ret;