Commit 64843d0b authored by Michal Grzeschik's avatar Michal Grzeschik Committed by Greg Kroah-Hartman
Browse files

usb: typec: tcpm: allow to use sink in accessory mode



Since the function tcpm_acc_attach is not setting the data and role for
for the sink case we extend it to check for it first.

Signed-off-by: default avatarMichael Grzeschik <m.grzeschik@pengutronix.de>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20250404-ml-topic-tcpm-v1-1-b99f44badce8@pengutronix.de


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0f7bbef1
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -4551,12 +4551,17 @@ static void tcpm_snk_detach(struct tcpm_port *port)
static int tcpm_acc_attach(struct tcpm_port *port)
{
	int ret;
	enum typec_role role;
	enum typec_data_role data;

	if (port->attached)
		return 0;

	ret = tcpm_set_roles(port, true, TYPEC_SOURCE,
			     tcpm_data_role_for_source(port));
	role = tcpm_port_is_sink(port) ? TYPEC_SINK : TYPEC_SOURCE;
	data = tcpm_port_is_sink(port) ? tcpm_data_role_for_sink(port)
				       : tcpm_data_role_for_source(port);

	ret = tcpm_set_roles(port, true, role, data);
	if (ret < 0)
		return ret;