thunderbolt: Add 'generation' attribute for devices
authorChristian Kellner <christian@kellner.me>
Thu, 3 Oct 2019 17:32:40 +0000 (19:32 +0200)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 9 Oct 2019 10:03:25 +0000 (13:03 +0300)
The Thunderbolt standard went through several major iterations, here
called generation. USB4, which will be based on Thunderbolt, will be
generation 4. Let userspace know the generation of the controller in
the devices in order to distinguish between Thunderbolt and USB4, so
it can be shown in various user interfaces.

Signed-off-by: Christian Kellner <christian@kellner.me>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Documentation/ABI/testing/sysfs-bus-thunderbolt
drivers/thunderbolt/switch.c

index b21fba14689bac8840d9d2fe7e1755dd857e498b..c31b4616181c484f73282f2f2fdf209beba2f849 100644 (file)
@@ -80,6 +80,14 @@ Contact:     thunderbolt-software@lists.01.org
 Description:   This attribute contains 1 if Thunderbolt device was already
                authorized on boot and 0 otherwise.
 
+What: /sys/bus/thunderbolt/devices/.../generation
+Date:          Jan 2020
+KernelVersion: 5.5
+Contact:       Christian Kellner <christian@kellner.me>
+Description:   This attribute contains the generation of the Thunderbolt
+               controller associated with the device. It will contain 4
+               for USB4.
+
 What: /sys/bus/thunderbolt/devices/.../key
 Date:          Sep 2017
 KernelVersion: 4.13
index 410bf1bceeee4f661850af632f49a11db672c5b8..ac9fa274080099bba41822717158b1fca913fb01 100644 (file)
@@ -1120,6 +1120,15 @@ device_name_show(struct device *dev, struct device_attribute *attr, char *buf)
 }
 static DEVICE_ATTR_RO(device_name);
 
+static ssize_t
+generation_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct tb_switch *sw = tb_to_switch(dev);
+
+       return sprintf(buf, "%u\n", sw->generation);
+}
+static DEVICE_ATTR_RO(generation);
+
 static ssize_t key_show(struct device *dev, struct device_attribute *attr,
                        char *buf)
 {
@@ -1325,6 +1334,7 @@ static struct attribute *switch_attrs[] = {
        &dev_attr_boot.attr,
        &dev_attr_device.attr,
        &dev_attr_device_name.attr,
+       &dev_attr_generation.attr,
        &dev_attr_key.attr,
        &dev_attr_nvm_authenticate.attr,
        &dev_attr_nvm_version.attr,