[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241001173109.1513-12-alexandru.gagniuc@hp.com>
Date: Tue, 1 Oct 2024 17:31:06 +0000
From: Alexandru Gagniuc <alexandru.gagniuc@...com>
To: gregkh@...uxfoundation.org,
stable@...r.kernel.org
Cc: qin.wan@...com,
andreas.noever@...il.com,
michael.jamet@...el.com,
mika.westerberg@...ux.intel.com,
YehezkelShB@...il.com,
linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org,
Alexandru Gagniuc <alexandru.gagniuc@...com>
Subject: [PATCH 6.6 11/14] thunderbolt: Introduce tb_switch_depth()
From: Mika Westerberg <mika.westerberg@...ux.intel.com>
[ Upstream commit c4ff14436952c3d0dd05769d76cf48e73a253b48 ]
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@...ux.intel.com>
Signed-off-by: Qin Wan <qin.wan@...com>
Signed-off-by: Alexandru Gagniuc <alexandru.gagniuc@...com>
---
drivers/thunderbolt/tb.c | 4 ++--
drivers/thunderbolt/tb.h | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 4ea0536ec5cf..39ec8da576ef 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -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;
/*
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 4cd5f48e3dee..d2ef9575231c 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -868,6 +868,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 &&
--
2.45.1
Powered by blists - more mailing lists