summaryrefslogtreecommitdiffstats
path: root/drivers/thunderbolt/switch.c
diff options
context:
space:
mode:
authorMika Westerberg2017-06-06 14:25:05 +0200
committerGreg Kroah-Hartman2017-06-09 11:42:42 +0200
commit72ee33907b629355d8fd1980140a467041a9f519 (patch)
tree3f5242955d986d7f22137d02582566a047c821b2 /drivers/thunderbolt/switch.c
parentthunderbolt: Refactor and fix parsing of port drom entries (diff)
downloadkernel-qcow2-linux-72ee33907b629355d8fd1980140a467041a9f519.tar.gz
kernel-qcow2-linux-72ee33907b629355d8fd1980140a467041a9f519.tar.xz
kernel-qcow2-linux-72ee33907b629355d8fd1980140a467041a9f519.zip
thunderbolt: Read vendor and device name from DROM
The device DROM contains name of the vendor and device among other things. Extract this information and expose it to the userspace via two new attributes. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Yehezkel Bernat <yehezkel.bernat@intel.com> Reviewed-by: Michael Jamet <michael.jamet@intel.com> Signed-off-by: Andreas Noever <andreas.noever@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/thunderbolt/switch.c')
-rw-r--r--drivers/thunderbolt/switch.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 2390f08b94da..11f16a141686 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -319,6 +319,15 @@ static ssize_t device_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(device);
+static ssize_t
+device_name_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct tb_switch *sw = tb_to_switch(dev);
+
+ return sprintf(buf, "%s\n", sw->device_name ? sw->device_name : "");
+}
+static DEVICE_ATTR_RO(device_name);
+
static ssize_t vendor_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -328,6 +337,15 @@ static ssize_t vendor_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(vendor);
+static ssize_t
+vendor_name_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct tb_switch *sw = tb_to_switch(dev);
+
+ return sprintf(buf, "%s\n", sw->vendor_name ? sw->vendor_name : "");
+}
+static DEVICE_ATTR_RO(vendor_name);
+
static ssize_t unique_id_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -339,7 +357,9 @@ static DEVICE_ATTR_RO(unique_id);
static struct attribute *switch_attrs[] = {
&dev_attr_device.attr,
+ &dev_attr_device_name.attr,
&dev_attr_vendor.attr,
+ &dev_attr_vendor_name.attr,
&dev_attr_unique_id.attr,
NULL,
};
@@ -358,6 +378,8 @@ static void tb_switch_release(struct device *dev)
struct tb_switch *sw = tb_to_switch(dev);
kfree(sw->uuid);
+ kfree(sw->device_name);
+ kfree(sw->vendor_name);
kfree(sw->ports);
kfree(sw->drom);
kfree(sw);