thunderbolt: Move tb_enable_tmu() close to other TMU functions
authorMika Westerberg <mika.westerberg@linux.intel.com>
Fri, 7 Oct 2022 14:49:01 +0000 (17:49 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Fri, 9 Jun 2023 09:07:23 +0000 (12:07 +0300)
This makes the code easier to follow. No functional changes.

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

index 0630b87..41c353f 100644 (file)
@@ -272,6 +272,35 @@ static void tb_increase_tmu_accuracy(struct tb_tunnel *tunnel)
        device_for_each_child(&sw->dev, NULL, tb_increase_switch_tmu_accuracy);
 }
 
+static int tb_enable_tmu(struct tb_switch *sw)
+{
+       int ret;
+
+       /*
+        * If CL1 is enabled then we need to configure the TMU accuracy
+        * level to normal. Otherwise we keep the TMU running at the
+        * highest accuracy.
+        */
+       if (tb_switch_is_clx_enabled(sw, TB_CL1))
+               tb_switch_tmu_configure(sw, TB_SWITCH_TMU_RATE_NORMAL, true);
+       else
+               tb_switch_tmu_configure(sw, TB_SWITCH_TMU_RATE_HIFI, false);
+
+       /* If it is already enabled in correct mode, don't touch it */
+       if (tb_switch_tmu_is_enabled(sw))
+               return 0;
+
+       ret = tb_switch_tmu_disable(sw);
+       if (ret)
+               return ret;
+
+       ret = tb_switch_tmu_post_time(sw);
+       if (ret)
+               return ret;
+
+       return tb_switch_tmu_enable(sw);
+}
+
 static void tb_switch_discover_tunnels(struct tb_switch *sw,
                                       struct list_head *list,
                                       bool alloc_hopids)
@@ -383,35 +412,6 @@ static void tb_scan_xdomain(struct tb_port *port)
        }
 }
 
-static int tb_enable_tmu(struct tb_switch *sw)
-{
-       int ret;
-
-       /*
-        * If CL1 is enabled then we need to configure the TMU accuracy
-        * level to normal. Otherwise we keep the TMU running at the
-        * highest accuracy.
-        */
-       if (tb_switch_is_clx_enabled(sw, TB_CL1))
-               tb_switch_tmu_configure(sw, TB_SWITCH_TMU_RATE_NORMAL, true);
-       else
-               tb_switch_tmu_configure(sw, TB_SWITCH_TMU_RATE_HIFI, false);
-
-       /* If it is already enabled in correct mode, don't touch it */
-       if (tb_switch_tmu_is_enabled(sw))
-               return 0;
-
-       ret = tb_switch_tmu_disable(sw);
-       if (ret)
-               return ret;
-
-       ret = tb_switch_tmu_post_time(sw);
-       if (ret)
-               return ret;
-
-       return tb_switch_tmu_enable(sw);
-}
-
 /**
  * tb_find_unused_port() - return the first inactive port on @sw
  * @sw: Switch to find the port on