usb: Link the ports to the connectors they are attached to
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Wed, 7 Apr 2021 06:55:53 +0000 (09:55 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Apr 2021 14:00:00 +0000 (16:00 +0200)
Creating link to the USB Type-C connector for every new port
that is added when possible.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20210407065555.88110-3-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/ABI/testing/sysfs-bus-usb
drivers/usb/core/port.c

index bf2c196..8b4303a 100644 (file)
@@ -255,6 +255,15 @@ Description:
                is permitted, "u2" if only u2 is permitted, "u1_u2" if both u1 and
                u2 are permitted.
 
+What:          /sys/bus/usb/devices/.../(hub interface)/portX/connector
+Date:          April 2021
+Contact:       Heikki Krogerus <heikki.krogerus@linux.intel.com>
+Description:
+               Link to the USB Type-C connector when available. This link is
+               only created when USB Type-C Connector Class is enabled, and
+               only if the system firmware is capable of describing the
+               connection between a port and its connector.
+
 What:          /sys/bus/usb/devices/.../power/usb2_lpm_l1_timeout
 Date:          May 2013
 Contact:       Mathias Nyman <mathias.nyman@linux.intel.com>
index dfcca9c..3c382a4 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/slab.h>
 #include <linux/pm_qos.h>
+#include <linux/usb/typec.h>
 
 #include "hub.h"
 
@@ -576,6 +577,7 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
        }
 
        find_and_link_peer(hub, port1);
+       typec_link_port(&port_dev->dev);
 
        /*
         * Enable runtime pm and hold a refernce that hub_configure()
@@ -619,5 +621,6 @@ void usb_hub_remove_port_device(struct usb_hub *hub, int port1)
        peer = port_dev->peer;
        if (peer)
                unlink_peers(port_dev, peer);
+       typec_unlink_port(&port_dev->dev);
        device_unregister(&port_dev->dev);
 }