We will be needing this when adding initial USB4 support so make it
available to other files in the driver as well. We also rename it to
tb_switch_find_port() to follow conventions used in switch.c.

No functional changes.

Signed-off-by: Mika Westerberg <mika.westerb...@linux.intel.com>
---
 drivers/thunderbolt/switch.c | 18 ++++++++++++++++++
 drivers/thunderbolt/tb.c     | 22 ++--------------------
 drivers/thunderbolt/tb.h     |  2 ++
 3 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 87c74c916a7c..8bc5d46011f8 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -2446,6 +2446,24 @@ struct tb_switch *tb_switch_find_by_route(struct tb *tb, 
u64 route)
        return NULL;
 }
 
+/**
+ * tb_switch_find_port() - return the first port of @type on @sw or NULL
+ * @sw: Switch to find the port from
+ * @type: Port type to look for
+ */
+struct tb_port *tb_switch_find_port(struct tb_switch *sw,
+                                   enum tb_port_type type)
+{
+       int i;
+
+       tb_switch_for_each_port(sw, i) {
+               if (sw->ports[i].config.type == type)
+                       return &sw->ports[i];
+       }
+
+       return NULL;
+}
+
 void tb_switch_exit(void)
 {
        ida_destroy(&nvm_ida);
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index a3b7a18dc6d9..eab93e32cc4f 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -343,24 +343,6 @@ static void tb_free_unplugged_children(struct tb_switch 
*sw)
        }
 }
 
-/**
- * tb_find_port() - return the first port of @type on @sw or NULL
- * @sw: Switch to find the port from
- * @type: Port type to look for
- */
-static struct tb_port *tb_find_port(struct tb_switch *sw,
-                                   enum tb_port_type type)
-{
-       int i;
-
-       tb_switch_for_each_port(sw, i) {
-               if (sw->ports[i].config.type == type)
-                       return &sw->ports[i];
-       }
-
-       return NULL;
-}
-
 /**
  * tb_find_unused_port() - return the first inactive port on @sw
  * @sw: Switch to find the port on
@@ -590,7 +572,7 @@ static int tb_tunnel_pci(struct tb *tb, struct tb_switch 
*sw)
        struct tb_switch *parent_sw;
        struct tb_tunnel *tunnel;
 
-       up = tb_find_port(sw, TB_TYPE_PCIE_UP);
+       up = tb_switch_find_port(sw, TB_TYPE_PCIE_UP);
        if (!up)
                return 0;
 
@@ -628,7 +610,7 @@ static int tb_approve_xdomain_paths(struct tb *tb, struct 
tb_xdomain *xd)
 
        sw = tb_to_switch(xd->dev.parent);
        dst_port = tb_port_at(xd->route, sw);
-       nhi_port = tb_find_port(tb->root_switch, TB_TYPE_NHI);
+       nhi_port = tb_switch_find_port(tb->root_switch, TB_TYPE_NHI);
 
        mutex_lock(&tb->lock);
        tunnel = tb_tunnel_alloc_dma(tb, nhi_port, dst_port, xd->transmit_ring,
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 7a8cc56a2870..f4ce739bfd7a 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -533,6 +533,8 @@ void tb_switch_suspend(struct tb_switch *sw);
 int tb_switch_resume(struct tb_switch *sw);
 int tb_switch_reset(struct tb *tb, u64 route);
 void tb_sw_set_unplugged(struct tb_switch *sw);
+struct tb_port *tb_switch_find_port(struct tb_switch *sw,
+                                   enum tb_port_type type);
 struct tb_switch *tb_switch_find_by_link_depth(struct tb *tb, u8 link,
                                               u8 depth);
 struct tb_switch *tb_switch_find_by_uuid(struct tb *tb, const uuid_t *uuid);
-- 
2.23.0

Reply via email to