thunderbolt: Check Intel vendor ID in tb_switch_get_generation()
authorMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 28 Dec 2022 07:45:35 +0000 (09:45 +0200)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 8 Aug 2023 05:13:17 +0000 (08:13 +0300)
Only Intel made Thunderbolt 1-3 devices so to avoid possible confusion
check for the Intel vendor ID before deciding the device generation.
While there move the USB4 check to happen first.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/switch.c

index 7ea63bb3171409cf504eb7b362ac2663df46d350..43171cc1cc2d83c223bef20dad7a18fd22841c0e 100644 (file)
@@ -2188,46 +2188,47 @@ struct device_type tb_switch_type = {
 
 static int tb_switch_get_generation(struct tb_switch *sw)
 {
-       switch (sw->config.device_id) {
-       case PCI_DEVICE_ID_INTEL_LIGHT_RIDGE:
-       case PCI_DEVICE_ID_INTEL_EAGLE_RIDGE:
-       case PCI_DEVICE_ID_INTEL_LIGHT_PEAK:
-       case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_2C:
-       case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C:
-       case PCI_DEVICE_ID_INTEL_PORT_RIDGE:
-       case PCI_DEVICE_ID_INTEL_REDWOOD_RIDGE_2C_BRIDGE:
-       case PCI_DEVICE_ID_INTEL_REDWOOD_RIDGE_4C_BRIDGE:
-               return 1;
-
-       case PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_BRIDGE:
-       case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE:
-       case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE:
-               return 2;
-
-       case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_LP_BRIDGE:
-       case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_BRIDGE:
-       case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_BRIDGE:
-       case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_BRIDGE:
-       case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_BRIDGE:
-       case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_BRIDGE:
-       case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_BRIDGE:
-       case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_BRIDGE:
-       case PCI_DEVICE_ID_INTEL_ICL_NHI0:
-       case PCI_DEVICE_ID_INTEL_ICL_NHI1:
-               return 3;
+       if (tb_switch_is_usb4(sw))
+               return 4;
 
-       default:
-               if (tb_switch_is_usb4(sw))
-                       return 4;
+       if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) {
+               switch (sw->config.device_id) {
+               case PCI_DEVICE_ID_INTEL_LIGHT_RIDGE:
+               case PCI_DEVICE_ID_INTEL_EAGLE_RIDGE:
+               case PCI_DEVICE_ID_INTEL_LIGHT_PEAK:
+               case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_2C:
+               case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C:
+               case PCI_DEVICE_ID_INTEL_PORT_RIDGE:
+               case PCI_DEVICE_ID_INTEL_REDWOOD_RIDGE_2C_BRIDGE:
+               case PCI_DEVICE_ID_INTEL_REDWOOD_RIDGE_4C_BRIDGE:
+                       return 1;
 
-               /*
-                * For unknown switches assume generation to be 1 to be
-                * on the safe side.
-                */
-               tb_sw_warn(sw, "unsupported switch device id %#x\n",
-                          sw->config.device_id);
-               return 1;
+               case PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_BRIDGE:
+               case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE:
+               case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE:
+                       return 2;
+
+               case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_LP_BRIDGE:
+               case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_BRIDGE:
+               case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_BRIDGE:
+               case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_BRIDGE:
+               case PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_BRIDGE:
+               case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_BRIDGE:
+               case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_BRIDGE:
+               case PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_BRIDGE:
+               case PCI_DEVICE_ID_INTEL_ICL_NHI0:
+               case PCI_DEVICE_ID_INTEL_ICL_NHI1:
+                       return 3;
+               }
        }
+
+       /*
+        * For unknown switches assume generation to be 1 to be on the
+        * safe side.
+        */
+       tb_sw_warn(sw, "unsupported switch device id %#x\n",
+                  sw->config.device_id);
+       return 1;
 }
 
 static bool tb_switch_exceeds_max_depth(const struct tb_switch *sw, int depth)