Skip to content

Commit fb7a89a

Browse files
Sanjay R Mehtawesteri
authored andcommitted
thunderbolt: Do not read control adapter config space
Adapter 0 is the control adapter and as per USB4 spec in section 2.2.6.2 control Adapters do not have an adapter configuration space. For this reason skip reading adapter config space in tb_port_init() when the port number is 0. This actually simplifies the rest of the function as we don't need to check for the port->port == 0 anymore. While there drop the extra empty line at the end of the function. Signed-off-by: Basavaraj Natikar <[email protected]> Signed-off-by: Sanjay R Mehta <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
1 parent 7a1808f commit fb7a89a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/thunderbolt/switch.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,12 @@ static int tb_init_port(struct tb_port *port)
724724
int res;
725725
int cap;
726726

727+
INIT_LIST_HEAD(&port->list);
728+
729+
/* Control adapter does not have configuration space */
730+
if (!port->port)
731+
return 0;
732+
727733
res = tb_port_read(port, &port->config, TB_CFG_PORT, 0, 8);
728734
if (res) {
729735
if (res == -ENODEV) {
@@ -736,7 +742,7 @@ static int tb_init_port(struct tb_port *port)
736742
}
737743

738744
/* Port 0 is the switch itself and has no PHY. */
739-
if (port->config.type == TB_TYPE_PORT && port->port != 0) {
745+
if (port->config.type == TB_TYPE_PORT) {
740746
cap = tb_port_find_cap(port, TB_PORT_CAP_PHY);
741747

742748
if (cap > 0)
@@ -762,7 +768,7 @@ static int tb_init_port(struct tb_port *port)
762768
if (!port->ctl_credits)
763769
port->ctl_credits = 2;
764770

765-
} else if (port->port != 0) {
771+
} else {
766772
cap = tb_port_find_cap(port, TB_PORT_CAP_ADAP);
767773
if (cap > 0)
768774
port->cap_adap = cap;
@@ -773,10 +779,7 @@ static int tb_init_port(struct tb_port *port)
773779
ADP_CS_4_TOTAL_BUFFERS_SHIFT;
774780

775781
tb_dump_port(port->sw->tb, port);
776-
777-
INIT_LIST_HEAD(&port->list);
778782
return 0;
779-
780783
}
781784

782785
static int tb_port_alloc_hopid(struct tb_port *port, bool in, int min_hopid,

0 commit comments

Comments
 (0)