@@ -2327,6 +2327,20 @@ void typec_unregister_port(struct typec_port *port)
}
EXPORT_SYMBOL_GPL(typec_unregister_port);
+/**
+ * typec_port_get_name - Get USB Type-C Port name
+ * @port: The port to describe
+ *
+ * Returns a name of the passed USB Type-C port on success or NULL when the
+ * port has not been enumerated yet. The resulting string should be freed by
+ * the caller.
+ */
+char *typec_port_get_name(struct typec_port *port)
+{
+ return kasprintf(GFP_KERNEL, "typec:%s", dev_name(&port->dev));
+}
+EXPORT_SYMBOL_GPL(typec_port_get_name);
+
static int __init typec_init(void)
{
int ret;
@@ -303,6 +303,8 @@ struct typec_plug *typec_register_plug(struct typec_cable *cable,
struct typec_plug_desc *desc);
void typec_unregister_plug(struct typec_plug *plug);
+char *typec_port_get_name(struct typec_port *port);
+
void typec_set_data_role(struct typec_port *port, enum typec_data_role role);
void typec_set_pwr_role(struct typec_port *port, enum typec_role role);
void typec_set_vconn_role(struct typec_port *port, enum typec_role role);
We need a way to generate and return the Type-C port device names. For example, it is going to be used by the DRM to provide PATH property for DisplayPort connectors. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> --- drivers/usb/typec/class.c | 14 ++++++++++++++ include/linux/usb/typec.h | 2 ++ 2 files changed, 16 insertions(+)