thunderbolt: Check router generation before connecting xHCI
authorMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 14 Jun 2022 15:53:59 +0000 (18:53 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Thu, 18 Aug 2022 08:55:52 +0000 (11:55 +0300)
Only Thunderbolt 3 routers need the xHCI connection flow. This also
ensures the router actually has both lane adapters (1 and 3). While
there move declaration of the boolean variables inside the block where
they are being used.

Fixes: 30a4eca69b76 ("thunderbolt: Add internal xHCI connect flows for Thunderbolt 3 devices")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/switch.c

index 244f8cd38b25917389b05d0b197f6eaab1db3f85..c63c1f4ff9dc7b445a9361c4b8719775ac598041 100644 (file)
@@ -3786,14 +3786,18 @@ int tb_switch_pcie_l1_enable(struct tb_switch *sw)
  */
 int tb_switch_xhci_connect(struct tb_switch *sw)
 {
-       bool usb_port1, usb_port3, xhci_port1, xhci_port3;
        struct tb_port *port1, *port3;
        int ret;
 
+       if (sw->generation != 3)
+               return 0;
+
        port1 = &sw->ports[1];
        port3 = &sw->ports[3];
 
        if (tb_switch_is_alpine_ridge(sw)) {
+               bool usb_port1, usb_port3, xhci_port1, xhci_port3;
+
                usb_port1 = tb_lc_is_usb_plugged(port1);
                usb_port3 = tb_lc_is_usb_plugged(port3);
                xhci_port1 = tb_lc_is_xhci_connected(port1);