Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: typec: class: add typec_get_data_role symbol

Alt Mode drivers are responsible for sending Enter Mode through the TCPM,
but only a DFP is allowed to send Enter Mode. typec_get_data_role gets
the port's data role, which can then be used in altmode drivers via
typec_altmode_get_data_role to know if Enter Mode should be sent.

Signed-off-by: RD Babiera <rdbabiera@google.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20250923181606.1583584-5-rdbabiera@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

RD Babiera and committed by
Greg Kroah-Hartman
ed4a5c5d 924aa1d9

+27
+13
drivers/usb/typec/class.c
··· 2121 2121 EXPORT_SYMBOL_GPL(typec_set_data_role); 2122 2122 2123 2123 /** 2124 + * typec_get_data_role - Get port data role 2125 + * @port: The USB Type-C Port to query 2126 + * 2127 + * This routine is used by the altmode drivers to determine if the port is the 2128 + * DFP before issuing Enter Mode 2129 + */ 2130 + enum typec_data_role typec_get_data_role(struct typec_port *port) 2131 + { 2132 + return port->data_role; 2133 + } 2134 + EXPORT_SYMBOL_GPL(typec_get_data_role); 2135 + 2136 + /** 2124 2137 * typec_set_pwr_role - Report power role change 2125 2138 * @port: The USB Type-C Port where the role was changed 2126 2139 * @role: The new data role
+1
include/linux/usb/typec.h
··· 337 337 void typec_unregister_plug(struct typec_plug *plug); 338 338 339 339 void typec_set_data_role(struct typec_port *port, enum typec_data_role role); 340 + enum typec_data_role typec_get_data_role(struct typec_port *port); 340 341 void typec_set_pwr_role(struct typec_port *port, enum typec_role role); 341 342 void typec_set_vconn_role(struct typec_port *port, enum typec_role role); 342 343 void typec_set_pwr_opmode(struct typec_port *port, enum typec_pwr_opmode mode);
+13
include/linux/usb/typec_altmode.h
··· 173 173 } 174 174 175 175 /** 176 + * typec_altmode_get_data_role - Get port data role 177 + * @altmode: Handle to the alternate mode 178 + * 179 + * Alt Mode drivers should only issue Enter Mode through the port if they are 180 + * the DFP. 181 + */ 182 + static inline enum typec_data_role 183 + typec_altmode_get_data_role(struct typec_altmode *altmode) 184 + { 185 + return typec_get_data_role(typec_altmode2port(altmode)); 186 + } 187 + 188 + /** 176 189 * struct typec_altmode_driver - USB Type-C alternate mode device driver 177 190 * @id_table: Null terminated array of SVIDs 178 191 * @probe: Callback for device binding