Skip to content

Commit 6f3bade

Browse files
committed
thunderbolt: Hide authorized attribute if router does not support PCIe tunnels
With USB4 devices PCIe tunneling is optional so for device routers without PCIe upstream adapter it does not make much sense to expose the authorized attribute. For this reason hide it if PCIe tunneling is not supported by the device router. Signed-off-by: Mika Westerberg <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]>
1 parent 2f608ba commit 6f3bade

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/thunderbolt/switch.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,18 @@ static struct attribute *switch_attrs[] = {
17461746
NULL,
17471747
};
17481748

1749+
static bool has_port(const struct tb_switch *sw, enum tb_port_type type)
1750+
{
1751+
const struct tb_port *port;
1752+
1753+
tb_switch_for_each_port(sw, port) {
1754+
if (!port->disabled && port->config.type == type)
1755+
return true;
1756+
}
1757+
1758+
return false;
1759+
}
1760+
17491761
static umode_t switch_attr_is_visible(struct kobject *kobj,
17501762
struct attribute *attr, int n)
17511763
{
@@ -1754,7 +1766,8 @@ static umode_t switch_attr_is_visible(struct kobject *kobj,
17541766

17551767
if (attr == &dev_attr_authorized.attr) {
17561768
if (sw->tb->security_level == TB_SECURITY_NOPCIE ||
1757-
sw->tb->security_level == TB_SECURITY_DPONLY)
1769+
sw->tb->security_level == TB_SECURITY_DPONLY ||
1770+
!has_port(sw, TB_TYPE_PCIE_UP))
17581771
return 0;
17591772
} else if (attr == &dev_attr_device.attr) {
17601773
if (!sw->device)

0 commit comments

Comments
 (0)