]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thunderbolt: Introduce tb_switch_depth()
authorMika Westerberg <mika.westerberg@linux.intel.com>
Mon, 4 Sep 2023 06:09:34 +0000 (09:09 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Fri, 20 Oct 2023 15:18:01 +0000 (18:18 +0300)
This is useful helper to find out the depth of a connected router.
Convert the existing users to call this helper instead of open-coding.

No functional changes.

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

index ad7142be39cc41c3494e333cd78c0a589fde204c..a0932545f4399fd32c173925f58b13f429f3090d 100644 (file)
@@ -255,13 +255,13 @@ static int tb_enable_clx(struct tb_switch *sw)
         * this in the future to cover the whole topology if it turns
         * out to be beneficial.
         */
-       while (sw && sw->config.depth > 1)
+       while (sw && tb_switch_depth(sw) > 1)
                sw = tb_switch_parent(sw);
 
        if (!sw)
                return 0;
 
-       if (sw->config.depth != 1)
+       if (tb_switch_depth(sw) != 1)
                return 0;
 
        /*
index 869ac360e1b50e41eb74a4bedd6f38b071097376..80e28124f583bbd7b949a0720bac3299ed4739a4 100644 (file)
@@ -866,6 +866,15 @@ static inline struct tb_port *tb_switch_downstream_port(struct tb_switch *sw)
        return tb_port_at(tb_route(sw), tb_switch_parent(sw));
 }
 
+/**
+ * tb_switch_depth() - Returns depth of the connected router
+ * @sw: Router
+ */
+static inline int tb_switch_depth(const struct tb_switch *sw)
+{
+       return sw->config.depth;
+}
+
 static inline bool tb_switch_is_light_ridge(const struct tb_switch *sw)
 {
        return sw->config.vendor_id == PCI_VENDOR_ID_INTEL &&